PLAYGROUND (experimental)

polygon_round

Get a polygon and round his corners
polygon_round(
    points, 
    radius, 
    precision, 
    [draw=true], 
    [stroke=#000000], 
    [fill=#FFFFFF], 
    [weight=1.00]
) -> NULL || List of points

Get a polygon and round his corners

Syntaxe

polygon_round(points=points, radius=20, points=10)

Arguments

NameTypeRequiredDefaultDescription
pointsyes-List for polygon'coords
radiusyes-Radius of angles
precisionyes-Number of points to add (more precision, more points)
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

canvas(width=880, height=1200);
var color="#FFC107";
font_default(25);
var france = [8,51,56,56,56,29,66,29,86,44,121,9,140,9,175,48,  230,70,190,125,205,192,173,214,136,199,121,224,38,194,57,131,8,75]; // simplified...
def france_contour(){
    for (var i=0; i<france.length-1;i+=2) {
        circle(france[i], france[i+1], 4, fill="#1976D2", stroke="transparent");
    }
}

coord_translate(10,10);
polygon(points=france, fill="#E3F2FD");
text("polygon", 10, 250);
france_contour();

coord_translate(300,0);
polygon_round(points=france, radius=10, precision=10, fill=color);
text("polygon_round 10", 10, 250);
france_contour();

coord_translate(300,0);
polygon_round(points=france, radius=30, precision=10, fill=color);
text("polygon_round 30", 10, 250);
france_contour();

coord_translate(-600,300);
polygon_jitter(france, 5, fill=color);
text("polygon_jitter 5", 10, 250);
france_contour();

coord_translate(300,0);
polygon_jitter(france, 10, fill=color);
text("polygon_jitter 10", 10, 250);
france_contour();

coord_translate(300,0);
polygon_jitter(france, 20, fill=color);
text("polygon_jitter 20", 10, 250);
france_contour();


coord_translate(-600,300);
polygon_smooth(france, 1, fill=color);
text("polygon_smooth 2", 10, 250);
france_contour();
coord_translate(300,0);
polygon_smooth(france, 2, fill=color);
text("polygon_smooth 2", 10, 250);
france_contour();
coord_translate(300,0);
polygon_smooth(france, 3, fill=color);
text("polygon_smooth 3", 10, 250);
france_contour();


coord_translate(-600,300);
polygon_simplify(france, 5, fill=color);
text("polygon_simplify 5", 10, 250);
france_contour();

coord_translate(300,0);
polygon_simplify(france, 15, fill=color);
text("polygon_simplify 15", 10, 250);
france_contour();

coord_translate(300,0);
polygon_simplify(france, 30, fill=color);
text("polygon_simplify 30", 10, 250);
france_contour();


save(whoami(png=true));