It is inspired by a project that I saw on HN a while ago. I wasn't able to find it again, so I made my own version. I swear, only after finishing Pulsar I managed to find https://tixy.land/ again.
As a bonus, I wanted to run these animations on my DIY LED frame. Check out the video:
https://github.com/Stanko/pulsar/tree/dev#led-retro-frame
Here are a few technical details:
It is built in TypeScript and open source. User code is executed in a web worker to minimize the risk of malicious use (tbh I'm proud of the solution, and I find it quite nifty). Initially, I used to render everything as an SVG, but in order to create GIFs for the LED frame, I switched to canvas. Not to mention that SVG gave me a few headaches which I'll cover in a blog post (if I ever write one). The syntax highlighter is a trick I found on Stack Overflow. The textarea is transparent, and as you type in it, I take the code, highlight and copy it into a div which overlays the textarea.
It was really fun to build and I hope you had some fun playing with it.
I made it around last new year's eve, so here is a simple animation of a Christmas tree:
https://muffinman.io/pulsar/?grid=classic&animate=both&code=...
When I made my (more esoteric) thing https://c50.fingswotidun.com/ I took a long time to consider the features before I froze them to allow people to submit their own code. I think you might have more scope for expandability given you already have modes of operation radio buttons for shapes.
As for colors, I wanted more than one color (or two with negative), so I went with a simple hardcoded palette. I wanted to keep the scope in control, but I might try inverting colors when I decide to add more features. Thanks!
Can you expand on this a bit? I have something that I would love to enable user plugins by using JS eval or something but I am too afraid of someone doing evil stuff to bring the feature in-place.
You still have to make sure the API you expose to the user plugins aren't exploitable.
Same here, I’m a visual thinker and stuff like this really helps me grasp certain concepts.
Sorry for going OT, I noticed from the demo video that you got an axidraw - what are doing with it, if a may ask?
Got one myself and been playing around with it. The latest idea has been to use a hand engraver as pen!
As for the engraver, keep in mind that AxiDraw is only using the weight of the pen (engraver) to press on a surface, so you might need to add some weight for it to work. But please be careful not to damage the servo motor or the plotter. Tyler Hobbs did something similar, he was using a drill bit to remove fresh paint from mirrors: https://www.tylerxhobbs.com/works/mirror-removal
People are doing all kinds of wacky stuff with plotters. I want to try using a brush along with markers. I think the combination of the two can be used to create interesting effects.
It is really hard to make a correct sandbox in JS in general, without something like the Realms proposal [1]. Until that point you would have to be conservative to be safe.
At least the exploit doesn't work until you start changing the code.
EDIT: Patched it by checking for backslashes and the word "constructor".
After some search, it seems that using a null-origin <iframe> seems the best approach you can use for now. Figma successfully used it in the production [2] and the only reason they switched was that no state can be ever shared, which is not a big problem for your case. They also tried the Realms shim for the aforementioned proposal but it seems to have a known vulnerability. And I guess you don't want to ship a WebAssembly JS interpreter ;-)
Anyway, sorry to bother you; it is hard to balance the fun and robustness at once. As a parting gift, the following is a genuine code that renders a 7-segment counter: https://muffinman.io/pulsar/?grid=classic&animate=opacity&co...
[2] https://www.figma.com/blog/how-we-built-the-figma-plugin-sys...
https://www.redblobgames.com/grids/hexagons-v2/pre-index.htm...
Can someone explain what's i hwre? I get x, y, and t as 2D space and time respectively, but may be not.
Reminds me a little bit of CSS Doodle: https://css-doodle.com/
For expressions, hopefully the TC9 Shadow Realms proposal will make this easier in the future.