PLAYGROUND (experimental)

arc

Draw an arc
arc(
    x, 
    y, 
    radius, 
    start, 
    stop, 
    [close=false], 
    [pie=false], 
    [stroke=#000000], 
    [fill=#FFFFFF], 
    [weight=1.00]
)

Draw an arc

Syntaxe

arc(x=10, y=10, radius=100, start=0, stop=HALF_PI, stroke="#000000", fill="#FFA000", weight=4);

Arguments

NameTypeRequiredDefaultDescription
xfloatyes-x-coordinate of the center
yfloatyes-y-coordinate of the center
radiusfloatyes-Radius of the arc
startfloatyes-angle to start the arc, specified in radians
stopfloatyes-angle to stop the arc, specified in radians
closebool-falseclose the arc (useless if pie is used)
piebool-falseclose the arc to the center (overrides close)
strokehexastring-#000000Stroke color
fillhexastring-#FFFFFFFill color
weightfloat-1.00Stroke weight (thickness)

Full example

var margin = 10;
var radius = 50;

var x = radius + margin;
var y = radius + margin;

var gap = 10 ;

var startStart = 0;
var stopStart = PI / 4;
var stopEnd = TWO_PI - PI / 4;
var count = 10;
var stepX = radius*2 + gap;
var rowGap = radius * 2 + gap;

var canvasWidth = margin * 2 + radius * 2 + (count - 1) * stepX;
var canvasHeight = margin * 2 + radius * 2;
canvas(canvasWidth, canvasHeight * 11.2);


var black = "#0D150A";
stroke(black);
weight(3);

for (var i = 0; i < count; i++) {
    var t = i / (count - 1);
    var stopAngle = stopStart + t * (stopEnd - stopStart);

    arc(x + i * stepX, y, radius, startStart, stopAngle, fill="transparent");
    circle(x + i * stepX, y, 3, fill="#889092", stroke="transparent");
    
    fill("#E0E3C6");
    arc(x + i * stepX, y + rowGap, radius, startStart, stopAngle);
    circle(x + i * stepX, y + rowGap, 3, fill="#889092", stroke="transparent");
    
    fill("#F3B61F");
    arc(x + i * stepX, y + rowGap * 2, radius, startStart, stopAngle, close=true);
    circle(x + i * stepX, y + rowGap * 2, 3, fill="#889092", stroke="transparent");
    
    fill("#E86219");
    arc(x + i * stepX, y + rowGap * 3, radius, startStart, stopAngle, pie=true);
    circle(x + i * stepX, y + rowGap * 3, 3, fill="#889092", stroke="transparent");

}

def ring(x, y, d, start, arc_length, w, c) {
    fill("transparent");
    weight(w);
    stroke(c);
    arc(x, y, d, start, start + arc_length);
}

var rings = [];
var palette = ["#E0E3C6", "#F3B61F", "#E86219"];

coord_translate(width()/2, 925);


fill("transparent");

var w = 30 ;

for( var r = 40; r < 430; r += w) {
    randseed(r*PI);
    var rad = random(0,TAU);
    var al = random(rad,TAU);
    var col = randlist(palette) ;

    ring(0, 0, r, rad, al, w-2, col);
    // ring(0, 0, r, rad, al, 2, black);
}


save(whoami(png=true));