Canvas Design Skill
This skill enables the creation of generative art, patterns, and abstract compositions using Python.
Core Capabilities
- Generative Art: Use algorithms to create unique visuals (fractals, noise, cellular automata).
- Pattern Generation: Create seamless tiles, geometric designs, and textures.
- Image Manipulation: Apply filters, blend modes, and transformations.
- Drawing Primitives: Render shapes, lines, and text using vector commands.
Dependencies
Pillow (pip install Pillow) - Core image manipulation.
numpy (pip install numpy) - Mathematical operations for generative art.
matplotlib (pip install matplotlib) - Plotting complex forms.
Workflow Examples
1. Simple Geometric Composition (Pillow)
from PIL import Image, ImageDraw
import random
width, height = 800, 600
img = Image.new('RGB', (width, height), 'white')
draw = ImageDraw.Draw(img)
# Draw random circles
for _ in range(50):
x = random.randint(0, width)
y = random.randint(0, height)
r = random.randint(10, 50)
color = (random.randint(0, 255), random.randint(0, 255), random.randint(0, 255))
draw.ellipse([x-r, y-r, x+r, y+r], fill=color, outline='black')
img.save('geometric_art.png')
2. Mandelbrot Fractal (NumPy + Matplotlib)
import numpy as np
import matplotlib.pyplot as plt
def mandelbrot(h, w, max_iter=20):
y, x = np.ogrid[-1.4:1.4:h*1j, -2:0.8:w*1j]
c = x + y*1j
z = c
divtime = max_iter + np.zeros(z.shape, dtype=int)
for i in range(max_iter):
z = z**2 + c
diverge = z*np.conj(z) > 2**2
div_now = diverge & (divtime == max_iter)
divtime[div_now] = i
z[diverge] = 2
return divtime
plt.figure(figsize=(10, 10))
plt.imshow(mandelbrot(800, 800, 50), cmap='magma')
plt.axis('off')
plt.savefig('mandelbrot.png', bbox_inches='tight', pad_inches=0)
Best Practices
- Resolution: Default to reasonable sizes like 800x600 or 1024x1024 for quick generation.
- Vector vs Raster: Use
matplotlib for complex curves/plots, Pillow for pixel manipulation.
- Performance: Avoid extremely high iterations or resolution in Python loops.
1---2name: canvas-design3description: Create programmatic digital art using Python libraries like Pillow (PIL), NumPy, and Matplotlib. Generate images, fractals, patterns, and abstract compositions.4license: MIT5---67# Canvas Design Skill89This skill enables the creation of generative art, patterns, and abstract compositions using Python.1011## Core Capabilities12131. **Generative Art**: Use algorithms to create unique visuals (fractals, noise, cellular automata).142. **Pattern Generation**: Create seamless tiles, geometric designs, and textures.153. **Image Manipulation**: Apply filters, blend modes, and transformations.164. **Drawing Primitives**: Render shapes, lines, and text using vector commands.1718## Dependencies1920* `Pillow` (pip install Pillow) - Core image manipulation.21* `numpy` (pip install numpy) - Mathematical operations for generative art.22* `matplotlib` (pip install matplotlib) - Plotting complex forms.2324## Workflow Examples2526### 1. Simple Geometric Composition (Pillow)2728```python29from PIL import Image, ImageDraw30import random3132width, height = 800, 60033img = Image.new('RGB', (width, height), 'white')34draw = ImageDraw.Draw(img)3536# Draw random circles37for _ in range(50):38 x = random.randint(0, width)39 y = random.randint(0, height)40 r = random.randint(10, 50)41 color = (random.randint(0, 255), random.randint(0, 255), random.randint(0, 255))42 draw.ellipse([x-r, y-r, x+r, y+r], fill=color, outline='black')4344img.save('geometric_art.png')45```4647### 2. Mandelbrot Fractal (NumPy + Matplotlib)4849```python50import numpy as np51import matplotlib.pyplot as plt5253def mandelbrot(h, w, max_iter=20):54 y, x = np.ogrid[-1.4:1.4:h*1j, -2:0.8:w*1j]55 c = x + y*1j56 z = c57 divtime = max_iter + np.zeros(z.shape, dtype=int)5859 for i in range(max_iter):60 z = z**2 + c61 diverge = z*np.conj(z) > 2**2 62 div_now = diverge & (divtime == max_iter) 63 divtime[div_now] = i 64 z[diverge] = 2 6566 return divtime6768plt.figure(figsize=(10, 10))69plt.imshow(mandelbrot(800, 800, 50), cmap='magma')70plt.axis('off')71plt.savefig('mandelbrot.png', bbox_inches='tight', pad_inches=0)72```7374## Best Practices7576* **Resolution**: Default to reasonable sizes like 800x600 or 1024x1024 for quick generation.77* **Vector vs Raster**: Use `matplotlib` for complex curves/plots, `Pillow` for pixel manipulation.78* **Performance**: Avoid extremely high iterations or resolution in Python loops.