I don't know if I should post this here, so please do warn me if I shouldn't do any more updates about this.
I'm using Morphic for one of my projects, and it's in a "very alpha" state right now. One of the morphs I am really proud of is named CustomRenderMorph
, which uses SVG code and evaluations to render it, like so:
this.path = "M 0 0 H ~(w) V ~(h) H 0 Z" +
"M ~(w*1/4) ~(h*1/4) H ~(w*3/4) V ~(w*3/4) H ~(w/4) Z"
where ~(...)
takes in any code and replaces instances of w with its width and h with its height. The code makes that path this (if both dimensions are 100):
M 0 0 H 100 V 100 H 0 Z M 25 25 H 75 V 75 H 25 Z
The rendering after parsing is easy - just using Path2D quickly creates the path without the need to use so many conditions.
I can't get any screenshots of the project right now since I'm restricted from "file:///*" on my Chromebook, but I will show them as soon as possible.