cozyvec is a terminal program for creating plotter art (specifically via SVG files) in javascript with minimal setup.
The library has been designed for brevity, so the code for a specific plot can be tweeted under the hashtag #cozyvec (much like PICO-8's #tweetcart and processing's #つぶやきProcessing) by providing shortcut versions of most tokens that are 1-4 characters.
Browser version available at: https://brubsby.github.io/cozyvec
However, the standalone builds are a better user experience (menu items)
You can download builds for OSX, Windows and Linux, or if you wish to build it yourself, follow these steps:
git clone https://github.com/brubsby/cozyvec.git
cd cozyvec/desktop/
npm install
npm start
l2|lineTo(x,y)
draw line from last pointm2|moveTo(x,y)
move to pointclsp|closePath()
draw line to last move to pointppr|paper(name[,orientation])
change paper to size in libraryppr|paper(w,h[,name[,orientation]])
custom paper in mmpen(w)
pen width in mm, also starts new SVG group (to help with pen swapping)mbox|marginBox([a[,b[,c[,d]]]])
create bounding box with margins [x1,y1,x2,y2] default 40 mm, partial arguments follow css margin conventionslog(s)
log message s, gets overwritten by errors and other logserr|error(s)
error message s and quitW|WIDTH
canvas widthH|HEIGHT
canvas heightPI
πTAU|TWO_PI
2*πHPI|HALF_PI
π/2QPI|QUARTER_PI
π/4pow(a,b)
exponentiationsqrt(a)
square rootsqr|square(a)
square numbercub|cube(a)
cube numberabs(a)
absolute valueceil(a)
round up to nearest integerflr|floor(a)
round down to nearest integersgn|sign(a)
return the sign of a numbersin(a)
sinecos(a)
cosinetan(a)
tangentasin(a)
arcsineacos(a)
arccosineatan(a)
arctangentat2|atan2(y,x)
arctangent2min(...a)
minimummax(...a)
maximummid(a,b,c)
clamp b to [a,c]smid|smoothMid(a,b,c)
clamp b to [a,c] with smoothingdst|distance(x1,y1,x2,y2)
distance between pointsrnd|random()
random [0-1)rnd|random(a)
random [0-a)rnd|random(a,b)
random [a-b)srnd|seedRandom()
seed rng with 0srnd|seedRandom(s)
seed rng with snse|noise(pos)
simplex noise (pos can be a number or 1-4 numbers in a list)nse|noise(pos,freq,amp)
simplex noisense|noise(pos,freq,amp,octaves,lacunarity,gain)
fractal simplex noise
CmdOrCtrl+G
documentationCmdOrCtrl+R
run codeCmdOrCtrl+E
export SVGCmdOrCtrl+I
export PNGCmdOrCtrl+P
flip paper orientationCmdOrCtrl+N
new fileCmdOrCtrl+O
open .js fileCmdOrCtrl+S
save .js fileCmdOrCtrl+Tab
dev console
Paper sizes are defined here, create an issue or PR if you'd like me to add another standardized paper size to select from.
You can also call paper|ppr(width_mm, height_mm[, name[, is_portrait]])
at the beginning of your script to define a custom size for your plot.
Please create an issue if you have questions about behavior, find a bug, or want to make a feature/paper size request! I will also accept PR's, but might edit them first!