Skip to main content
100%

Trigonometry for Designers Example Code - Translated into HTML5 Canvas (JavaScript)

✓ Published0🌍 Public
Aadammarcwilliams
Last edited Oct 24, 2016
Created on Oct 24, 2016

This example generates a spiraling floral pattern on an HTML5 canvas using the JavaScript Canvas API. It draws hundreds of overlapping petal-like shapes, each positioned and rotated according to the golden angle (137.5 degrees) with a growing radius. The pattern emerges from repeated trigonometric calculations—cosine and sine for placement, plus rotation and scaling transformations per petal. The code uses `CTX.translate`, `CTX.rotate`, `CTX.scale`, and `CTX.arc` to render each petal with layered circles and rectangles, producing a dense, organic composition.

AI-generated description

Similar vizzes