@arc
The path data of an arc, L … A …, for a path d.
It continues the current path, so arcs and lines chain into one shape.
Angles are degrees clockwise from three o'clock, like SVG rotate().
Syntax
- @arc(r: <rx> [<ry>]; from: <angle>; to: <angle>; at: <x> [<y>])
- @arc(<rx> [<ry>] [at <x> [<y>]], [<angle>] to <angle> [, …])
- r
- One radius, or two for an ellipse. Defaults to
0. - from
- Start angle. Defaults to
0(three o'clock). - to
- End angle. Defaults to
360, a full circle drawn as two arcs. - at
- The center. One value sets both axes. Defaults to the origin.
moveis its older name.
The short form lists the same values: @arc(40 at 50 50, 0 to 180)
is @arc(r: 40; at: 50 50; from: 0; to: 180).
Without angles it is a full circle.
Several ranges draw pieces of the same circle, each one separate:
@arc(40, 0 to 90, 180 to 270) is @arc(40, 0 to 90) M @arc(40, 180 to 270).
A sweep of a full turn or more is the whole circle.
When to is less than from the arc is counter-clockwise.
Angles take deg, rad, grad or turn.
Every value takes arithmetic, as in to: 360 * .7.
At the start of d, path or path() the leading L becomes M.
So does the one after a bare M or m: @arc(…) M @arc(…) draws two separate arcs.
The data ends at the arc's end, so @arc(…) L 0 0 Z is a pie slice.
Examples
@grid: 1 / 60vmin;
background: @svg(
viewBox: 100;
path {
d: @arc(r: 36; from: 0; to: 180; at: 50 50);
fill: none;
stroke: #000;
stroke-width: 6;
stroke-linecap: round;
}
); A line back to the center closes a pie:
@grid: 1 / 60vmin;
background: @svg(
viewBox: -50 -50 100 100;
path {
d: @arc(r: 40; from: -40; to: 40) L 0 0 Z;
fill: #000;
}
); A second arc, drawn back the other way, closes a ring segment:
@grid: 1 / 60vmin;
background: @svg(
viewBox: -50 -50 100 100;
path {
d: @arc(r: 44; from: -150; to: -30)
@arc(r: 24; from: -30; to: -150) Z;
fill: #000;
}
); Two radii draw an ellipse:
@grid: 1 / 60vmin;
background: @svg(
viewBox: 100;
path {
d: @arc(r: 40 22; from: 0; to: 270; at: 50 50);
fill: none;
stroke: #000;
stroke-width: 5;
}
); A bare M starts a new arc. Two around opposite corners make a Truchet tile:
@grid: 1 / 60vmin;
background: @svg(
viewBox: 0 0 6 6;
fill: none;
stroke: #000;
stroke-width: .12;
stroke-linecap: round;
path*6x6 {
d: @arc(.5, 0 to 90) M @arc(.5 at 1, 180 to 270);
transform: translate(@nx(-1) @ny(-1)) rotate(@p(0, 90) .5 .5);
}
);