Skip to content
eluckey2002Public

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mathart

A gallery of generative pieces drawn straight from equations — harmonographs, attractors, Maurer roses, Ford circles, Chladni figures. Every piece is deterministic: a seed and a handful of numbers produce exactly one picture, and that picture lives in the URL.

Everything is plain HTML, CSS and ES modules using the 2D canvas. No build step, no dependencies, no bundler — the site/ folder is both the source and the deployable artifact, which is the whole reason publishing is one command.

Publish

./publish.sh

That's it. It prints a live URL like https://bright-canvas-a7k2.here.now/.

  • The first run creates the site. Every run after that updates the same site — the slug is remembered in .herenow/state.json (gitignored).
  • Pass ./publish.sh --slug my-name to pick the subdomain, or set HERENOW_SLUG=my-name.
  • Without a here.now API key you get an anonymous site that expires in 24 hours, plus a claim link to make it permanent. With a key (~/.herenow/credentials or $HERENOW_API_KEY) sites are permanent from the start.
  • publish.sh is a thin wrapper: it finds here.now's own publish script, and installs it into ./.agents/ via npx skills add heredotnow/skill if it isn't already on the machine. Extra flags are forwarded, so ./publish.sh --help shows the full set.

Publish from CI

.github/workflows/publish.yml republishes on every push to main that touches site/, and can be run by hand from the Actions tab. It works with no setup at all — the site is anonymous and the job summary carries the URL and a claim link. Two optional settings make it nicer:

Setting Where Purpose
HERENOW_API_KEY Settings → Secrets → Actions makes the site permanent
HERENOW_SLUG Settings → Variables → Actions keeps the URL stable across runs

The first run prints the slug to set.

CI needs Node 22 or newer: the skill installer refuses to run below 22.20, and publish.sh runs it with --yes so its interactive agent picker doesn't stall a headless job.

Develop

./serve.sh          # http://localhost:8000

A real server is required — ES modules will not load over file://.

Layout

site/
  index.html        gallery shell and detail view
  style.css
  app.js            routing, render queue, controls, PNG export
  pieces/
    lib.js          seeded RNG, palettes, canvas helpers
    index.js        the registry — the gallery's order
    *.js            one file per piece
publish.sh          site → here.now, one command
serve.sh            local preview

Adding a piece

Drop a module in site/pieces/ that default-exports this shape:

import { background, ramp, paletteParam } from './lib.js';

export default {
  id: 'lissajous',                     // URL fragment, must be unique
  title: 'Lissajous',
  blurb: 'One sentence on what the equation is doing.',
  formula: 'x = sin(at + δ),  y = sin(bt)',
  params: [
    { key: 'a', label: 'a', min: 1, max: 9, step: 0.01, value: 3 },
    paletteParam('tide')               // or any { type: 'select', options } control
  ],

  async draw(ctx, { w, h, p, rng, detail, tick }) {
    background(ctx, w, h);
    // p.a is the current slider value; rng is seeded, so redraws are identical.
    // await tick(fraction) inside long loops to stay responsive and abortable.
  }
};

Then add two lines to site/pieces/index.js. Sliders, deep links, seed rerolling, PNG export and the gallery thumbnail all come for free.

Two rules keep the gallery coherent:

  • Draw only from rng, never Math.random(), or the same URL will render differently on every visit.
  • await tick(f) in any loop over ~50k iterations, so a slider drag can abort a half-finished render instead of freezing the tab.

URLs

The viewer state is the URL, so any picture worth keeping is a link:

#dejong?seed=k9x2&a=2.2&palette=ember

Only parameters that differ from the defaults are written, which keeps shared links short and readable.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages