circle
circle(cx, cy, r, [segments=128])
Input: cx, cy, r, segments · Output: no output
What it is
Draws a circle centered at (cx, cy) (numbers, data units) with radius r (number, data units). segments= (integer, default 128) is how many straight edges approximate the curve — raise it for a very large circle, lower it for a deliberately faceted look.
Overloads
One call shape — this function is not overloaded.
| Code | Input | Output | Description |
circle(cx, cy, r, [segments=128]) | cx numberDraws a circle centered at (cx, cy) (numbers, data units) with radius r (number, data units).cy numberDraws a circle centered at (cx, cy) (numbers, data units) with radius r (number, data units).r numberDraws a circle centered at (cx, cy) (numbers, data units) with radius r (number, data units).segments optional (default 128)segments= (integer, default 128) is how many straight edges approximate the curve — raise it for a very large circle, lower it for a deliberately faceted look. | no output | — |
Examples
From the documentation, and run by the build -- the output and the figure below are what the engine actually produced. Simplest first.
circle(0, 0, 1)
axis equal
from plotting
How it works
── shapes ────────────────────────────────────────────── circle(cx, cy, r), ellipse(cx, cy, rx, ry), arc(cx, cy, r, from_deg, to_deg), polygon(xs, ys). All are sampled in DATA space and mapped through the axis transform, so a circle stays a circle when the axes are equal and becomes the correct ellipse when they are not. Emitting an SVG <circle> at a pixel radius would be simpler and would draw the wrong shape on any panel whose scales differ -- which is most of them. segments= controls the sampling; 128 is smooth at any figure size a paper uses and cheap enough not to think about.
From the note above this builtin in the interpreter, where the reasoning was written down as it was built.