9 Pict Radial Shapes
import: pict/radial | package: rhombus-pict-lib |
function | ||
| ||
function | ||
| ||
function | ||
| ||
function | ||
| ||
function | ||
| ||
function | ||
| ||
function | ||
> star(~fill: "gold")
> flash(~fill: "red")
> flower(~fill: "purple")
> cloud(~fill: "gray")
> regular_polygon(~fill: "blue")
> gear(~fill: "brown")
function | |||||||||||||||||||
|
Various arguments have expected ranges, but none of the ranges are enforced, and interesting images can be created by using values outside the normal ranges:
inner
0 to outer
inner_pause
0 to 1
outer_pause
0 to 1
inner_pull
0 to 1
outer_pull
0 to 1
The result of radial is squashed to ellipse form if height is not the same as width. The rotate argument determines an amount of rotation (in radians counter-clockwise) applied to the imagine before it is squashed. The bounding box for the resulting pict corresponds to a square around the original circle, and it is not affected by rotate. (It is affected by bound, however, as described further below.)
Points radiating from the inner to outer radius are evenly spaced by default, but angle_at is called for each point’s index to get a location for each point, and it can choose a different spacing (e.g., with some “jitter” from even spacing in the case of cloud).
The points extend from a base of radius inner to an edge at radius outer. By default, the connection from a point at the inner radius to a point at outer radius uses up half the radial space allocated to the point. If inner_pause is greater than 0, it represents a fraction of half the space between points that stays at the inner radius before extending out. Similarly, outer_pause is a fraction allocated to staying at the out radius. When staying at the inner or outer radius, flat_inner_edge and flat_outer_edge determine whether the start and end points are connected by a straight line or an arc at the radius.
When the inner_pull and outer_pull arguments are 0, then the inner and outer points are straight corners. Otherwise, they determine an amount of curvature. Each of outer_pull and inner_pull represent an amount of curvature touward a rounder “petal.”
The line, line_width, and fill arguments are the same as for functions like rectangle.
The bound argument can be #'unit, #'unit, #'shrink, or #'stretch. The default, #'unit, gives the resulting pict a bounding box that corresponds to the outer radius of the image. If bound is #'shrink, then the bounding box is instead one that encloses the inner and outer points of the figure, and so the resulting pict may have bounds smaller than width and height. The #'stretch mode is similar to #'shrink, but the pict is scaled and stretched to ensure that its bounding box has dimensions width and height.
> radial_pict()
> radial_pict(~fill: #'inherit).colorize("red")
> radial_pict(~width: 64, ~height: 32, ~rotate: math.pi * 1/2)
> radial_pict(~inner_pause: 0.5, ~outer_pause: 0.25, ~fill: "black")
> radial_pict(~outer_pull: 0.25, ~fill: "purple")
> radial_pict(~inner_pull: 0.25, ~fill: "forestgreen")
> radial_pict(~outer_pull: 0.25, ~inner_radius: -0.5, ~fill: "lightblue")
ellipse(~around: radial_pict(~points: 3)),
rectangle(~around: radial_pict(~points: 3)),
rectangle(~around: radial_pict(~points: 3, ~bound: #'shrink)),
rectangle(~around: radial_pict(~points: 3, ~bound: #'stretch)))
annotation | |||||||||||||||
| |||||||||||||||
function | |||||||||||||||
|
For example, gear uses radials_pict to combine gear arms with a hole when a non-zero hold is requested.
function | |
| |
function | |
| |
function | |
| |
function | |
| |
function | |
| |
function | |
| |
| |
function | |
| |
function | |
> flower_radial(~petals: 5).pict(~fill: "pink")
method | ||||||
| ||||||
| ||||||
method | ||||||
A DC path for a radial places the middle of the shape at the origin, so it extends up to half the shape’s width in each direction horizontally, and up to half the shape’s height in each direction vertically.
> regular_polygon_radial().pict(~fill: "orange")
> regular_polygon_radial(~width: 64).path().bounding_box()
Rect(-30.433808521444913, -32.0, 60.867617042889826, 57.88854381999832)
function | |||||||
|
> radials_pict([regular_polygon_radial(~width: 64),
gear_radial(~width: 52)],
~fill: "orange")
function | ||||||||||||
| ||||||||||||
| ||||||||||||
function | ||||||||||||
The length argument determines the length of the arrow. The head argument determines the fraction of length that is used for the triangular head, while breadth determines its breadth of that triangle in a direction perpendicular to the length. The tail argument determines the thickness of the tail line as a fraction of breadth; if tail is 0, then no tail is drawn (and head defaults to 1 in that case). The indent argument determines a fraction of the head’s length by which the the tail side of the arrow’s is indented at its center, forming a barb along the line if indent is positive or a more diamond-shaped head if indent is negative.
The arrow is rotated by rotate radians. With a zero rotation, the arrow points to the right (i.e., toward a greater x-offset). The arrow is rotated around its center.
The bound argument determines the bounding bod of the arrow pict. The default #'unit mode makes the bounds correspond to an unrotated arrow, and as the arrow is rotated around its center, it is likely to extend outside that box. The #'shrink mode shrinks or extends the bounding box as needed to cover all of the corners of the arrow. The #'line mode for bound creates a bounding box that covers just the tip of the arrow and the center of the ending edge of the tail.
> arrow(~fill: "forestgreen")
> arrow(~tail: 0, ~fill: "blue")
function | |
| |
function | |
The function returned by jitter_spaced takes the angle that it would otherwise return an adjust it based on a math.sin of the angle times jitter. The default ~angle_at argument for cloud is jitter_spaced(0.3).
> radial_pict(~points: 5, ~angle_at: jitter_spaced(0.2))
enumeration | ||||
enumeration | ||||