算法艺术创作
algorithmic-art
通过代码和可调参数创作生成艺术与交互式视觉效果。
design-generative-art【设计与创意】Create algorithmic visuals with p5.js, Canvas, or SVG using seeded randomness and interactive controls. Use when "generative art", "procedural visuals", "flow fields", "particle system", or "art from code". Charts → data-visualization.
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
Degree of freedom: MIXED. Algorithm and palette [HIGH freedom]; existing
pipeline inventory and seed reproducibility [LOW freedom — run exactly].
Create generative, procedural, and mathematical art using code. Transform algorithms into visual experiences.
Inventory: no p5; one
getContext('2d')chart canvas — do not hijack it. Seed:mulberry32(42)drives a newsrc/components/art/flow field. Parameterize:density,palette(ocean),scale; slider re-renders from the same seed. Validate: seed 42 twice matches;prefers-reduced-motionstops the RAF loop.
data-visualization; UI illustration → design-frontend; WebGL/3D → enhance-web-web3dBefore creating ANY generative art, verify:
cat package.json | grep -i "p5\|three\|canvas\|pixi\|paper"
ls -la src/components/art/ src/components/generative/ 2>/dev/null
rg "Canvas|useFrame|getContext.*2d|WebGL" --type tsx -l
rg "simplex\|perlin\|noise\|seedrandom" --type ts
Why: Don't conflict with existing rendering pipelines or duplicate utility code.
Every piece should be reproducible with a seed:
function mulberry32(seed: number) {
return function() {
let t = seed += 0x6D2B79F5
t = Math.imul(t ^ t >>> 15, t | 1)
t ^= t + Math.imul(t ^ t >>> 7, t | 61)
return ((t ^ t >>> 14) >>> 0) / 4294967296
}
}
// Usage
const rng = mulberry32(42) // Same seed = same output
const value = rng() // 0-1 deterministic random
Make art controllable via parameters:
interface ArtParams {
seed: number
density: number // 0-1
palette: string[]
scale: number
speed: number
complexity: number // 0-1
}
Design for any canvas size:
// Normalize coordinates to 0-1 range
const nx = x / width
const ny = y / height
// Then scale to canvas
const px = nx * canvas.width
const py = ny * canvas.height
function generateLSystem(system: LSystem): string {
let current = system.axiom
for (let i = 0; i < system.iterations; i++) {
current = current.split('').map(c => system.rules[c] || c).join('')
}
return current
}
Full implementations of all four: references/algorithms.md.
'use client' canvas wrapper; seed, width, height, palette, className propsuseCallback keyed on seed/size/palette; useEffect calls itDate.now() seed) and a labelled numeric seed inputmaxWidth: '100%', height: 'auto' for responsive displayFull component: references/component-palettes-export.md §React Component Pattern.
Curated 5-color sets in warm / cool / monochrome / vibrant / Japanese-inspired groups (sunset, ocean, ink, neon, wabi, …).
Table: references/component-palettes-export.md §Color Palettes.
requestAnimationFrame loop; t = frame * params.speed * 0.01rgba(0,0,0,0.02)) for trailscancelAnimationFrameFull loop: references/algorithms.md §Animation Loop.
canvas.toDataURL('image/png') into a download link named ${filename}-${Date.now()}.pngXMLSerializer → Blob (image/svg+xml) → URL.createObjectURLHelpers: references/component-palettes-export.md §Export & Sharing.
enhance-web-web3d — WebGL, Three.js, shaders for 3D generative artdesign-motion — Animation patterns for interactive piecesdesign-canvas — Print-quality visual design philosophydata-visualization — Data-driven generative compositionsAfter creating algorithmic art:
prefers-reduced-motion