dynamic
generative
color
Tree Circles and Parametric Magic – A Dance of Branches and Curves

Tree Circles and Parametric Magic – A Dance of Branches and Curves

written by reyrove

07 Oct 2024100 EDITIONS
1 TEZ

Setting the Scene: The Canvas Awakens

const ratio = 1 / 1;
const prefix = 'Fourier 1';
const features = {};

Defining the Colors: Picking the Palette

const BackgroundColours1 = ['#CD5C5C', '#F08080', ...];
const BackgroundColours2 = ['#FFFFE0', '#FFFACD', ...];
const ForegroundColours1 = ['#ff4a03', '#ff7803', ...];
const ForegroundColours2 = ['#610803', '#5c2f08', ...];

The Magic of Tree Circles

function drawTreeCircle(ctx, startX, startY, length, angle, depth, branchWidth, color1, color2, radius) {
ctx.arc(endX, endY, Radius, 0, 2*Math.PI);

Building the Branches

function drawTree(ctx, startX, startY, length, angle, depth, branchWidth, color1, color2) {
subBranches = ($fx.rand() * (maxBranch - 1)) + 1;

Parametric Curves: The Wave of Fourier

function drawParametricCurve(ctx, centerX, centerY, radius, steps, color, Width, color2) {
const parametricX = (T) => centerX + R/B1[0] * Math.sin(T/A1[0]);
const parametricY = (T) => centerY + R/B2[0] * Math.cos(T/A2[0]);

Drawing the Canvas: Trees and Curves Unite

ctx.arc(0, 0, w/3, 0, Math.PI * 2, true);
drawTreeCircle(ctx, X1, Y1, w/100, Angle1, 8, w/250, color11, color21, w/500);
drawParametricCurve(ctx, w/2, h/2, 3*w/4, 400, color3, w/150, color4);

Explore and Play

And just like that, we’ve created a living, breathing digital forest, full of vibrant colors, swirling shapes, and blossoming circles. Every time you run this code, the forest grows in new and unexpected ways. You can play with the code, experiment with the colors, branches, and curves, and see what kind of magical forest you can grow.

For the full code, click here, and don’t forget to share your creations with me on X, Instagram, and Facebook. We’d love to see what your digital forest looks like!


Come visit us in our digital home—you’re always welcome as our guest, to explore, to create, and to enjoy the beauty we craft together.

With all love,

_Frostbond Coders

stay ahead with our newsletter

receive news on exclusive drops, releases, product updates, and more

feedback