PLAYGROUND (experimental)

spiral

spiral(x, y, [rmin=0], [rmax=100], [startangle=0], [sides=100], [space=1], [clockwise=true], [draw=true], [stroke=#000000], [fill=#FFFFFF], [weight=1.00])

Draw a spiral

Syntaxe

spiral(x=10, y=10, radius=5, stroke="#000000", fill="#FFA000", weight=4)

Arguments

NameRequiredDefaultDescription
xyes-x-coordinate of the center
yyes-y-coordinate of the center
rmin-0minimum radius
rmax-100minimum radius
startangle-0startAngle
sides-100Number of sides (>2)
space-1Space between each turn
clockwise-trueClockwise if true, anti- if false
draw-trueIf false, return a list of points, and don't draw (stroke, fill & weight are ignored)
stroke-#000000Stroke color
fill-#FFFFFFFill color
weight-1.00Stroke weight (thickness)

Full example

var palette = palette_blend("#F2BC00", "#C03228", 10);

var cycle = 5;

canvas(800, 800, "#020410", center=true);

var padding = 20;
var x = 0;
var y = 0;
var radius = height()/2 - padding;

stroke("transparent");

var col = 0;
var totalRings = length(palette) * cycle;

for (var j = 0; j < totalRings; j++) {
    var currentRadius = radius - j * (radius / totalRings);
    fill(palette[j % length(palette)]);
    circle(x, y, currentRadius);
}

save("circle.png");