Algorithms

drawingbots.com · 2026-08-22 · by Long Nguyen ·generic
A visual catalog of 120 algorithms used in pen-plotter and generative art — from path optimization to organic growth — with live interactive p5.js demos.

Algorithms

Algorithms

A visual catalog of the algorithms behind pen-plotter art — from path optimization and vectorization to generative geometry and organic growth. Cards marked Live demo open an interactive p5.js sketch showing the algorithm in action.

Share this page:

[](https://twitter.com/intent/tweet?url=https%3A%2F%2Fdrawingbots.com%2Falgorithms%2F&text=A+visual+catalog+of+pen+plotter+algorithms)[](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fdrawingbots.com%2Falgorithms%2F)

122 of 122 have live demos — more coming soon.

Live demo

2-opt local search

Repeatedly reverses sections of a route whenever the swap shortens its total length.

Live demo

Adaptive stippling

Places marks at variable spacing or size according to local image tone, detail, or an error measure.

Live demo

Affine transformation

Maps coordinates with combinations of translation, rotation, scaling, and shear while preserving straight lines and parallelism.

Live demo

Arc interpolation

Evaluates points along a circular or elliptical arc from its geometric parameters.

Live demo

Arc-length resampling

Redistributes points along a curve so consecutive samples are separated by approximately equal physical distances.

Live demo

Arc-to-Bézier conversion

Approximates circular or elliptical arcs with one or more cubic Bézier curve segments.

Live demo

Archimedean spiral

Generates a spiral whose radius increases linearly with angle, producing nearly constant spacing between turns.

Live demo

Attractor-field integration

Moves particles or curve samples through a vector field formed by attracting and repelling points or shapes.

Live demo

B-spline curves

Constructs smooth piecewise-polynomial curves controlled by points, knots, and polynomial degree.

Live demo

Bayer ordered dithering

Compares image values against a repeating threshold matrix to create a regular distribution of binary marks.

Live demo

Bentley–Ottmann sweep-line algorithm

Finds intersections among line segments by sweeping an ordered event line across the geometry.

Live demo

Bézier curves

Defines smooth parametric curves from endpoints and control points using Bernstein polynomials.

Live demo

Blue-noise sampling

Distributes samples with few low-frequency clumps while avoiding the rigid appearance of a grid.

Live demo

Bresenham line algorithm

Steps through a discrete grid to approximate a straight line using inexpensive incremental error calculations.

Live demo

Catmull–Rom splines

Interpolates a smooth curve through a sequence of control points using neighboring points to determine tangents.

Live demo

Cellular automata

Updates cells on a grid from local neighborhood rules to produce evolving spatial patterns.

Live demo

Centerline tracing

Extracts a single path along the middle of strokes or elongated regions in a raster image.

Live demo

Chaikin corner cutting

Smooths a polyline by repeatedly replacing each corner with two points placed along its adjacent edges.

Live demo

Circle packing

Places non-overlapping circles inside a boundary while satisfying size, spacing, or density constraints.

Live demo

CMYK color separation

Decomposes an image into cyan, magenta, yellow, and black coverage channels.

Live demo

Color quantization

Reduces a large set of image colors to a smaller representative palette while minimizing visual error.

Live demo

Concave hull

Builds a boundary around a point set that can bend inward and follow the set more closely than a convex hull.

Live demo

Concentric infill

Fills a region with successively inset or outset copies of its boundary.

Live demo

Contour extraction

Finds curves that follow boundaries or equal-valued levels in raster, scalar-field, or elevation data.

Live demo

Convex hull

Computes the smallest convex polygon containing a set of points.

Live demo

Cross-hatching

Overlays two or more families of hatch lines at different angles to build tone or texture.

Live demo

Curl noise

Derives a divergence-free vector field from the curl of a noise field, producing swirling motion without obvious sinks or sources.

Live demo

Curve flattening

Approximates arcs and parametric curves with polylines while keeping deviation or segment length below a tolerance.

Live demo

De Casteljau's algorithm

Evaluates or subdivides a Bézier curve through repeated linear interpolation of its control points.

Live demo

Delaunay triangulation

Connects points into triangles so no input point lies inside any triangle's circumcircle.

Live demo

Differential growth

Iteratively moves and subdivides a chain under attraction, repulsion, and smoothing forces so it grows without collapsing onto itself.

Live demo

Distance transform

Assigns each raster cell its distance to the nearest foreground, background, or boundary cell.

Live demo

Douglas–Peucker simplification

Recursively removes polyline vertices whose removal stays within a specified perpendicular-error tolerance.

Live demo

Dubins path planning

Finds a short path between oriented points using straight segments and fixed-radius turns.

Live demo

Edge detection

Locates strong changes in image intensity or color that are likely to correspond to visual boundaries.

Live demo

Edge tangent flow

Builds a smooth orientation field that follows nearby image edges while reducing local directional noise.

Live demo

Error-diffusion dithering

Quantizes each image sample and distributes its quantization error to neighboring samples that have not yet been processed.

Live demo

Fast marching method

Propagates a front through a weighted domain by solving an Eikonal equation in order of increasing arrival time.

Live demo

Fermat spiral fill

Fills a region with a Fermat (parabolic) spiral whose in-and-out arms interleave, so a single continuous path enters and exits at the boundary with near-uniform spacing.

Live demo

Flood fill

Visits connected cells or regions starting from a seed while respecting a boundary or value condition.

Live demo

Floyd–Steinberg dithering

An error-diffusion method that passes quantization error to four nearby pixels using fixed weights.

Live demo

Fourier series drawing

Approximates a periodic shape as a sum of rotating sinusoidal components or epicycles.

Live demo

Fractal noise

Combines multiple scaled octaves of coherent noise to produce detail at several spatial frequencies.

Live demo

G-code toolpath generation

Translates drawing geometry into ordered machine moves, coordinate commands, feed settings, and pen-control actions.

Live demo

Genetic path optimization

Evolves candidate route orderings through selection, crossover, and mutation according to a travel-cost score.

Live demo

Greedy nearest-neighbor path ordering

Repeatedly selects the unvisited path endpoint nearest to the current pen position, optionally reversing paths.

Live demo

Halftoning

Represents continuous tone with discrete marks whose size, spacing, shape, or density varies.

Live demo

Harmonograph curves

Combines damped sinusoidal oscillations to model the paths produced by a mechanical harmonograph.

Live demo

Hatching

Fills a region with parallel or locally oriented lines clipped to the region boundary.

Live demo

Hexagonal grid generation

Tiles the plane with regularly spaced hexagonal cells using axial, cube, or offset coordinate systems.

Live demo

Hidden-line removal

Determines which portions of projected 3D edges are occluded by surfaces and removes or splits those portions.

Live demo

Hilbert curve

Recursively constructs a continuous space-filling curve that visits every cell of a square grid.

Live demo

Homography

Maps points between two planes with a projective transformation defined by a 3-by-3 matrix.

Live demo

Image-guided flow fields

Converts image gradients, edges, brightness, or structure tensors into a vector field that guides curves.

Live demo

Inverse kinematics

Computes actuator positions or joint angles needed to place a tool at a requested Cartesian coordinate.

Live demo

Island detection

Identifies disconnected components, enclosed loops, or path groups that are isolated from the rest of the geometry.

Live demo

Isoline extraction

Traces curves through positions where a sampled scalar field equals selected values.

Live demo

k-d tree nearest-neighbor search

Partitions points recursively by coordinate axis to accelerate spatial range and nearest-neighbor queries.

Live demo

K-means color clustering

Alternates between assigning samples to the nearest color center and updating each center to its cluster mean.

Live demo

L-systems

Repeatedly rewrites symbols with grammar rules and interprets the result as drawing commands.

Live demo

Lawnmower infill

Covers a region with parallel back-and-forth passes connected in alternating directions.

Live demo

Liang–Barsky line clipping

Clips a line segment against an axis-aligned rectangle by updating the valid interval of its parametric equation.

Live demo

Line joining and merging

Connects nearby compatible segment endpoints, reversing direction where necessary, to form longer continuous polylines.

Live demo

Line-segment intersection

Tests whether two finite segments cross and, when they do, computes their intersection point and parameters.

Live demo

Linear interpolation

Computes intermediate values along a straight interval between two known values or points.

Live demo

Lissajous curves

Plots two perpendicular sinusoidal motions with independently chosen frequencies, phases, and amplitudes.

Live demo

Low-pass path smoothing

Suppresses high-frequency changes in sampled coordinates or motion commands while retaining slower shape changes.

Live demo

Marching squares

Extracts isoline segments from a two-dimensional sampled field by classifying the corners of each grid cell.

Live demo

Martinez polygon clipping

Uses a sweep-line process to compute boolean operations on simple or self-intersecting polygons.

Live demo

Maze generation

Builds a connected network of passages with methods such as depth-first backtracking, randomized Prim, or Kruskal growth.

Live demo

Medial axis transform

Finds the centers and radii of maximal disks contained inside a shape, forming a skeletal representation.

Live demo

Minimum spanning tree

Connects all vertices of a weighted graph with minimum total edge weight and no cycles.

Live demo

Morphological erosion

Shrinks foreground regions by removing pixels or cells that do not contain a chosen structuring element.

Live demo

Motion planning

Chooses a feasible sequence of movements that respects geometry, machine limits, obstacles, and tool state.

Live demo

NURBS curves

Represents smooth rational spline curves with weighted control points, a knot vector, and polynomial basis functions.

Live demo

OpenSimplex noise

Generates coherent gradient noise on a simplex-like lattice with fewer directional artifacts than classic grid noise.

Live demo

Orthographic projection

Projects 3D points onto a plane along parallel rays without perspective size reduction.

Live demo

Penrose tiling

Covers the plane aperiodically with a small set of tiles constrained by matching or substitution rules.

Live demo

Perlin noise

Interpolates pseudo-random gradients on a lattice to create smooth, spatially coherent noise.

Live demo

Perspective projection

Projects 3D points onto a plane so apparent size decreases with distance from the viewer.

Live demo

Physarum simulation

Models agents that deposit and follow a diffusing trail field, producing adaptive transport-like networks.

Live demo

Point-in-polygon test

Determines whether a point lies inside, outside, or on the boundary of a polygon using crossing or winding rules.

Live demo

Poisson-disc sampling

Generates samples with a guaranteed minimum separation while retaining an irregular, natural distribution.

Live demo

Polygon Boolean operations

Computes union, intersection, difference, or exclusive-or between polygonal regions.

Live demo

Polygon offsetting

Constructs parallel boundaries at a specified distance from polygon edges while resolving joins and self-intersections.

Live demo

Polygon packing

Places polygonal shapes within a boundary while avoiding overlap and optimizing space, density, or another objective.

Live demo

Potrace

Transforms a thresholded bitmap into smooth vector outlines through path decomposition, polygon fitting, and curve optimization.

Live demo

Quadtree spatial indexing

Recursively divides a two-dimensional region into four cells so spatial queries can ignore empty or distant areas.

Live demo

Random walk

Builds a path through successive random or probability-weighted steps from the current position.

Live demo

Raster-to-vector tracing

Converts raster regions, edges, or strokes into geometric paths such as polylines and Bézier curves.

Live demo

Ray casting

Projects rays from a viewpoint or query point and finds their first intersections with scene geometry.

Live demo

Ray hatching

Casts rays or probes across projected surfaces and converts visible intervals into hatch strokes.

Live demo

Ray marching

Advances a ray through a field in steps, often using signed distance values to choose safe step lengths.

Live demo

Ray tracing

Traces rays through a scene to evaluate intersections, visibility, lighting, and reflections.

Live demo

Reaction–diffusion

Simulates interacting substances that spread and react locally, producing spots, stripes, and labyrinthine structures.

Live demo

Rectangular packing

Arranges rectangles within a bounded area to minimize unused space or satisfy layout constraints.

Live demo

Scanbeam processing

Sweeps through ordered vertex events while maintaining active edges for the current horizontal or vertical band.

Live demo

Scanline polygon filling

Intersects regularly spaced scanlines with polygon edges and fills the alternating interior intervals according to a fill rule.

Live demo

Signed distance fields

Represent a shape with a scalar value giving distance to its boundary and a sign indicating inside or outside.

Live demo

Simplex noise

Generates coherent gradient noise on simplex cells, scaling efficiently to multiple dimensions.

Live demo

Single-line font rendering

Represents glyphs as centerline strokes rather than closed filled outlines, as in Hershey-style fonts.

Live demo

Skeletonization

Iteratively thins a binary shape to a one-pixel-wide topology-preserving skeleton.

Live demo

Space-colonization growth

Grows a branching network toward nearby attraction points while removing points reached by existing branches.

Live demo

Spiral infill

Covers a region with a continuous inward or outward spiral derived from repeated offsets or a spiral field.

Live demo

Spirograph curves

Generates hypotrochoid or epitrochoid paths from a circle rolling inside or outside another circle.

Live demo

Stippling

Represents tone or form with discrete dots whose density, size, or distribution varies spatially.

Live demo

Streamline integration

Numerically traces curves that remain tangent to a vector field from selected seed points.

Live demo

String-art line selection

Iteratively chooses chords between fixed anchor points to reduce the difference from a target image.

Live demo

Superformula

Generalizes the superellipse to a single polar equation whose few parameters sweep from circles and polygons to petals, stars, and organic blobs.

Live demo

Thresholding

Classifies image samples by comparing intensity, color, or another measure with one or more thresholds.

Live demo

Tone- and feature-aware circular scribbling

Builds a continuous path from circular scribbles whose placement, loop size, and motion respond to image tone and features.

Live demo

Traveling Salesman Problem optimization

Searches for a short route that visits every required point or path once before returning or stopping.

Live demo

Truchet tiling

Builds patterns by rotating or selecting tiles that contain compatible arcs or line fragments.

Live demo

Turtle graphics

Generates paths by moving an oriented cursor with relative commands such as forward, turn, and branch.

Live demo

Vatti polygon clipping

Computes boolean operations on general polygons using scanbeams, local minima, and an active edge structure.

Live demo

Voronoi diagram

Partitions a plane into cells containing the locations closest to each generating site.

Live demo

Wave Function Collapse

Assigns compatible tiles or states to cells by repeatedly propagating local constraints and resolving uncertainty.

Live demo

Weave path ordering

Splits and orders intersecting paths so alternating segments appear to pass over and under one another.

Live demo

Weighted Voronoi stippling

Iteratively relocates Voronoi sites toward density-weighted cell centroids derived from a target image.

Live demo

Worley noise

Measures distance to nearby random feature points to produce cellular bands, ridges, and regions.

Live demo

Z-buffer visibility

Stores the nearest depth reached at each sampled image location and rejects geometry farther from the viewer.

Live demo

Zingl–Bresenham curve algorithm

Incrementally approximates Bézier curves and conic sections on a discrete grid using error terms.

drawingbots.com · 20 links

Comments (0)

No comments yet