Images & photos · Browser Image & Drawing Editor
How freehand drawing works in a browser: pointer events to pixels
· How it works
image-editing canvas browser-processing
A freehand stroke drawn with a mouse, finger or stylus is a stream of position samples that the browser turns into a smooth line. This post follows one stroke from input event to painted pixels.
The wobbly circle that comes out smooth — what you draw versus what the editor records
A freehand mark starts as sampled positions, not a continuous ribbon. Begin with the wobbly circle that comes out smooth: what you draw is a gesture, while the editor records sampled positions. For this stroke pipeline, source code confirms Unified pointerdown, pointermove, pointerup and pointercancel handlers capture one active pointer and map CSS coordinates back through zoom. The brush interpolates between sparse samples at spacing based on one quarter of its width, but it ignores pressure values.
Circle three answers with mouse, finger or stylus and watch one gesture become one history entry after pointer release. Round caps and joins produce continuous freehand strokes; a tap still paints a circular mark. Pressure artistry and vector handwriting remain outside this path even when the hardware reports richer input.
Pointer events: mouse, touch and pen in one API — how the browser reports position, pressure where available, and the sampling rate you actually get
A freehand mark starts as sampled positions, not a continuous ribbon. Pointer events put mouse, touch, and pen input behind one API, reporting position and sometimes pressure at the sampling rate the device provides. For this stroke pipeline, source code confirms The brush interpolates between sparse samples at spacing based on one quarter of its width, but it ignores pressure values. Round caps and joins produce continuous freehand strokes; a tap still paints a circular mark.
Circle three answers with mouse, finger or stylus and watch one gesture become one history entry after pointer release. Device pixel ratio, capped at three, sharpens only the on-screen backing store; document pixels remain at image resolution. Pressure artistry and vector handwriting remain outside this path even when the hardware reports richer input.
Pointer events unify mouse, touch and pen positions here, but pressure is not consumed
A freehand mark starts as sampled positions, not a continuous ribbon. Turning points into a path means connecting samples with segments or curves, and smoothing always trades some fidelity for legibility. For this stroke pipeline, source code confirms Round caps and joins produce continuous freehand strokes; a tap still paints a circular mark. Device pixel ratio, capped at three, sharpens only the on-screen backing store; document pixels remain at image resolution.
Circle three answers with mouse, finger or stylus and watch one gesture become one history entry after pointer release. Unified pointerdown, pointermove, pointerup and pointercancel handlers capture one active pointer and map CSS coordinates back through zoom. Pressure artistry and vector handwriting remain outside this path even when the hardware reports richer input.
Stroking a path on the canvas — line width, caps, joins and anti-aliasing, and why stroke edges are never pure single-colour pixels
A freehand mark starts as sampled positions, not a continuous ribbon. Stroking the path adds width, caps, joins, and anti-aliasing, which is why an edge contains blended pixels rather than one perfectly pure colour. For this stroke pipeline, source code confirms Device pixel ratio, capped at three, sharpens only the on-screen backing store; document pixels remain at image resolution. Unified pointerdown, pointermove, pointerup and pointercancel handlers capture one active pointer and map CSS coordinates back through zoom.
Circle three answers with mouse, finger or stylus and watch one gesture become one history entry after pointer release. The brush interpolates between sparse samples at spacing based on one quarter of its width, but it ignores pressure values. Pressure artistry and vector handwriting remain outside this path even when the hardware reports richer input.
Device pixel ratio — why a drawing canvas needs more backing pixels than screen points on a high-density display, and what happens when it does not
A freehand mark starts as sampled positions, not a continuous ribbon. Device pixel ratio explains why a drawing canvas needs more backing pixels than screen points on a high-density display, and why a low-resolution backing store looks soft. For this stroke pipeline, source code confirms Unified pointerdown, pointermove, pointerup and pointercancel handlers capture one active pointer and map CSS coordinates back through zoom. The brush interpolates between sparse samples at spacing based on one quarter of its width, but it ignores pressure values.
Circle three answers with mouse, finger or stylus and watch one gesture become one history entry after pointer release. Round caps and joins produce continuous freehand strokes; a tap still paints a circular mark. Pressure artistry and vector handwriting remain outside this path even when the hardware reports richer input.
Worked example: circling three answers on a photographed worksheet — how each stroke is captured, drawn and exported
A freehand mark starts as sampled positions, not a continuous ribbon. Circle three answers on a photographed worksheet and the path becomes a sequence of samples, interpolated brush marks, and finally exported pixels. For this stroke pipeline, source code confirms The brush interpolates between sparse samples at spacing based on one quarter of its width, but it ignores pressure values. Round caps and joins produce continuous freehand strokes; a tap still paints a circular mark.
Circle three answers with mouse, finger or stylus and watch one gesture become one history entry after pointer release. Device pixel ratio, capped at three, sharpens only the on-screen backing store; document pixels remain at image resolution. Pressure artistry and vector handwriting remain outside this path even when the hardware reports richer input.
What this does not cover — pressure-sensitive brushes, vector export and handwriting recognition
A freehand mark starts as sampled positions, not a continuous ribbon. The boundary includes pressure-sensitive brushes, vector export, and handwriting recognition. For this stroke pipeline, source code confirms Round caps and joins produce continuous freehand strokes; a tap still paints a circular mark. Device pixel ratio, capped at three, sharpens only the on-screen backing store; document pixels remain at image resolution.
Circle three answers with mouse, finger or stylus and watch one gesture become one history entry after pointer release. Unified pointerdown, pointermove, pointerup and pointercancel handlers capture one active pointer and map CSS coordinates back through zoom. Pressure artistry and vector handwriting remain outside this path even when the hardware reports richer input.
Takeaway: your device does the drawing — how the Browser Image & Drawing Editor captures strokes locally and never sends them anywhere
A freehand mark starts as sampled positions, not a continuous ribbon. The takeaway is local and concrete: your device supplies the pointer input, while the Browser Image & Drawing Editor captures and renders the stroke in the browser. For this stroke pipeline, source code confirms Device pixel ratio, capped at three, sharpens only the on-screen backing store; document pixels remain at image resolution. Unified pointerdown, pointermove, pointerup and pointercancel handlers capture one active pointer and map CSS coordinates back through zoom.
Circle three answers with mouse, finger or stylus and watch one gesture become one history entry after pointer release. The brush interpolates between sparse samples at spacing based on one quarter of its width, but it ignores pressure values. Pressure artistry and vector handwriting remain outside this path even when the hardware reports richer input.