Advanced Compositions¶
Combine multiple techniques — layers, groups, merged regions, and connections — into complex artwork.
Multi-Layer Artwork¶
Use z_index to orchestrate four distinct visual layers:
# Layer 0: subtle grid
cell.add_border(color=colors.grid, width=0.3, opacity=0.15, z_index=0)
# Layer 1: faded hexagons
cell.add_polygon(Polygon.hexagon(size=0.6), fill=colors.secondary, opacity=0.15, z_index=1)
# Layer 2: diagonal lines
cell.add_diagonal(width=0.5 + nx * 1.5, color=colors.primary, opacity=0.25, z_index=2)
# Layer 3: accent dots on every 3rd cell
cell.add_dot(radius=0.2, color=colors.accent, opacity=0.7, z_index=3)
Reusable EntityGroup Motifs¶
Define a factory function for a reusable crosshair motif:
def make_crosshair(color1, color2):
g = EntityGroup()
g.add(Dot(0, 0, radius=8, color=color1, opacity=0.6))
g.add(Line(-12, 0, 12, 0, width=1, color=color2, opacity=0.5))
g.add(Line(0, -12, 0, 12, width=1, color=color2, opacity=0.5))
g.add(Ellipse(0, 0, rx=10, ry=10, fill="none", stroke=color2, stroke_width=0.5))
return g
for cell in scene.grid:
group = make_crosshair(colors.primary, colors.secondary)
cell.add(group)
group.fit_to_cell(0.8)
group.rotate(nx * 45)
Merged CellGroup Regions¶
Use grid.merge() to create distinct regions with different treatments:
# Feature area
feature = scene.grid.merge((2, 3), (7, 8))
feature.add_fill(color=colors.primary, opacity=0.15)
feature.add_border(color=colors.accent, width=1.5)
feature.add_text("FEATURED", at="center", font_size=0.10, color=colors.accent, bold=True)
# Title bar
title = scene.grid.merge_row(0)
title.add_fill(color=colors.primary, opacity=0.2)
title.add_text("COMPOSITION", at="center", font_size=0.55, color=colors.accent)
The Full Stack: Image + Geometry + Connections¶
Combine every technique into a single composition:
- Layer 0: Faded image fills as a background
- Layer 1: Hexagons sized by brightness
- Layer 2: White dots on bright cells, connected to neighbors
- Layer 3: Title overlay on merged cells
Layering strategy
Work from background to foreground. Low z_index for ambient elements, high z_index for focal points. Opacity is your best friend for letting layers breathe.