What lists does paint need?

Commands, for undo Paths and graphic styles, for paint Paths for object selection

Drawing an object goes from start to commit, although maybe more steps (add point, move anchor).

objects have a selected bool that changes their look (draw anchors)

startObject should render if it's top of the stack, but not otherwise.

Commit could manipulate the undo stack, replacing start with itself, keeping the start command and swapping it back on undo

Other commands can change objects (fill, style). Object stack is different to command stack. Commands create/alter/delete objects, and keep references of the old object and changed properties for undo.

Anchors are not objects, but instead are additions to the paths of selected objects.

Draw runs through object stack oldest first.


Paint todo/ideas

Infinite scroll - there's no reason to limit the drawing area since we're only putting pixels on the screen where the canvas viewport is. Add a global transform to the context with translate and scale (zoom), and a pan tool for click to drag.

Save - stash the action stack and drawing stack somewhere so the canvas restores at page load time

Export - Download current viewport as a png, download everything as svg

Style - Set things like line width, fill/stroke colour. Maybe a properties flyout on the right?

Object select - to edit object properties

If we store paths as svg paths then they'll serialize easier. Doesn't really matter, for rectangle and circle we can store coords and radius and convert them to paths later.

If we're going to do a property editor then we should spec up property types so we can generate the form mechanically. A shape is then defined by a list of property/type pairs, and maybe click handlers to manipulate anchors.


To remember your current position in the blog, this page must store some data in this browser.

Are you OK with that?