Pen plotting, experiment zero
In some of my spare time I play around with making art with machines. It's mostly been a failure thus far; a Brachiograph which I couldn't stop vibrating violently (servos can be finicky) and an attempt to attach a pen to my 3D printer which almost worked but would require some too serious hardware mods to get it solid and stable.
So I bought a very basic -- and cheap! -- pen plotter from China. Had to assemble it, which took a very pleasant afternoon, and am quite surprised by how well it works.
That link might die one day. It's the only pen plotter they offer, the rest of their stuff is CNC routers.
It comes with a copy of GRBL installed and so to drive it one only needs to send it GCODE via a USB TTY.
Since I'm a coder I prefer to write the software stack myself, rather than just grabbing SVGs and using off the shelf GCODE converters, as the supplied documentation would suggest. I'd rather procedurally generate some images and build the GCODE myself.
And so that's what I've started doing, writing most of it in Janet which is my toy-building language of choice. I've realised I'll need to render TTF fonts if I want any text anywhere so I've experimented initially with converting glyphs to GCODE and it's kinda working.
Getting the curves out of a TTF is a bit painful, but thankfully the ttf-parser Rust crate works well enough. There doesn't seem to be a Janet library for this yet, and I started to write one but then valued my time too much and just used the crate. I have a Rust project which spits out all the lines and bezier curves required to write text. Using single line fonts means they don't require infilling which is better for plotting.
So by combining the curves and converting to GCODE lines I was able to plot something today:
Yeah, almost! That's supposed to be the word 'golly' written in a stylised single line font.
There are a couple of surprises here -- the plotter seems to be in a landscape orientation where I thought it'd be portrait. As in, I expected the text to be vertical in this image. This means the origin is at the bottom left and my X and Y axes need to be swapped, and that Y coordinates need to be inverted, a la:
See! Golly.
Also, my conversion from general line drawing operations to GCODE seem to be a bit wonky as it's drawing lines, pen down, when it should just be moving, pen up. Here's the same just rendered without smoothing to an image:
But this really pleases me, it's mostly a success.