사용 방법
- 설치 명령을 복사하고 자신의 에이전트 환경에 설치하기 전에 소스 패키지를 확인하세요.
- 필요한 도구, 인증 정보, 지원 환경은 원본 문서에서 확인하세요.
- 입력과 원하는 산출물을 설명하고 출처와 결과를 대조하세요.
npx skills add https://github.com/progen/p5-brush-skill --skill p5-brush시작 전 확인
- 설치에는 모델 구독, API 한도, 파일 접근 권한이 포함되지 않습니다.
- 별점 수와 설치 수는 활동 지표이며 독립적인 품질·보안 검증이 아닙니다.
원본 Skill 문서
원본 저장소의 제목, 예시, 코드, 표, 링크, 이미지를 유지해 표시합니다.
p5.brush — AI Generative Art Skill
You generate standalone HTML files that produce generative art using p5.js 2.x and p5.brush v2.
Library by [@acamposuribe](https://github.com/acamposuribe/p5.brush). Design custom brushes visually with the Brush Maker.
Workflow
- User describes what they want (e.g. "a field of wildflowers in charcoal", "abstract watercolor circles")
- You write a complete HTML file with an embedded p5.js sketch using the p5.brush API
- Save to a sensible location (e.g.
./output/<descriptive-name>.htmlin the current project, or wherever the user specifies) - Open in browser:
open <path>
Output Template
Every generated file follows this structure:
html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>p5.brush — [title]</title>
<script src="https://cdn.jsdelivr.net/npm/p5@2/lib/p5.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/p5.brush@2.0.0-beta"></script>
<style>
html, body { margin: 0; padding: 0; overflow: hidden; background: #1a1a1a; display: flex; justify-content: center; align-items: center; height: 100vh; }
canvas { display: block; }
</style>
</head>
<body>
<script>
function setup() {
createCanvas(800, 800, WEBGL);
brush.load();
// Shift WEBGL origin to top-left:
translate(-width / 2, -height / 2);
// Set background
background(245, 240, 235); // warm paper
// Set a random seed for reproducibility
randomSeed(42);
// --- Your generative art code here ---
}
</script>
</body>
</html>CRITICAL RULES
- Always use `WEBGL` mode:
createCanvas(w, h, WEBGL)— p5.brush v2 requires it - Always call `brush.load()` in setup, after
createCanvas(w,h,WEBGL). Usebrush.load(buffer)to target ap5.Graphicsorp5.Framebuffer, andbrush.load()to switch back - Shift origin:
translate(-width/2, -height/2)right after background to work in top-left coordinates - Angles follow `angleMode()` — radians by default (matching p5).
brush.addField()angles default to degrees unless you pass{ angleMode: "radians" } - `brush.arc()` is stroke-only — it does NOT fill.
brush.circle()andbrush.rect()support stroke + fill + hatch - Use `randomSeed()` for reproducible outputs — p5.brush syncs automatically (both
randomSeed()andnoiseSeed()) - Static sketches only need `setup()` — no
draw()loop needed. Usedraw()only for animations withbrush.refreshField(frameCount/10) - All drawing in one frame — put everything in
setup()for static art - Text labels: use HTML overlay, NOT p5 `text()` — WEBGL mode requires TTF/OTF fonts loaded via
loadFont()which is fragile with CDN fonts. For labeled artwork, use absolutely positioned HTML<div>elements over the canvas instead - Image brushes require `await` —
brush.add()returns a Promise fortype: "image". You mustawaitit and declareasync function setup() - Fill budget — watercolor fills are expensive. Keep filled shape count reasonable (under ~50 for complex fills with high bleed) or the sketch will lag
API REFERENCE
Setup & Config
js
brush.load() // Initialize. Call in setup() after createCanvas(w,h,WEBGL)
brush.load(buffer) // Target a p5.Graphics or p5.Framebuffer
brush.load() // Switch back to main canvas
brush.scaleBrushes(scale) // Scale all default brush params (weight, scatter, spacing)
brush.instance(p) // For p5 instance mode — call before setup/drawVector Fields
Fields guide brush strokes along organic paths. Activate before drawing.
js
brush.field("waves") // Activate: "hand", "curved", "zigzag", "waves", "seabed", "spiral", "columns"
brush.noField() // Deactivate
brush.wiggle(5) // Shorthand: activate "hand" field with intensity (1-10)
brush.refreshField(t) // Update field for animation (use frameCount/10 in draw())
brush.listFields() // Returns array of available field namesCustom field:
js
brush.addField("myField", function(t, field) {
for (let col = 0; col < field.length; col++)
for (let row = 0; row < field[0].length; row++)
field[col][row] = 45 + noise(col * 0.1, row * 0.1) * 180;
return field;
}, { angleMode: "degrees" }); // default is degrees
brush.field("myField");Brush Management
js
brush.box() // Returns array of all brush names
brush.pick("2B") // Select brush without changing color/weightBuilt-in brushes:
| Name | Type | Character |
|---|---|---|
2B | pencil | Soft, dark, textured |
HB | pencil | Medium, balanced |
2H | pencil | Hard, light, precise |
cpencil | pencil | Colored pencil, softer opacity |
pen | pen | Ink pen, clean lines |
rotring | pen | Technical pen, very precise |
charcoal | pencil | Heavy texture, wide scatter |
spray | spray | Scattered dots |
marker | marker | Flat, solid strokes |
marker2 | marker | Marker variant |
hatch_brush | hatch | Clean lines for hatching |
Custom brush types:
js
// Standard custom brush
brush.add("myBrush", {
type: "default", // "default", "spray", "marker", "custom", "image"
weight: 0.5, // thickness (canvas units)
scatter: 0.8, // sideways wobble (canvas units)
sharpness: 0.5, // 0-1, edge softness (default type only)
grain: 10, // texture density (default type only)
opacity: 150, // 0-255
spacing: 0.1, // gap between stamps (1 = no overlap)
pressure: [1, 0.5], // [start,end] or [start,mid,end] or (t)=>value
rotate: "natural", // "none", "natural", "random"
});
// Custom tip brush — draw your own tip shape
brush.add("diamond", {
type: "custom",
weight: 5,
opacity: 23,
spacing: 0.6,
pressure: [0.5, 1.5, 0.5],
tip: (_m) => { _m.rotate(45); _m.rect(-1.5, -1.5, 3, 3); },
rotate: "natural",
});
// Image brush — MUST use await + async setup()
await brush.add("watercolor", {
type: "image",
weight: 10,
scatter: 2,
opacity: 30,
spacing: 1.5,
pressure: [1, 0.5],
image: { src: "./brush_tips/brush.jpg" },
rotate: "random",
});Stroke
js
brush.set("2B", "#333", 1) // Set brush, color, weight — activates stroke
brush.stroke("#ff0000") // Set color, activate stroke
brush.strokeWeight(2) // Weight multiplier
brush.noStroke() // Disable strokeFill (Watercolor)
js
brush.fill("#4a90d9", 150) // Color + opacity (0-255), activate fill
brush.fill(244, 15, 24, 75) // RGB + opacity
brush.fillBleed(0.5, "out") // Edge bleed: strength 0-1, direction "out"/"in"
brush.fillTexture(0.5, 0.3) // Texture: strength 0-1, border intensity 0-1
brush.noFill() // Disable fillHatch
js
brush.hatch(8, 45, { rand: 0.2, continuous: false, gradient: false })
// dist: line spacing, angle: follows angleMode(), options: { rand, continuous, gradient }
brush.hatchStyle("rotring", "#555", 0.5) // Brush for hatch lines
brush.noHatch()
brush.hatchArray(polygons) // Hatch across multiple Polygon objects at onceDrawing Primitives
Lines & curves (stroke only):
js
brush.line(x1, y1, x2, y2)
brush.flowLine(x, y, length, direction) // Follows active vector field
brush.spline([[x1,y1], [x2,y2,pressure], ...], curvature) // 0-1 curvature
brush.arc(x, y, radius, startAngle, endAngle) // STROKE ONLY, follows angleMode()Shapes (support stroke + fill + hatch):
js
brush.rect(x, y, w, h) // Default: top-left corner mode
brush.rect(x, y, w, h, "center") // Center mode
brush.circle(x, y, radius) // Supports stroke + fill + hatch
brush.circle(x, y, radius, true) // With hand-drawn irregularity
brush.polygon([[x1,y1], [x2,y2], ...]) // Not affected by vector fieldsCustom shapes (support stroke + fill + hatch, affected by fields):
js
brush.beginShape(0.5) // curvature 0-1
brush.vertex(x, y) // or brush.vertex(x, y, pressure)
brush.vertex(x2, y2)
brush.endShape(true) // true = close shapeManual stroke paths:
js
brush.beginStroke("curve", x, y) // or "segments"
brush.move(angle, length, pressure)
brush.endStroke(angle, pressure)Clipping
js
brush.clip([x1, y1, x2, y2]) // Clip strokes/hatches to rectangle (not fills)
brush.noClip()Classes
Polygon:
js
let poly = new brush.Polygon([[x1,y1], [x2,y2], ...]);
poly.draw() // Draw outline with current stroke
poly.fill() // Fill with current fill settings
poly.hatch() // Hatch with current hatch settingsPlot (reusable stroke paths):
js
let plot = new brush.Plot("curve");
plot.addSegment(angle, length, pressure);
plot.endPlot(finalAngle, finalPressure);
plot.draw(x, y); // Draw at position
plot.fill(x, y); // Fill at position
plot.hatch(x, y); // Hatch at positionPosition (flow field walker):
js
let pos = new brush.Position(x, y);
pos.moveTo(direction, length, stepLength); // Move along flow field
pos.angle(); // Get field angle at current position
pos.reset(); // Reset plotted distanceRECIPES
Hand-drawn look
js
brush.wiggle(3);
brush.set("2B", "#333", 1);
brush.line(100, 100, 400, 300);Watercolor blobs
js
brush.noStroke();
brush.fill("#4a90d9", 100);
brush.fillBleed(0.6, "out");
brush.fillTexture(0.5, 0.3);
brush.rect(200, 200, 300, 300);Cross-hatched shapes
js
brush.noFill();
brush.hatch(5, 45, { rand: 0.1 });
brush.hatchStyle("rotring", "#444", 0.5);
brush.set("pen", "#222", 0.8);
brush.rect(100, 100, 300, 300);
// Layer second direction:
brush.hatch(5, -45, { rand: 0.1 });
brush.rect(100, 100, 300, 300);Flow field lines
js
brush.field("curved");
brush.set("cpencil", "#8B4513", 0.8);
for (let i = 0; i < 200; i++) {
brush.flowLine(random(width), random(height), random(100, 400), random(TWO_PI));
}Filled circle with watercolor
js
brush.noStroke();
brush.fill("#e85d75", 120);
brush.fillBleed(0.4);
brush.circle(400, 400, 100);Mixed media grid (from author's examples)
js
let palette = ["#7b4800", "#002185", "#003c32", "#fcd300", "#ff2702", "#6b9404"];
let cols = 12, rows = 6, border = 300;
let cw = (width - border) / cols, rh = (height - border) / rows;
brush.field("curved");
for (let i = 0; i < rows; i++) {
for (let j = 0; j < cols; j++) {
if (random() < 0.1) {
brush.fill(random(palette), random(80, 140));
brush.fillBleed(random(0.05, 0.4));
brush.fillTexture(0.55, 0.5);
} else {
brush.set(random(["2H", "HB", "charcoal"]), random(palette));
brush.hatchStyle(random(["marker", "marker2"]), random(palette));
brush.hatch(random(10, 60), random(0, 180));
}
brush.rect(border/2 + cw * j, border/2 + rh * i, cw, rh);
brush.noStroke(); brush.noFill(); brush.noHatch();
}
}Design Tips
- Paper colors: warm
(245, 240, 235), cream(252, 248, 240), cool white(248, 248, 252), dark(30, 30, 35) - Layering: Draw background elements first (light opacity), then foreground (higher opacity). Multiple passes build depth.
- Organic variation: Use
random()andnoise()for position, size, color shifts. Avoid exact repetition. - Color palettes: Pick 3-5 colors. Vary saturation/brightness with
random()for natural feel. - Composition: Use golden ratio, rule of thirds, or radial layouts. Leave breathing room.
- Texture stacking: Combine hatching + watercolor fill + pencil outlines for rich mixed-media effects.
- Scale:
brush.scaleBrushes(2)for larger canvases (1200+px) so strokes stay visible. - p5 transforms work:
push(),pop(),translate(),rotate(),scale()— brush state is saved/restored automatically alongside p5's state.