Add basic shape tools to the example drawing area
维护者通常 1 天内回复
@Chuyutseng 已经在做这个了。
开始于 2026年11月8日。
评估
这个 Issue 还没有评估数据。
描述
Observed behavior
The Example drawing area introduced in PR #262 allows candidates to illustrate examples during coding interviews without hiding the code editor. It currently supports freehand drawing, erasing, undo, clear, color selection, and text labels, but does not provide tools for drawing basic geometric shapes.
Candidates must manually draw rectangles, circles, and straight lines using the pen tool, making it difficult to create consistent diagrams when explaining data structures, algorithms, or relationships between elements.
Expected behavior
The Example drawing area should support three additional drawing tools:
- Rectangle: Draw a rectangle between two points.
- Ellipse: Draw a circle or ellipse within the dragged bounds.
- Line: Draw a straight line between two points.
Candidates should be able to preview a shape while dragging and complete it when releasing the pointer.
Each completed shape should behave as a single undoable operation, reuse the existing color selection, and remain compatible with recording, replay, and reconnection.
Reproduction
- Start a Coding interview with Example drawing enabled.
- Expand the Example drawing area below the code editor.
- Observe that the toolbar provides pen, eraser, text, undo, clear, and color selection.
- Attempt to draw a rectangle, circle, or straight line.
- Observe that these shapes must be drawn manually using the pen tool.
Initial analysis
The drawing model and rendering logic are implemented in web/whiteboard.js, with corresponding tests in tests/browser/whiteboard.test.js. The existing drawing operations support undo, clearing, and replay through a shared drawing model.
PR #523 introduced structured text operations shared by Whiteboard and Example drawing. The proposed shape tools should reuse the existing drawing infrastructure where possible.
The implementation would need to consider:
- Toolbar controls: Add rectangle, ellipse, and line tools alongside the existing drawing controls.
- Pointer handling: Track the initial pointer position and current position to determine shape geometry.
- Drawing preview: Render temporary shapes during dragging without adding intermediate previews to the operation history.
- Operation history: Commit each completed shape as a single undoable operation.
- Recording and replay: Ensure that completed shapes are preserved and rendered correctly.
- Reconnection: Retain completed drawings after reconnecting.
The operation representation should minimize changes to the existing drawing protocol while preserving compatibility with recording, replay, and reconnection.
Proposed change
Extend the Example drawing area with three basic shape tools: Rectangle, Ellipse, and Line.
Selecting a shape tool should allow candidates to press, drag, and release the pointer to create the corresponding shape. A temporary preview should be displayed during dragging, and the completed shape should be committed to the drawing history when the pointer is released.
The implementation should preserve existing pen, eraser, text, undo, clear, color selection, recording, replay, and reconnection behavior.
Validation plan
Add browser regression tests covering:
- Rectangle, ellipse, and line creation using pointer interactions.
- Shape geometry when dragging in different directions.
- Shape preview and final rendering.
- Color selection for newly created shapes.
- Undo and clear behavior for completed shapes.
- Recording and replay of drawings containing geometric shapes.
- Preservation of completed shapes after reconnection.
- Regression coverage for existing pen, eraser, and text tools.
Tests should verify the actual drawing output rather than only checking whether toolbar buttons or canvas elements are visible.
Run ./scripts/test.sh and report the results, including any skipped checks.
- 主要语言
- Rust
- 星标
- 223
- 派生
- 148
- 平均合并
- 1 天 4 小时
- 30 天内合并 PR
- 223
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
sysprog21/codetrial 的其他 Issue
-
难度 1/5 1 小时以内 新手友好度 84/100
维护者通常 1 天内回复
-
Show recorded scores in past attempt rows可能已有人在做 @liehcheng 于 1 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
sysprog21/codetrial#604 · 4 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
-
Remind the candidate when they speak while the microphone is muted可能已有人在做 @gino1203 今天认领。 未关闭
sysprog21/codetrial#627 · 已指派 1 人 ·
维护者通常 1 天内回复
-
The peer lobby stays on "Checking account..." when an invite link is opened with site data blocked可能已有人在做 @dges5202 今天认领。 未关闭
sysprog21/codetrial#626 · 3 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
-
Browser-local practice backend可能已有人在做 @tony2037 今天认领。 未关闭
sysprog21/codetrial#621 · 2 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
查看 sysprog21/codetrial 的全部 Issue
相似的 Issue
-
needs-triage tooling
难度 1/5 1 小时以内 新手友好度 90/100
neilsh/stunt-reel#317 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 84/100
storytold/craft-fonts#65 ·
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 86/100
storytold/craft-libs#723 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 83/100
n0-computer/iroh#4669 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复