Drawing
Drawing-background,fill/stroke, the shapes, and the transform stackAccumulation-noClearkeeps the canvas across frames, so drawing piles up (long exposures, paint-on-canvas).Accumulatoris a layer that keeps the running mean, so a picture built from faint samples converges.Depth of field from light-LineSprayandBokehdraw lines as millions of scattered points through a lens. The points are added into a running mean until bokeh emerges.LineSprayandBokehare built on the.lightparticle style and thedevelopprint filter.HDR & tone mapping-toneMaprolls bright, out-of-range light off the screen instead of clipping it. The page covers the linear-float pipeline behind every frame, and the glow/bloom and sandpainting looks.Wide gamut & HDR output-colorOutputpresents through Display P3 and keeps highlights brighter than white.Color(displayP3:)makes a color outside sRGB. The page also covers HDR10 video export.Retained batches-makeBatchrecords heavy static drawing once, anddrawBatchreplays it each frame from the GPU at almost no cost. The transform in force at draw time places or stamps the whole recording.Layered effects-renderTarget/withTargetdraw into off-screen layers.filtered/postProcessrun GPU filters over them (blur, bloom, color grade, gradient map, edges, halftone, …), and the result composites back with blend modes.combinedcombines two layers (mask, displace, mix, depth-of-field defocus).generatemakes procedural pattern sources,feedbackmakes trails and tunnels, andcompose { }(withasidehelper layers) declares a stack of layers as one block.Looks-ColorLUTreads a.cubefile, the color table a grading tool exports, andFilter.lutapplies it to a layer or the whole frame, a cube by tetrahedral interpolation. A look can also be built in code and written out as a.cube.Text-drawTextdraws with bitmap, outline (.ttf/.otf), and stroke (single-line / plotter) fonts.textToShapesturns text into geometry.Images-loadImage,drawImage,tint, and pixel access. Load or author a raster image, draw it scaled or transformed, and recolor it.Sample photographs-SamplePhoto, twenty bundled photographs with their credits, for trying an image technique or a filter on a real picture.Glyph mosaic-drawGlyphMosaicrebuilds an image as a grid of text glyphs. Each cell's character is chosen by its measured ink in the active font.Halftone-drawHalftonerebuilds an image as the classic print dot screen. The dots are area-exact, sit on a rotated grid, and are real circles for the plotter path.Autostereogram-Image.autostereogramhides a depth map in a repeating pattern. When the repeats are paired, a surface nobody drew stands out of the page.Photo mosaic-Image.mosaic+averageColor+drawMosaicrebuild a picture out of many smaller pictures. Each cell takes the nearest picture by average color in linear light.Pixel sorting-Image.pixelSortedreorders runs of an image's own pixels along rows or columns, with each run bounded by brightness (the classic glitch melt).Seam carving-Image.seamCarvedandSeamMapresize a picture by removing the paths of pixels that hold the least detail. What matters then keeps its shape. Masks hold something still or take it out.Color- theColortype, the OKLab family and mixing,Ramps andPalettes (loaded from a file or extracted from an image), dithering an image down to a palette, and perceptualColormapsSpectral color-Spectrumis the reflectance curve behind a color. The page covers.paintmixing (pigments meeting in green, Kubelka-Munk), filtering light by multiplication, andColor(wavelength:)with blackbody glow. It also covers the spectral GPU effects (.thinFilm,.diffraction,.paintMix).Geometry- theVector2,Rectangle,Shape/Contour, andPathvalue types, plus theGridlayout helper, curved outlines, shape booleans, and offsettingSVG import-loadSVG/drawSVGread vector artwork intoShapes andContours (paths with curves and arcs, the basic shapes, groups and transforms, fills and strokes). The result is ready for booleans, offsets, hatching, and re-export.Fourier epicycles-Epicycles+drawEpicyclesrebuild any closed outline as a chain of spinning circles (the discrete Fourier transform as a drawing machine). A term count sets the result anywhere from a soft, blurred version of the outline to an exact trace.Envelopes & caustics-envelopefinds the curve that every line of a family touches.causticfinds the bright curve where reflected or bent light crowds together.Classic curves- the classic closed-form curves as geometry builders:phyllotaxis,lissajous,rose,superellipse,supershape,hypotrochoid/epitrochoid(the spirograph gears),guilloche(the rose engine's twisted, cam-shaped rings), the damped-pendulumHarmonograph,spirolateral(a walk of growing steps, repeated until it returns to its start), Chaikinsmoothed(iterations:)corner cutting, andsmoothed(neighbors:), the moving average that keeps every pointAnamorphosis-Anamorphosismakes a plate that reads only in a mirrored cylinder standing on the page, seen from one viewing spot. The page covers the wrap at true size and the map for points, contours, and shapes. It also covers what an eye can see of a cylinder, and the search that reads a plate back.Clothoid- the curve whose bend grows at a steady rate (the Euler or Cornu spiral). It gives you the easement that joins a straight run to a turn with no kink. It also gives the single curve that fits two points and two headings, a smooth path through waypoints, and polyline corners a vehicle could take.Shape morphing-ShapeMorphtweens oneShapeinto another. Every in-between is a real vector shape (contour pairing, corner-keeping correspondence, holes that grow in and out).ShapeisTweenable, so aTimelinecan sequence geometry.Voronoi & Delaunay- tessellate points into vector geometry: Voronoi cells (the "crystallization" look) and the dual Delaunay triangle mesh. Lloyd relaxation and weighted power diagrams are included.Spatial index-SpatialIndexanswers what is near a point without reading every point. It finds the nearest, the k nearest, everything within a radius, and everything inside a box. It runs over a uniform grid or a k-d tree.Fitting-RadialBasisfits a smooth field of numbers, vectors, or colors through values you know at a few scattered places. A field of vectors can also act as a warp.Fit.minimizewalks a few parameters downhill against a cost you write.Truchet tiling- each grid cell gets one tile, turned to a random orientation. Identical parts then line up into flowing loops (.arcs) or a maze (.diagonals).Hitomezashi stitching- one bit per grid line sets the phase of its dashes. The shifted lines then weave into staircases, loops, and a two-tone cloth.Ten print-tenPrintpicks one of two diagonals per cell by a coin flip. It then joins them into the long connected paths that made the picture famous.Kolam and sona- one line is launched between a field of dots and bounced off the edges until it closes. The finished pattern is gcd(rows, columns) loops, and walls steer the line.Celtic knotwork- the same line, given width and an alternating over-under rule. It is returned already broken where each cord passes under another.Crease patterns- the flat sheet that a folded or cut thing comes from. The page covers the Miura fold and its rigid folding in three dimensions, and rotating-squares kirigami. It also covers Kawasaki's and Maekawa's laws, which say whether a sheet can fold flat.Tiling & layout- the other ways to divide a canvas:HexGrid/TriangleGrid(the hex and triangle tilings, with hex distance, neighbors, and exact picking),subdivide(recursive panels, binary or quadtree),Maze(three carving algorithms, walls as clean line-work, solution and longest paths), andapollonianGasket(the kissing-circles foam)Aperiodic tilings- the tilings that never repeat:penroseTiling(kites and darts, rhombs, with the matching-rule arcs),wangTiling(edge-matching squares as one connected quilt),girihPattern(Islamic star patterns over any polygons, plus the five girih tiles), andspectreTiling(the einstein, straight or strictly chiral curved)Parquet deformations-parquetDeformationdraws a tiling whose tile changes shape as you read across it. The geometry lives on the lattice's shared edges, so a square becomes an interlocking key with nothing coming apart on the way.Hyperbolic tiling- regular tilings of the hyperbolic plane in the Poincaré disk.hyperbolicTilingtakes any {p,q} with (p-2)(q-2) > 4 and returns typed tiles with depth and a two-coloring parity. Aviewpointpans across the endless tiling.Strange attractors- chaotic systems drawn as points. Continuous 3D orbits (Lorenz, Rössler, Aizawa, …) are integrated with Runge-Kutta and orbited through the camera. The 2D iterated maps (Clifford, de Jong, Hénon, Gumowski-Mira, Ikeda, hopalong) are accumulated into density fields.AttractorFlowmoves a million GPU particles through one field at once.SDF combinators- compose signed-distance fields so shapes merge instead of stacking: smooth union/subtract/intersect and morph, round/onion, and domain mirror/tile. You reach the operators through theSDFvalue type +drawSDFand a scopedsmoothUnion { }block. They work in 2D and in a raymarched 3D form (SDF3D+drawSDF3D).Measured distance fields-Filter.distanceFieldmeasures a distance field back out of a drawn layer. The field says how far every pixel is from the nearest edge, and which way that edge lies.Filter.fieldMapreads the field back as contours, grown and shrunk shapes, and outlines. A shader can also read it as a Voronoi keyed to the picture.Layer styles- an outline, a drop or inner shadow, an outer or inner glow, or a lit bevel, each read from a layer's alpha and each one filter. The outline, the glows, and the bevel measure the layer's distance field, and the shadows blur it.The frequency domain- a picture read as a sum of waves instead of a grid of pixels.Filter.fourierwrites the spectrum on the GPU and.inverseFourierreads it back. That means filtering by scale is a shape drawn over the spectrum. It also means a field can be built from nothing but a description of its energy.Light in a flat sketch-Combine.lightcomputes the light that reaches every pixel of a flat scene. Draw the scene in one layer and the lights in another. One measurement (radiance cascades) then gives you shadows that soften with distance, falloff, light through a gap, and the color a lit wall reflects.Local averages- the average of the neighborhood around every pixel at a fixed cost, over a summed-area table.Filter.boxBluris a blur whose cost does not grow with its radius.Filter.adaptiveThresholdcuts a picture to two tones against each pixel's own surroundings, so uneven light stops mattering.
To write GPU code yourself (fragment shaders, the shader library, and compute kernels), see Shaders.