⚠ Early release: v0.3.2.sophistry is not ready for production use. Until 1.0, any minor release may break the API; expect missing features and bugs too.Stability and versioning
Gallery
Every example here is a real, typechecked module from docs/src/examples/, written with the Solid binding (@sophistry/solidjs) over the framework-free core, or with the core alone.
What you see running is exactly the source beneath it. Examples on a page are ordered from
the simplest to the most involved, so read from the top. The larger categories
(animations, plotting and interaction) are split into pages by topic.
New to sophistry? Do the first scene tutorial, then browse Basic concepts. Each category page links to the guides that explain what you are looking at. Looking for something specific?
- Moving things: Animations and Interaction
- Graphs and data: Plotting and charts, from function graphs to chart transitions
- Formulas and linear algebra: Math and LaTeX
- Depth: 3D
- Whole projects: Advanced projects and the recipes
- No framework at all: Without a framework, the same ideas with
createScene
Basic concepts
Stages, shapes and your first tweens.
- Shapes galleryThe basic shapes, each styled with stroke, fill and opacity; colors come from the active theme.
- First scene: shapes and labelsStep one of the first-scene tutorial: a ring, a radius, an angle arc and a dot, with a label placed next to the dot by its measured bounds.
- Unit circleDraw a circle with draw(), then send a dot around it with moveTo().
- Group transformsA Group moves, rotates and scales everything inside it at once; here two scaled copies of a small figure turn together.
- Labels and positioningLine three shapes up with arrange(), then hang a caption beneath one with nextTo(), using each shape's measured bounds.
- A diagram laid out by placementThree boxes in a row, captions under each, arrows between them, a frame around the lot and a title pinned to the corner. No coordinates are typed by hand.
- Coordinate planeAxes map data coordinates to scene units: plot a function inside them, and use coordsToPoint() to place a point at (2, 4).
- Vector with componentsA Vector grows out of the origin of a NumberPlane, then dashed lines drop to the axes to show its x and y components.
- Dimension annotationA double-headed arrow and a live readout measure the width of a rectangle as it stretches and shrinks.
- Gradients and strokesA lit sphere, a sheen that sweeps across a card, a dashed line and a stroke whose color follows the curve.
- Theme colorsEvery default color comes from the active theme; these swatches read its palette tokens and follow the site's light and dark mode.
- Palette switcherTap a swatch to hand the whole scene a different palette. Shapes, labels and the ground all restyle because they only read theme tokens.
- RGB versus OKLCH blendsThe same blue-to-yellow blend in two color spaces. RGB sags through a muddy gray in the middle; OKLCH keeps its lightness and sweeps the hue.
- Boxes and layoutA card laid out with flexbox in design pixels: a heading, wrapped rich text, a row of tags and a circle in scene units, written on in order.
- BracesBraces measure a rectangle's sides and a triangle's hypotenuse, each with a label at its tip, drawn in one after another.
- Clipping a groupA <Group clip> paints its children only inside a region. Here the clip's right edge follows a track, wiping a coloured copy over a grey one.
- Grid layoutA box with display: grid: a title spanning every column, three equal columns of cards, and a footer row, with tracks in design pixels and fr.
- Formulas inside sentencesAny scene node can sit in a line of text like a wide glyph: a typeset formula mid-sentence and a coloured dot as a legend key, wrapping with the words around them.
- Layout transitionslayoutTo changes boxes' styles and children and moves everything to its new place: tiles reorder, then the row turns into a column, each tile gliding there.
- Scene units and the frameA unit grid with y pointing up, the origin at the center, and the visible frame read back from useScene().frame: units={8} at 16:9 spans x from -4 to 4 and y from -2.25 to 2.25.
- Text blocks, lists and titlesA title with its rule, rich text wrapped to a measure and a bulleted list, each written in reading order or an item at a time.
Animations
Sequencing, morphs and emphasis effects.
Tweens and effects
- Fade and growThree shapes enter in different ways: fading in, growing from their center, and spinning in from nothing.
- First scene: animate with a playerStep two of the first-scene tutorial: tracks drive the ring, the radius and the angle, and usePlayer runs the script on the stage clock.
- Comparing easingsFive dots cover the same distance in the same time, each with a different easing curve, so you can see how the curves feel.
- Manim's rate functionsSix dots make the same trip with Manim's rate functions: a running start, slow into the end, two smooth halves, lingering, exponential decay, and a smooth move squished into the second half.
- Write and unwriteThree outlines are drawn one after another with write, held for a moment, then erased in reverse order with unwrite.
- Emphasis effectsFour ways to draw the eye in turn: indicate swells a dot, wiggle shakes a square, flash sends out a ring, circumscribe boxes a label.
- Indication effectsFour more ways to point at something: a spotlight closes in, a dot blinks, a flash runs along a curve, and a wave ripples through a bar.
- Animated boundaryA stroke keeps running round a box, a new colour each cycle, while the last one thins away underneath: ambient emphasis that needs no animation.
- Morph shapesA circle morphs into a square, a star, and back again.
- Matching shapesA square and a circle become a larger circle and a long bar. TransformMatchingShapes pairs each shape with the one it most resembles, so nothing crosses over.
- Point moving on a shapeA dot travels around a circle at constant speed by following the circle's outline with moveAlong.
- Arcs, trails and changing speedTwo dots swap places along half-circle arcs instead of straight lines, slowing right down as they pass each other, and each leaves a fading trail.
- Moving angleOne ray swings around a fixed one while an Angle arc and a Text readout follow it, all driven by a single tracked number.
- Animated numbersAn Integer, a DecimalNumber and a Variable count up and back down with valueTo; digits keep fixed-width columns so nothing jitters.
Sequencing and timelines
- Sequencing animationsThe same three lifts played one after another, all together, and staggered, using sequence, parallel and lagged.
- A scrubbable timelineOne script, three steps. player.timeline() runs it and exposes seek, time and playing, so a button and a range slider can pause, resume and scrub it in either direction.
- First scene: scrub it with a timelineStep four of the first-scene tutorial: the whole script becomes a timeline you can seek with a slider, backwards as well as forwards.
- Scrubbable explainer with chaptersA four-step explainer on one timeline. Chapter buttons sit at offsets computed from each step's duration; the slider and the buttons both just call seek.
- One track, many driversThe same x track is written by dragging the knob, by a tween from the button, and by a slider. Nothing is wired together: they all just write the track.
- A custom animation leafanimation({...}) builds a seekable leaf from begin and seek. This one makes a counter tick in whole numbers while a built-in valueTo slides the dot, and both obey scrubbing and composites.
Plotting and charts
Axes, graphs and data-driven charts.
Function graphs and calculus
- Sine and cosinePlot two functions on one set of axes and draw them in with draw().
- Log-scale axesA log y axis turns exponential growth into a straight line, with ticks on each decade. The graph plots through the same scale as the axis.
- Polar roseTrace the curve r = 3 cos 5θ on a polar grid by sweeping θ from 0 to π.
- Area under a curveRiemann rectangles are stacked ever more thinly until they fill the area under the curve.
- Secant to tangentShrink dx toward zero and the secant line through two points turns into the tangent.
- Vector fieldThe phase portrait of a pendulum as arrows colored by their length.
Bars, pies and part-to-whole
- Bar chart revealA bar chart whose bars grow in as draw() drives its progress.
- Horizontal bars<Bars> on a categorical y axis: names laid out top-down, bars growing from zero one after another, values counting up. Hover a bar.
- Grouped and stacked barsOne long-format table, two layouts of one bar mark: series colours the regions through the chart's scale and legend, the dodge layout puts them side by side in each quarter, the stack layout piles them up. The stack grows as one, so every frame is a true stacked chart.
- Value labels in stacked barslabels={{ position: "inside", total: true }} centres each segment's value in it, in whichever of dark and light text reads on its fill, and writes each stack's total past its end. Labels count up and grow in with their segments; one too small for its segment (the 1 in Q2) is left out.
- Diverging stacked barsA Likert chart from long-format rows: series="answer" with layout="stack" sends negative values down from zero and positive values up, so disagreement and agreement grow apart from one centre line, and the chart's colour scale gives the legend in answer order. The question axis stands at the left edge, clear of the bars, and a zero line marks the baseline they grow from.
- Histogram binsThe same 120 samples regrouped into more and more bins, from coarse to fine.
- WaterfallHow a starting figure became a final one: each change grows from where the last left off.
- Bullet chartStephen Few's bullet graph: four KPIs against their targets over poor / fair / good bands, each on its own scale. The bands fade in first, then each bar grows from zero and its target marker draws in.
- FunnelStages of a process, top-down: each widens out from the centre, the loss between them shaded.
- Waffle chartA 10 × 10 waffle where each cell is one percent, filling from the bottom-left like a container. Counts use largest-remainder rounding, so they always add up to 100.
- Mosaic (Marimekko) chartSales by region × product: each column is as wide as its region's share of the market, split by product mix, so every tile's area is its sales. Region names fade in first, then the columns grow left to right.
- Pie and radar chartsA doughnut chart and a two-series radar chart, both built from plain data and revealed together: the doughnut's slices open together from 12 o'clock, each pushed round by the ones before, while the radar's polygons grow out of the centre. ariaLabel gives each slice an accessible name.
- KPI gauge and radial barsA gauge with threshold bands and a needle, beside activity rings. Each draws its track first, then sweeps clockwise while the readout counts up.
Lines, areas and time series
- A chart that fits itself<Chart> ranges its axes from the layers inside it, then draws the frame before the data.
- Line and area curvesThe same readings drawn three ways: a monotone curve (smooth, but never overshooting a reading) over a monotone band, a straight polyline, and a step-after line that holds each value until the next. Curves are native Béziers, and the reveal cuts them along x without straightening them.
- Series and a generated legendOne long-format dataset split by series: a line and markers per city, one colour per city from the chart's scale, and a legend that arrives after the data it explains.
- Time seriesNative Dates make a UTC time axis that ticks on month boundaries and writes dates.
- Annotated seriesMarks layered in one chart: a shaded span, a target rule, the series, labelled points with tooltips.
- One reveal frontreveal="x" sweeps a single clip edge across the plot, so the band, the line and its markers enter together, at a constant rate along x.
- Two y axesRainfall as bars on the left axis and temperature as a line on a secondary axis on the right. Layers inside SecondaryY share the month axis and the reveal but fit their own scale, aligned with alignTicks so its ticks sit on the left axis's grid lines, and the frame makes room for the right-hand numbers inside its width.
- Stacked areasWide-format rows (one object per x) become stacked bands: y takes one channel per band, mixing keys and functions, and series names them, so the bands take the chart's colours and legend.
- StreamgraphStackPlot with offset="wiggle" and order="insideOut": the layers float around a centre line chosen to keep them as level as possible, and the whole stream grows out of it. The week axis sits at the bottom edge (xAxis position) rather than through the stream, and series names the bands for the legend.
- CandlesticksPrices on a time axis (inferred from Dates): each wick draws low to high, then the body grows from the open to the close.
Scatter and distributions
- Scatter with error barsMeasurements as points with a symmetric error bar on each: every point fades in where it stands and its bar grows out of it, left to right.
- Regression with a confidence bandOne least-squares fit per series, each with the 95% band of its mean, narrowest at the centre of its data. The series channel splits the fits and colours fits and points alike, keyed by one legend; every line and band sweeps in along x behind one front.
- Robust LOESS smoothA local regression with its 95% band, through a noisy daily series with a few bad readings. The plain smooth bends toward the outliers and its band balloons; robustness iterations re-weight them away.
- Strip plot and beeswarmEvery observation as a dot, coloured by cohort through the chart's series scale and legend. A strip plot spreads them by seeded jitter (the same on every frame); a beeswarm packs them so none overlap. Dots appear in place, low values first.
- Box and violin plotsThe same three samples summarised two ways: quartile boxes that open out of their medians, and kernel-density violins that widen out of their centre lines.
- Grouped box plotsBox plots split by a series, seaborn's hue: the boxes sharing a dose stand side by side in its slot, and a dodged strip of the raw readings sits over each box. One colour scale and one legend serve both.
- Density with a rugOne kernel density estimate per series (morning and evening waits, from one long-format sample), both sweeping in along x behind one front, with the raw sample as a rug of ticks standing on the axis, in the same series colours, drawn in value order.
- RidgelineOne Density over long-format rows, with series="month" and row: each month's curve stands on its own row of a band y axis and rises into the one above, so the shift in the distribution month by month reads as a landscape. The month axis stands at the left edge, clear of the curves, though the temperatures cross zero, and reveal="x" uncovers every ridge behind one shared front.
- Parallel coordinatesFour car measurements side by side: each car is a line across the axes, drawn left to right once the axes are in.
Facets and linked views
- Small multiples with shared scalesOne panel per island from a single long-format table. The panels share both scales, so the clusters compare across the row, and only the outer panels write numbers; the species colours come from one scale with one legend. Every frame draws first, then the panels fill left to right.
- A row × column facet gridOne table split two ways: years down the rows, islands across the columns. Each row's year is written once in the right margin and each island once over the top row, the panels share both scales, and one legend runs along the top.
- Facet grid with x shared down each columnscales={{ x: "column" }} gives each travel mode its own distance axis, shared by the rows below it (ggplot's facet_grid with scales = "free_x"), and space="free" sizes each column by its range, so a kilometre is one length across the grid. Time stays shared.
- Facet panels sized by their categoriesEach department has its own teams, so the x axes are independent; space="free" makes each panel as wide as its number of bars, so every bar is the same width and the panels read as one row of bars. The value axis is shared.
- Pair plotEvery pair of three measurements against each other, each measurement's density on the diagonal. Panels in a column share x and panels in a row share y, so a flower lines up across the matrix; only the bottom row and left column write numbers and names.
- Scatter with marginal densitiesA joint plot: two groups in a scatter, with each variable's density along its edge, the right-hand one a vertical density, values up y. The marginals follow the scatter's scales, so the curves line up with the points, and they are normalised together, so each curve's area is its group's share and the larger group stands taller.
- Brushing linked chartsAn overview with a draggable range brush drives two detail charts linked on x. The brush writes two tracks and the link reads them, so dragging it, using the arrow keys, or animating the tracks (as here) zooms both details together, and scrubbing the timeline replays it.
- Brushing a box on both axesA two-dimensional brush on the left selects a box of the cloud and the chart on the right zooms to it. Drag the box, an edge or a corner, or Tab to it and use the arrow keys; the four tracks it writes are the right chart's ranges, animated here.
- Brushing categories on a band axisOn a category axis the brush snaps to whole bars, and an arrow key moves it one bar. brushedCategories turns its two tracks into the months it covers, which the chart below breaks down by product.
Heatmaps and contours
- Annotated heatmapCategorical rows and columns, a colormap, and each value written in a colour that reads on its cell.
- Heatmap with contoursA grid of values colored as a heatmap, with iso-lines of the same field drawn over it.
- Clustered heatmapHours of use per app and weekday, clustered both ways by average linkage: similar apps and similar days move next to each other, and each dendrogram replays its merges, closest first, as the cells fade in.
- Log and diverging colour normsA field spanning four decades on a log norm, and temperature anomalies on a diverging norm centred on zero, each with a colour bar that follows its norm.
- Contours from scattered samplesReadings at scattered stations, triangulated: after the frame, the faces fade in as a wave from the top-left while the contour lines draw level by level, lowest first.
Hierarchies, networks and flows
- TreemapA squarified treemap of a source tree: tiles fade in folder by folder, coloured by top-level folder.
- SunburstA sunburst of a monthly budget, revealed by one clockwise sweep from 12 o'clock.
- DendrogramA cluster dendrogram of a small taxonomy: elbow links grow out of the root one level at a time, leaves aligned on the right.
- Radial dendrogramA small family of languages as a radial cluster tree: the root in the centre, every language on the outer ring, links growing out level by level.
- Treemap data transitionOne budget, two years. Tiles are matched by their path of names: the team that was cut fades out, the others resize into place, the new team fades in. One blend track drives it, so it scrubs. Data order and an order-keeping tile keep every frame a clean tiling.
- Treemap transition that keeps its rowsThe values reorder, so a fresh squarify would re-row the tiles and slide them across each other. tile="resquarify" lays the new values out in the old rows instead: every tile keeps its neighbours and every frame is a clean tiling, at the cost of the end not being the plain squarified layout.
- Sunburst drill-downZooming into one branch of a sunburst and back out: the focus is a transition between two nodes driven by one track, so the zoom scrubs like any other animation. The chosen branch becomes the centre and its children open out round the whole turn.
- Tree data transitionA reorganisation as a node-link tree. Nodes are matched by their path of names: the team that was wound up draws back into its parent, the rest slide to their new places with their links following, then the new teams grow out of theirs. One blend track drives it, so it scrubs.
- Network layoutsOne set of vertices and edges placed three ways by changing only the layout prop.
- Sankey diagramEnergy flowing from sources to uses: nodes appear column by column, then the flows draw left to right.
- Chord diagramMigration between four regions: the ring sweeps round like a pie, then each chord fades in, as wide at each end as the flow leaving it.
- Directed chord diagramWho emails whom: one chord per direction, each as wide at both ends as its flow, ending in an arrowhead on the team it reaches. A team that only receives still gets its arc.
Chart transitions
- Morphing chart dataCharts redraw from their data, so animating the data animates the chart: one blend track mixes two datasets and every bar follows.
- Line morph in data spaceEach line morphs on one shared x grid, so values move vertically and a line that gains data grows at its end; the old forecast fades out, the new series sweeps in, and the axes rescale with them.
- Stacked area morphEach end is stacked on its own and every band's two edges morph together on one shared x grid, so each frame is still a stack: a leaving band shrinks and the bands above settle onto it, a new one grows in its place.
- Bars into a scatterOne blend track turns a bar chart into a scatter plot: the bars shrink away, the category axis cross-fades into a number line, and the dots on the bars' tops slide to their new places in scene units while the y axis glides to the new axis's zero. Played forward, then back.
- Animated axis rescaleOne track drives the y domain and the data together, shared by the axis, the grid and the marks: the values grow tenfold as the axis rescales under them, so the points barely move while the numbers change. Ticks on both ends slide, the rest cross-fade, and labels that would crowd fade out as they close up.
- Keyed scatter updateOne blend track joins two datasets by key: Lima shrinks away where it stood, the fitted y axis grows, matched cities move in data space, then Oslo grows in. Played forward, then scrubbed back.
- Keyed bubbles with a staggered entranceBubbles sized by population through the `size` channel (area ∝ value), keyed by the frame's size legend, blend to a later year by key: Lima shrinks away, the others move and resize, then three new cities grow in one after another, left to right (`enterStagger`). Only the entrance is staggered; the moves stay together, so they are easy to follow.
- Keyed beeswarm updateWeek 1 to week 6 of a trial on one blend track: participants who drop out shrink away, everyone else slides from their place in the first swarm to their place in the second (both ends packed), then a new arm's band opens and its dots grow in.
- Keyed box plot updateOne blend track joins two years of trial arms by name: placebo closes into its median, the fitted axis grows, the matched arms' quartiles and whiskers move in data units, then a new arm opens. Played forward, then scrubbed back.
- Keyed pie morphOne blend track joins two years of browser share by name: IE's slice closes and its neighbours take the room, the shares change in data space, then Edge opens where the new year has it. Every frame is a whole pie.
- Radar with a changing axis setTwo phones rated on five axes, then on a new set of five. Axes are matched by name: Weight and Price fold away, every polygon's corner on them flattening into its edge, the shared axes turn to their new places, then Camera and Repair unfold. The polygons blend axis by axis on the same track.
- Sorting bars with slotsA slots model owns the order; the chart's band axis reads each category's slot through `slot`, so bars and their names slide together. Each sort is one seekable `permute`, staggered.
- Bar chart raceValues interpolate between yearly keyframes, ranks come from the interpolated values, and each overtake slides on its own short ease. The category axis follows the ranks through its `slot`, so names ride with their bars, and only the top five are shown: whoever drops out slides under the last place and out of view.
- Animated scatter with trailsTime as an encoding, Gapminder-style: one marker per country at the moment `at`, sized by population (area ∝ value, the `size` channel) and interpolated between decades, with a trail of the path it took. The axes fit every decade, so they hold still while time plays.
- Streaming seriesNew samples arrive off-screen right and the x domain slides left under a clip; the leaving tick fades out. Everything is a function of one time track, so it scrubs.
Interaction
Dragging, constraints and keyboard-accessible scenes.
Dragging and input
- First scene: make it draggableStep three of the first-scene tutorial: the same theta track that the animation writes is now also written by dragging the dot around the ring.
- Drag constraintsThree dots with three rules: one moves freely, one is pinned to a circle, and one snaps to a grid of 0.5 units.
- Drag along a ringA dot constrained to a circle, draggable with the pointer or the arrow keys.
- Keyboard-accessible draggingEvery draggable is also a tab stop. Tab to the dot, then use the arrow keys to move it by 0.5 units (hold Shift for 0.1), or Escape to cancel a drag in progress.
- A slider that drives a graphDrag the knob along a line to change the frequency of a sine wave. scalarParam turns the pointer position into a number, and the graph reads that number.
- Linked dotsDrag any corner of the triangle. The outline and the area readout are derived from the three dragged points, so they update on every move.
- Drop targetsDrag the token onto either box. Each box lights up while the token is over it, and the choice is reported when you let go.
- Step-through lessonDrag the token onto the right answer to unlock Next. Wrong drops bounce back; Tab to a box and press Enter to answer without a pointer.
- Scroll-driven animationScroll the box: its scroll position is the timeline's time. A sticky stage stays pinned while the page behind it moves, and scrolling back rewinds the scene.
Cameras, zoom and drill-down
- Pan and zoomScroll to zoom about the cursor and drag empty space to pan. PanZoom writes the same units and center tracks that the Stage reads.
- Animating the cameraA stage's units and center are ordinary tracks, so moveTo and valueTo fly the camera between landmarks. Nothing is rebuilt: the same scene repaints through a new view.
- Picture-in-pictureOne scene seen through two cameras. Drag the dot in the main view and the magnified inset follows it.
- Zoom a chart with the wheel, a pinch or the keysScroll over the top chart to zoom about the cursor, drag it to pan, pinch on a touch screen, or Tab to it and use + and -, the arrows, and 0 to reset. The zoom writes two tracks and the overview's brush reads the same two, so it follows the zoom, and dragging the brush moves it.
- Drag a box to zoomDrag a rectangle over the plot to zoom into it (a thin one zooms one axis), hold Shift to pan instead, Backspace to step back out, and 0 or a double tap to reset; Escape mid-drag cancels. The toolbar in the corner switches between panning and box zoom and resets, and each button is a tab stop. The x axis is logarithmic: zooms and the bounds work in decades. The wheel over the plot zooms the chart, and anywhere else it zooms the stage's own PanZoom camera.
- Zooming a category axisThe top chart is a window onto twelve of thirty-six months. Scroll over it to zoom, drag to pan, or Tab to it and use the arrows and + and -: drags, pinches and keys settle on whole months, and the names leaving the window fade. The overview's brush reads the same two tracks; scroll over the brush to grow or shrink it.
- Tap to drill into a treemapTap a tile to zoom into its folder, tap a crumb above to zoom back out; Tab and Enter do the same. The zoom is a tween of the chart's focus, so it is exactly the scrubbable drill-down transition, and under reduced motion it dissolves instead.
- Tap to zoom into a treeTap a node to spread its subtree over the chart, tap it again (or the back arrow, or a crumb) to zoom out; Tab and Enter do the same. Deep trails collapse their middle into an ellipsis that climbs back up.
- Zoomable circle packingTap a circle to zoom into it and the background to zoom out, along d3's smooth zoom path. The chart is controlled: createDrillDown holds the focus and tweens it, and the same focus drives the breadcrumb trail, so both scrub together.
Math and LaTeX
Formulas as geometry that draws and transforms.
- Euler's identityLaTeX is geometry: two formulas are written out stroke by stroke.
- Quadratic formulaAn equation and its solution are written out one after the other with write().
- Formula morphSymbols shared by two equations glide to their new places while the rest fade, so completing the square reads as algebra.
- Taylor seriesPolynomial approximations of sin x of degree 1, 3, 5 and 7 are drawn in turn, each hugging the curve for longer.
- Fourier square waveAdding odd sine harmonics one at a time turns a plain sine wave into a square wave.
- Linear transformationA shear matrix warps the plane and a unit square, while the basis vectors show where each column of the matrix lands.
- Complex multiplicationMultiplying z by 1 + i turns it by 45 degrees and stretches it by the square root of 2, which is the argument and modulus of 1 + i.
- Coloring parts of a formulacreateLatex hands back every glyph as its own part, so each one can get its own color. Here the unknown x is picked out from the rest of the equation.
- Squaring the complex planeA grid of lines is sent through z ↦ z²: straight lines bend into parabolas, and right angles stay right angles.
- A pendulum's phase flowA disc of starting states flows along a pendulum's phase portrait: near the bottom it circles round, and it stretches into a thin arc as the swings drift out of step.
- A tracker and a dot on a graphManim's ValueTracker plus always_redraw, as a track() and derive(): a dot rides y = sin x while its x readout updates.
3D
Cameras, meshes and orbit controls projected onto the same canvas.
- Orbit a 3D sceneDrag to orbit a cube and a sphere; the camera eye is a plain track.
- Helix curveA parametric 3D curve drawn in by draw(); drag to orbit around the helix.
- Surface plotA rippling surface y = f(x, z) sampled from a function of two parameters; drag to orbit around it.
- 3D bar chartA 3 by 3 grid of bars whose heights come from one array; each box is anchored at its corner and rises along y.
- 3D stem plotPoints on a circle with drop lines falling along y to the floor, each stem as tall as its y value.
- Camera motionThe camera eye is derived from an angle track, so a plain rotateBy() loop turns the camera around the scene.
- The platonic solidsAll five regular solids side by side, outlined so their faces read. Drag to orbit.
- Surface from coordinate gridsA saddle z = x^2 - y^2 given as three matrices (xs, ys, zs, like numpy's meshgrid), drawn as shaded quads with a wireframe on top. viewHeight sets how large the scene projects.
Advanced projects
Larger scenes that combine several features.
- Sine curve from the unit circleA point circles a unit circle while its height is traced out as a sine wave to the right.
- Fourier epicyclesFour circles chained end to end, each spinning at its own rate; the tip of the last arm traces a rounded square.
- Gradient descentA point rolls down the contours of f(x, y) = (x^2 + 6y^2) / 2, zig-zagging across the narrow valley and leaving a trail.
- Sorting visualizerBars bubble-sort themselves: a slots model keeps each bar's identity, each swap is one plan.swapAt() played with an await, and the compared pair is highlighted.
- Scrubbable bubble sortA sort recorded as one timeline: bars keep their identity in a slots model, every compare and swap is an animation, so you can play, pause, step and scrub the whole run in either direction.
- Breadth-first traversalA BFS over a small graph. The visit order is computed once; a single step counter drives which vertices and edges are lit.
- A custom shape: SpiralA new primitive in a dozen lines. defineShape takes the props and a geometry function, so it gets styling, transforms, gradients, draw() and paint order like any built-in; wrap() makes it a component.
- Export a PNGThe stage's ref hands you the scene. captureFrame encodes scene.canvas as last painted; download the blob.
- Export an image sequenceexportFrames seeks a timeline to exact instants, paints each one synchronously and encodes the canvas. The thumbnails are real exported frames.
Without a framework
The same core from plain TypeScript: createScene, definitions, tracks and play.
- A custom shape with defineShapedefineShape turns a props descriptor and a geometry function into a definition like circle; the new rose shape is created, drawn and animated.
- Dragging and node eventsdraggable() makes a handle write a point track; a line and a caption follow it, and node.on() listens for hover and taps.
- A first scene, no frameworkcreateScene, a few definitions and two tracks: draw a ring, then move a point along it, from plain TypeScript.
- Instancing: thousands of dots, one nodeinstances() draws 4,000 circles as one node with per-item channels; changing its data tweens every dot to a new layout with a stagger.
- PathBatch: many outlines, one nodeA field of 600 arrowheads, each its own outline and colour, drawn by one pathBatch node whose items derive from a single phase track.
- Springs: springTo and followspringTo is a seekable spring animation with an overshoot; follow keeps a second point chasing the first, live, preserving its velocity.
- Tracks, derive and watchOne track drives a dot, a radius, an arc and a caption through derive; watch mirrors it into the page once per frame.