Penplotting.js
Penplotting.js is a JavaScript framework for making generative art in SVG format for penplotters. This project is a personal project, and as such, it is a work-in-progress. New features and breaking changes are to be expected in future updates. Use at your own discretion, feel free to contribute and raise issues.
Features
- Shapes and geometry classes: 2D Vector, Line, Path, Circle, AABB
- Seedable PRNG implementations with useful methods
- Quadtree for optimised nearest-neighbour search
- Paper sizes
Installation
npm i @jakebeamish/penplotting
Usage
To start a new plot, run
npx new-plot
-
This will create new default index.html
, style.css
and plot.js
files.
Inside plot.js
, adjust the options for initializing the plot:
const plot = new Plot({
+
This is a shell script that will create new default index.html
, style.css
and plot.js
files in the current working directory. Inside plot.js
, adjust the options for initializing the plot:
const plot = new Plot({
units: "mm",
title: "My amazing plot",
size: Paper.A5,
strokeWidth: 0.05
});
-
Define a plot.generate() function, in which Vectors, Lines and other shapes can be created, manipulated, and added to the SVG document using plot.add(shapes)
.
// This is where the work is made
+
The image is defined in a plot.generate() function in which Vector, Line and Circle objects can be created and manipulated, and added to the SVG document using plot.add(shapes)
.
// This is where the work is made
plot.generate = () => {
// Create Lines from Vectors
const a = new Vector(10, 10);