Important caddy configuration tip, make sure you quote values that contain spaces when setting headers, otherwise you get a silent fail.


Tip of the day - you can have HTML button and input widgets outside of a form, so long as you tag the widget with a form attribute with the right id.

(Been waiting a few days to post this, took a little time to get the fix posted).



Nope, posting was fine, but I'd setup the cache wrong. Fixed that now (I think!) so all the dynamic pages are no-store, static pages with a query string (from asp-append-version) get a long (256 days) expiry, and static pages without a query string (which are mostly JavaScript modules loaded through other modules) get a must-revaliate.

I'm not happy about the growing number of headers, it's not doing wonders for the payload:content ratio. On the other hand, at least HTTP/2.0 means that there isn't a fresh connection for each file.


Got up in the middle of last night and did some programming. Fun, except now I'm going be all tired at work.


I think that the thing I miss most from a command line when I'm using a GUI is the command history.

On the command line I can use the up/down arrows to find commands that I've entered before, edit them, and run them again. I can search through the history to see what options I used last time I ran the command, and I could (if I could be bothered) run analysis to find out what commands I use most often.

In the GUI I can't do any of that. Every time I want to do somthing I need to click through a whole pile of menus and dialogs, unless the application authors have included a shortcut for the specific thing I want to do.

I probably could install a mouse/keyboard recording tool, but that still wouldn't have the naked convinience of typing up arrow enter to repeat whatever it was I just did.



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.


Pants. Serializing the action stack is going to be tricky, since it's a pile of functions (and closures).

One fix is to write a language - based on lox or mal - and have the ui save instructions in those terms.

let r = rectangle(10, 10, 35, 60)
set r lineWidth 2
set r strokeStyle "green"
draw r

// useful for humans, not sure if would ever be generated
set globalStyle {lineWidth: 4, strokeStyle: "brown" }
for (let r = 10; r <= 50; r += 10)
  let c = circle(25, 25, r)
  draw c
done

I don't think we need a full on VM, but a parser to build an ast, and then a visitor to execute - jlox, but in JavaScript and maybe a little stripped down (but also with object literals).

Worth a try, I haven't been through jlox in a while.


(of course, if we don't need humans to be able to read/write it, mal is probably easier to code, maintain, and extend, but I've got a picture in my head of me messing about in a console and that feels easier in lox. Mental note: leave space for pluggable languages)


I'm feeling proper knackered this evening, even after a couple of hours sleep. Did a bunch of thinking today (work and paint), and the diet is starting to kick in.


So yes, lox was/is massive overkill for the paint language. Current design is command per line, with a command word followed by space seperated options. E.g:

draw rectangle 1 10 30 20 40

Currently it knows draw rectangle, draw circle, and erase last (where the erase command is to undo one of the other two). I'm going to need to add at least move, resize, rotate, maybe skew, and set style.

Commands generally take a shape id as a parameter.

We'll need to add more shapes.


Let's make a Drawable a bag of properties - an object - with a type property to inform how to use those properties to e.g. draw a path.

{
  "id": 7,
  "type": "Rectangle",
  "top": 15,
  "left": 10,
  "bottom": 25,
  "right": 20,
  "style": {...}
}

(Somewhere there's a map of names to property types to inform a property editor.)

drawableStack gets renamed to display, push to paint, pop to erase, draw to refresh (and bring the refresh once a frame logic into the type along with getBoundingBox).

Shape specific code (such as drawable to path and drawable to anchors) is held in the shape objects that also implement the tool interface.


Another night staying up late to put off tomorrow. Work has got crap again, I think. Also Trump/America is being stupid again. (And yes, I get that Trump isn't actually stupid in any real sense, but the options he's picking are not great for future humanity)

Paint is going ok, I guess. Need to do colour and fill next, along with adding lines, curves, polygons, and probably resizing.

I've sunk all this time into rectangle and circle, and I'm worried that lines and other shapes are going to be too different for the shared code to help.

I'm too tired for this. See you later blog.


Lego Wishlist for March 2025

Lego.com prices:

  • 60488 Red Sports Car £8.99
  • 60450 Yellow Construction Wheel Loader £12.99
  • 60451 Emergency Ambulance £17.99
  • 71829 Lloyd's Green Forest Dragon £17.99
  • 60461 Red Farm Tractor with Trailer & Sheep £17.99
  • 60453 Lifeguard Beach Rescue Truck £19.99
  • 60439 Space Science Lab £34.99

Alternative (single purchase):

  • 60434 Space Base and Rocket Launchpad £124.99
  • 71822 Source Dragon of Motion £129.99

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

Are you OK with that?