forge
Explore
Log in

Don't you dare go Hollow

Commits

Commits on c35a83aa3f65a20c8a2fdfd2dfdb3e35878741b5Filtered to src/lib/draw-stroke.test.tsClear filter

2026-07-22

feat: 🎬 draw-and-replay for question-pool photos, DPR-correct playbackAhmet Kaan Gümüş · 0fbb97c
feat: 🎬 draw-and-replay for question-pool photos, DPR-correct playback

- ask/solution forms gain a draw option alongside the existing file
  input, not instead of it: photographing a textbook problem is still
  the common case, drawing is now just another way to fill the same
  photo field
- both pool photo displays (question and solution) are now replayable
  the same way a student's answer drawing already was, via new
  getQuestionImageBlob/getSolutionImageBlob blobClient fetchers
- the img/playback toggle used to live inline in answer-sheet-view's
  AnswerDrawing; pulled out to a shared ReplayableImage (its third call
  site) so the pool views reuse it instead of a copy, and DrawingPlayback
  moved from components/exams to components/ui since it's no longer
  exam-only
- fixed a DPR mismatch in playback: an exported PNG bakes its pixel
  dimensions at the author's device-pixel-ratio, but the scene JSON only
  carried world (DPR-free) width/height, so replay on a viewer with a
  different ratio than the author rendered at half or double the
  correct size. DrawScene now carries the export's dpr, DrawCanvas
  stamps it when exporting, and a shared canvasPx() sizes both the
  export canvas and the playback canvas off the same number
- hardened parseScene's bounds: the scene JSON is recovered from a
  user-uploaded PNG's tEXt chunk and its w/h/dpr size a canvas
  allocation on the viewer's machine, so all three are now range-checked
  (0 < w,h <= 16384, 0 < dpr <= 8) instead of just type-checked
- regression tests for the bounds, canvasPx, and the new blob fetchers
feat: 🎬 replay a student's answer drawing stroke-by-strokeAhmet Kaan Gümüş · 595aa7e
feat: 🎬 replay a student's answer drawing stroke-by-stroke

- teachers can play back a drawn exam answer in the grading answer
  sheet, watching how the student built it instead of only seeing the
  finished image
- no backend change: the drawing PNG already carries its editable stroke
  JSON in a tEXt chunk, so pngBytesToScene recovers the strokes
  client-side from the grader image that was already being served
- add a getStudentAnswerImage wrapper for
  GET /exams/{examId}/attempts/{userId}/answers/{questionId}/image;
  the route had no wrapper before, only a raw <img src>
- DrawingPlayback runs a requestAnimationFrame loop revealing points in
  drawn order at a constant POINTS_PER_SECOND, with play/pause/restart;
  pacing is order-only because the capture stores no timestamps
- pure sliceStrokes(strokes, revealCount) -> { full, partial } lives
  beside strokesBounds and is unit-tested
- the static image stays the default view; playback is a reversible
  toggle and falls back to the plain image when a PNG has no embedded
  strokes
- eraser strokes replay through a two-layer composite (ink on a
  transparent layer, then over white + paper) mirroring
  canvasToImageBlob, so a fully-revealed frame matches the saved PNG
- EN/TR i18n keys for the playback controls
feat: 🎨 infinite canvas, notebook paper, and floating draw controls - pan an unbounded pad (hand tool, middle-mouse drag, right-click erases) with world-coord strokes; export the drawn bounding box instead of the viewport so saved PNGs follow the content - view-only zoom (buttons + wheel, 0.25×–4×); exports stay at 1× - notebook backgrounds plain / ruled / squared grid, baked into the PNG under a transparent stroke layer so the eraser can't cut the lines; the choice rides in the embedded scene JSON (no backend change) - strokesBounds ignores eraser strokes so a far erase can't pad the export box; paintPaper draws the ruling (both unit-tested) - floating glass control islands: tools+size top-left, colours top-middle, paper top-right, undo/clear + zoom in the corners - pen/eraser size and paper style open as hover/tap/keyboard menus driven by an openMenu signal (closes on select, outside, Escape, leave) - transient tool highlight while middle/right button held; EN/TR i18nAhmet Kaan Gümüş · 0ae3da9
feat: 🎨 infinite canvas, notebook paper, and floating draw controls
- pan an unbounded pad (hand tool, middle-mouse drag, right-click
  erases) with world-coord strokes; export the drawn bounding box
  instead of the viewport so saved PNGs follow the content
- view-only zoom (buttons + wheel, 0.25×–4×); exports stay at 1×
- notebook backgrounds plain / ruled / squared grid, baked into the
  PNG under a transparent stroke layer so the eraser can't cut the
  lines; the choice rides in the embedded scene JSON (no backend change)
- strokesBounds ignores eraser strokes so a far erase can't pad the
  export box; paintPaper draws the ruling (both unit-tested)
- floating glass control islands: tools+size top-left, colours
  top-middle, paper top-right, undo/clear + zoom in the corners
- pen/eraser size and paper style open as hover/tap/keyboard menus
  driven by an openMenu signal (closes on select, outside, Escape, leave)
- transient tool highlight while middle/right button held; EN/TR i18n

2026-07-21

feat: 🎨 editable freehand drawings for notes and text examsAhmet Kaan Gümüş · 3758bf0
feat: 🎨 editable freehand drawings for notes and text exams

- add a canvas drawing pad (pen, eraser, 5 colors, 3 widths, undo, clear)
  that saves a PNG with its stroke JSON embedded in a tEXt chunk, so a
  saved drawing displays as a normal image and reopens for editing
- lib/png-meta embeds/extracts PNG text chunks (crc32); draw-stroke gains
  DrawScene + parseScene; drawing-file turns canvas+scene into a PNG File
  and parses stored bytes back to a scene (all pure, unit-tested)
- reopened drawings rescale to the current pad (aspect preserved); when
  editing you can clear a drawing and save the blank to erase it
- notes: draw new attachments and edit saved *.hzdraw.png ones in place
  (create-new-then-delete-old, no data loss); PNG/JPEG device export
- teacher exam questions: draw or re-edit the question illustration
- student text answers: draw the answer in the exam room, reopen to edit
  or remove; teacher sees it in the grading answer sheet
- answer-image api wrappers + question-image blob fetch, answer_image on
  AttemptAnswer/StudentAnswer, EN/TR i18n keys
- DrawCanvas is its own lazy chunk (~2.6KB gzip); main bundle unchanged