curve_svgpath
curve_svgpath(path, [segments=100], [draw=true], [stroke], [fill], [weight])
Draw or parse an SVG path
Syntaxe
curve_svgpath("M10 10 H 90 V 90 H 10 L 10 10", stroke="#000");
Arguments
| Name | Required | Default | Description |
|---|---|---|---|
path | yes | - | SVG path string |
segments | - | 100 | Number of segments for curves |
draw | - | true | Draw the path (true) or return points (false) |
stroke | - | - | Stroke color |
fill | - | - | Fill color |
weight | - | - | Stroke weight (thickness) |
Full example
var palette = ["#EAB1C6", "#E9B109", "#E18A1F", "#829D44", "#D35E17"];
canvas(600, 500);
load_text_default(size=18);
curve_svgpath("M10 10 H 90 V 90 H 10 L 10 10");
curve_svgpath("M30 30 H 90 V 90 H 10 Z");
curve_svgpath("M110 215 a 30 50 0 0 1 52.55 -52.45", fill=palette[0]);
curve_svgpath("M172.55 152.45 a 30 50 -45 0 1 42.55 -42.55");
coord_open();
coord_translate(0, 200);
curve_svgpath("M80 80 A 45 45, 0, 0, 0, 125 125 L 125 80 Z");
curve_svgpath("M230 80 A 45 45, 0, 1, 0, 275 125 L 275 80 Z");
curve_svgpath("M80 230 A 45 45, 0, 0, 1, 125 275 L 125 230 Z");
curve_svgpath("M230 230 A 45 45, 0, 1, 1, 275 275 L 275 230 Z");
coord_close();
coord_open();
coord_translate(300, -0);
coord_scale(0.5);
for(var i=0; i<9; i++) {
var seg = (i+4);
curve_svgpath("M230 80 A 45 45, 0, 1, 0, 275 125 L 275 80 Z", segments=seg, fill=palette[i%palette.length]);
text("segments="+seg, 300, 80);
coord_translate(0, 100);
}
coord_close();
save("curve_svgpath.png");
var p = curve_svgpath("M80 80 A 45 45, 0, 0, 0, 125 125 L 125 80 Z", segments=12, draw=false);
console(p); // [25, -15.9807621135, 40, 10, 25, 35.9807621135, ...]
