Shape Composition
30 / 30
Combine circle and rectangle masks to build more complex shapes using min/max or simple compositing.
This is the Module 4 capstone. Combine a circle mask and a rectangle mask into one compound shape using max — the union of two shapes.
max for shape union
Both masks are 0/1 values. Taking max per pixel:
- Either one is 1 → result is 1 (pixel is inside some shape)
- Both are 0 → result is 0 (pixel is outside both shapes)
This is equivalent to merging the two shapes together.
Rectangle mask
Use abs(uv - center) to measure distance from center, then compare to half-size:
Circle mask
Exercise
The exercise starts with rect = 0.0, circle = 0.0 (all background). Build both masks, then combine them with max.
Answer Breakdown
The circle and rectangle overlap partially. max means: show the foreground color if the pixel belongs to at least one shape.
Try replacing max(rect, circle) with min(rect, circle) — min is intersection: only the overlapping region shows.