Skip to main content
100%

Bahamas flag (how to make rectangles and polygons)

✓ Published0🌍 Public
AAdamBlaine1
Last edited Mar 15, 2016
Created on Mar 15, 2016

This example builds the Bahamas flag from basic D3.js shapes, using three horizontal rectangles and one overlaid triangle. The code appends three `<rect>` elements to an SVG, each with a distinct fill color—cyan for the top and bottom bands and yellow for the middle—and then adds a black `<polygon>` to represent the triangular hoist side. The polygon’s coordinates are explicitly defined in the `points` attribute, connecting the left edge’s top and bottom corners to a central point, while the rectangles use simple x, y, width, and height properties. Rendering relies on D3’s selection and attribute methods to construct the SVG elements directly.

AI-generated description

Built with blockbuilder.org

Similar vizzes