{"name":"prefab-sketch","title":"Sketch","kind":"prefab","status":"available","summary":"The byte-light creative-coding loop: full-window 2D canvas, dpr scaling, resize, draw(ctx, {t, dt, mouse}), p5 ergonomics at ~1KB.","spec":"prefab-sketch@0.1.1","version":"0.1.1","versions":["0.1.1","0.1.0"],"license":"MIT","source":"prototir","sizeKB":1,"requires":[],"permissions":[],"flags":{"wasm":false,"streamed":false},"compatibility":"Desktop and mobile browsers.","install":{"manifest":"{\n  \"modules\": [\n    \"prefab-sketch@0.1.1\"\n  ]\n}","importFrom":"prefab-sketch"},"example":"import { createSketch } from 'prefab-sketch';\n\ncreateSketch({\n  draw(ctx, { width, height, mouse }) {\n    ctx.fillStyle = '#0a0a0a';\n    ctx.fillRect(0, 0, width, height);\n    ctx.strokeStyle = '#ededed';\n    ctx.strokeRect(mouse.x - 20, mouse.y - 20, 40, 40);\n  }\n});","api":[{"heading":"createSketch(options)","entries":[{"signature":"draw(ctx, state)","description":"Required. Called every frame with the 2D context and state { t, dt, frame, width, height, mouse: { x, y, down } }. dt is capped at 0.05 s."},{"signature":"setup(ctx, state)","description":"Called once before the first frame."},{"signature":"canvas, mount = document.body","description":"Draw into your own canvas, or let it add a full-window one to `mount`."},{"signature":"dpr = min(devicePixelRatio, 2), clear = false","description":"Pixel density, and whether to clear the canvas before each frame."}]},{"heading":"The returned sketch","entries":[{"signature":"canvas, ctx, state","description":"The canvas, its context and the live state."},{"signature":"destroy()","description":"Stops the loop, removes listeners, and removes the canvas if it created it."}]}],"notes":["The byte-light path for canvas art: the p5 setup/draw ergonomics without shipping the library. p5 is still in the catalog for Processing-style sketches."],"upstreamDocs":null,"labs":[]}