본문으로 건너뛰기
cccskills
무료GitHub에 공개

p5js-prototypes

Write p5.js prototypes into the lab — sketches that actually run in a browser, seed-reproducible, with controls generated from the sketch's own parameters. Use for generative art, flow fields, particle systems, noise, animation, anything sketched visually in the browser.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

설치 방법 보기

포함된 파일(5)

  • SKILL.md7.3 KB
  • examples/attractor-nodes/example.json591 B
  • examples/attractor-nodes/sketch.js6.6 KB
  • examples/flow-field/example.json507 B
  • examples/flow-field/sketch.js4.1 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

p5.js prototypes

A p5.js run in this lab is a folder of source that a browser opens, not a chat artifact that scrolls away. lab_new writes it, lab_lint judges it, the tab shows it, and it stays on disk where you can change it and look again.

The shape of a run

lab/p5js/<slug>/
  sketch.js     the prototype: setup(), draw(), and the algorithm's state
  index.html    the shell: the library, the seed, the controls. GENERATED.
  p5.min.js     p5.js, vendored so the run is offline. GENERATED.
  README.md     what it is and how to run it. GENERATED.
  NOTES.md      the seed, what to look at, what to try. GENERATED.

Edit sketch.js. Add a parameter by adding an entry to the params array in index.html AND reading it in sketch.js — the control is generated from that array, so there is no second place to keep in step.

The contract: one object

The shell puts everything the sketch needs on window.__dshProtoLab__:

window.__dshProtoLab__.seed          // an integer; the same seed draws the same picture
window.__dshProtoLab__.params        // [{ name, min, max, value, step }, ...]
window.__dshProtoLab__.param('name') // the ONLY way a sketch should read a tunable
window.__dshProtoLab__.drew = true   // set at the end of the first draw() - see below

Seed yourself before anything is drawn — this snippet is executed by the package's own check against a stub p5, so it is a shape that runs:

// The shell creates both holders before this factory runs.
const spec = window.__dshProtoLab__;

window.__dshProtoLabLifecycle__.setup = function () {
  randomSeed(spec.seed);
  noiseSeed(spec.seed);
  createCanvas(windowWidth, windowHeight).parent('lab-stage');
  background(0);
};

let first = true;
window.__dshProtoLabLifecycle__.draw = function () {
  // ... the algorithm ...
  if (first) { spec.drew = true; first = false; }
};

Why the lifecycle goes into a holder instead of onto window. p5's own auto-start watches window.setup and window.draw and constructs its OWN instance the moment either appears — so a sketch that installs them on window races the framework for its own lifecycle, and p5's instance wins. The shell hands the two functions to its own new p5({ setup, draw }) instead, and the sketch never touches those two names. lab_new writes this shape for you.

Three things follow from that contract, and all three are checked:

  • randomSeed and noiseSeed are not optional. Without them the run is not reproducible, lab_lint reports unseeded, and "same seed, same picture" stops being true — which is the only reason a seed exists.
  • window.__dshProtoLab__.drew = true at the end of the first draw() is how the shell and the headless render check tell a drawn frame from a canvas that stayed black because setup() threw.
  • Read tunables through window.__dshProtoLab__.param(name), never by copying a number into a second variable at load time: the slider has to change the algorithm.

Derive the algorithm; do not pick a pattern

The order that produces something worth keeping:

  1. The concept — one sentence, and it is about the process, not the image: "seeds drift along a noisy vector field and die of old age, so density accumulates where the field slows them". lab_new concept="...".
  2. The derivation — what quantities does that sentence name? particles, a field, a lifetime, a respawn rule. Those become state and parameters.
  3. The seed's job — say what varies with it (initial population, respawn positions, the noise offset), because that is what makes a seed worth scrubbing rather than a randomisation button.
  4. The code — and only then choose the p5 calls that express the derivation.

What separates a prototype from a doodle is not the number of features. It is that the picture is a consequence of a rule you can state, and that changing one number shows you the rule working. If you cannot say which parameter would change the picture and how, the algorithm is not finished.

The rules that matter in a browser

  • The frame is a budget. 60 fps is ~16 ms for everything in draw(). A few thousand particles with one line() each is fine; a nested loop over every pixel is not. When something is expensive, say so in NOTES.md and give it a parameter that turns it down.
  • Recompute per frame, store per particle. The field is a function of position (noise(x * scale, y * scale, t)); never cache it into a grid unless you also make rebuilding it cheap.
  • A veil beats a clear for anything that moves. fill(0, 8); rect(0, 0, w, h) in draw() accumulates paths into density; background(0) throws the history away.
  • windowResized() — the canvas is the window, so resize and rebuild, rather than letting the browser stretch the canvas.
  • Offline means offline. No CDN <script>, no remote image, no font URL. The library is already beside the run; if you need another file, put it in the folder. lab_lint reports remote-asset as an error.
  • The preview is one composed page. It inlines the library and sketch.js and permits no network at all, so a loadImage('data/x.png') will work when index.html is opened in a browser and will NOT work in the Lab tab (lab_lint warns loads-a-file). Do not design around the preview — design the run, and open the file when you need assets.

Workflow

lab_new   runtime=p5js concept="..." params=[{name:"particles",min:200,max:6000,value:1800,step:50}]
lab_read  run=p5js/<slug> file=sketch.js
          ... edit sketch.js ...
lab_lint  run=p5js/<slug>

Then look at it: the Lab tab in the right bar, or the run's own index.html in a browser. ?seed=42 (and any parameter, ?seed=42&particles=900) explores the space without touching the file.

Aim your effort where it shows: get one gesture right — the field, the palette, the respawn rule — rather than four half-tuned ones. Then write down in NOTES.md what you saw and what you would try next, because that is the file the next person (or the next you) reads first.

Examples that ship with this skill

Two complete, seed-reproducible runs sit in examples/ beside this file; read them as reference, and instantiate one to work on it:

lab_new action=example runtime=p5js example=flow-field
lab_new action=example runtime=p5js example=attractor-nodes
exampleconceptseed
flow-fieldparticles carried by layered noise, fading trails accumulating where the field slows20260401
attractor-nodesa population pulled toward moving attractors, its traces mapping the basins between them20260402

Both are checked: every example is rendered headlessly by this package's own check, and a different seed must produce a different picture.

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

Author an editorial HTML+SVG diagram with the Diagram Design kit - choose the visual type, read its reference, start from an example, and satisfy the safety and accessibility contract that diagram_write({kind:"html"}) enforces.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

vecnode/vn-code92026년 10월 19일 업데이트

Drive ffmpeg through the media_run tool as an argv array - remux instead of re-encode, map streams explicitly, trim at keyframes, scale and crop, extract audio and frames, and build GIFs, contact sheets and concatenations. Covers the flags this pack injects, reading a failure from its exit code and last log lines, and the version-dependent spellings to hedge.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

vecnode/vn-code92026년 10월 19일 업데이트

Read a media file's real structure with ffprobe through media_run - the JSON invocation and how to read it, what every family of field means, how to count frames, sample without decoding everything, detect HDR and interlacing, and diagnose a missing duration, a stream with no frames or a container that lies. Covers when media_probe's own report is already enough.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

vecnode/vn-code92026년 10월 19일 업데이트

Use when the user wants to design, redesign, shape, critique, audit, polish, simplify, harden, animate, or otherwise improve a frontend interface: websites, landing pages, dashboards, product UI, components, forms, settings, onboarding, empty states, and native iOS or Android screens. Handles UX review, hierarchy, layout, typography, color, motion, UX copy, accessibility, responsive behavior, edge cases, and capturing or documenting design systems (DESIGN.md, tokens). Also for making bland UI bolder, loud UI quieter, or ambitious visual effects. Not for backend-only or non-UI tasks.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

vecnode/vn-code92026년 10월 19일 업데이트

Author Mermaid diagrams that parse the first time: choose the right diagram type for the question, write syntax the parser accepts, and keep the picture readable in a narrow panel. A bundled reference covers complex, large diagrams.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

vecnode/vn-code92026년 10월 19일 업데이트

Write openFrameworks prototypes into the lab — real C++ (ofApp.h, ofApp.cpp, main.cpp) that builds into an app with the projectGenerator and make. Use for native/desktop sketches, performance-sensitive work, OpenGL, audio input, sensors, anything that has to be an application rather than a page.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

vecnode/vn-code92026년 10월 19일 업데이트

vecnode의 스킬 모두 보기

이 스킬의 문제 신고