Run drawing script
run_scriptExecute JavaScript to procedurally draw patterns, particles, and brushwork in Atelier, creating animated art as a single undoable step.
Instructions
Run JavaScript that draws procedurally (forests of grass, hatching, particles, patterns...). The whole script is ONE undo step and is animated live in the UI. All calls are synchronous. API (same args as the tools): stroke(strokeOrArray, defaults?) shape(shapeOrArray, opts?) text(itemOrArray, opts?) fill(args) filter(filterOrArray, opts?) select(args) addLayer(args) updateLayer(args) deleteLayer(ref) duplicateLayer(args) mergeLayers(args) clearLayer(args) transformLayer(args) layerMask(args) canvasSettings(args) note(text) sample(x, y, layer?) -> {hex, alpha, hsl} layers() -> [{id,name,...}] W, H (canvas size) rand() [0,1) seeded · random(a,b) · randInt(a,b) · pick(array) · gauss() ≈N(0,1/3) clipped to [-1,1] · noise(x,y) Perlin [-1,1] · fbm(x,y,octaves) hsl(h,s,l,a?) s,l in 0..100 -> css · rgb(r,g,b,a?) · mix(colorA, colorB, t) -> hex · lighten(color, amount) · lerp · clamp · print(...) (console.log too) Example: for (let i=0;i<300;i++){ const x=random(0,W); stroke({brush:"grass", color:hsl(100+random(-15,15),45,random(25,45)), points:[[x,H-20],[x+random(-20,20),H-60-random(0,80)]], layer:"Grass"}) }
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"code": "<code>"
},
"name": "run_script"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | JavaScript source | |
| seed | No | Seed for rand()/noise (default random) | |
| label | No | Name shown in history/UI |