No matching definitions.

plutovg/path

src/plutovg/path.tur
defn

path-create

(path-create :ptr<void>)

allocate a new empty path.

(ok handle) on success; (err 0) on allocation failure. Free with path-destroy when done.

(let [r (path-create)] (if (ok? r) (let [p (ok-val r)] ...)))

Since: PV2

defn

path-destroy

(path-destroy [p :int] :void)

release a path allocated by path-create or path-clone.

ppath handle

void

(path-destroy p)

Since: PV2

defn

path-move-to

(path-move-to [p :int x :float y :float] :void)

begin a new subpath at (x, y).

ppath handle
xdestination x
ydestination y
(path-move-to p 10.0 10.0)

Since: PV2

defn

path-line-to

(path-line-to [p :int x :float y :float] :void)

append a straight line to (x, y).

Since: PV2

defn

path-quad-to

(path-quad-to [p :int x1 :float y1 :float x :float y :float] :void)

append a quadratic Bezier to (x, y) via control (x1, y1).

Since: PV2

defn

path-cubic-to

(path-cubic-to [p :int x1 :float y1 :float x2 :float y2 :float x :float y :float] :void)

append a cubic Bezier with controls (x1,y1)/(x2,y2).

Since: PV2

defn

path-arc-to

(path-arc-to [p :int rx :float ry :float rotation :float large-arc? :bool sweep? :bool x :float y :float] :void)

append an SVG-style elliptical arc to (x, y).

ppath handle
rxhorizontal radius
ryvertical radius
rotationx-axis rotation in radians
large-arc?:bool, choose the large (true) or small (false) arc sweep
sweep?:bool, sweep direction (true = clockwise)
xdestination x
ydestination y

Since: PV2

defn

path-close

(path-close [p :int] :void)

close the current subpath with a straight line to its origin.

Since: PV2

defn

path-add-rect

(path-add-rect [p :int x :float y :float w :float h :float] :void)

append an axis-aligned rectangle as a closed subpath.

Since: PV2

defn

path-add-round-rect

(path-add-round-rect [p :int x :float y :float w :float h :float rx :float ry :float] :void)

append a rounded-corner rectangle as a closed subpath.

ppath handle
xtop-left x
ytop-left y
wwidth
hheight
rxhorizontal corner radius
ryvertical corner radius

Since: PV2

defn

path-add-ellipse

(path-add-ellipse [p :int cx :float cy :float rx :float ry :float] :void)

append an axis-aligned ellipse as a closed subpath.

Since: PV2

defn

path-add-circle

(path-add-circle [p :int cx :float cy :float r :float] :void)

convenience: append a circle subpath.

Since: PV2

defn

path-add-arc

(path-add-arc [p :int cx :float cy :float r :float start-angle :float sweep-angle :float] :void)

append a circular arc centered at (cx, cy).

ppath handle
cxcenter x
cycenter y
rradius
start-anglestart angle in radians
sweep-angleend angle in radians (interpreted by plutovg)
The plutovg helper expects start and end angles plus a `ccw` flag;
we expose the simpler "start + sweep" form by interpreting sweep-angle
as the end angle and defaulting ccw to false (clockwise sweep). Callers
that need counter-clockwise sweeps should construct the arc manually
with arc-to.

Since: PV2

defn

path-clone

(path-clone [p :int] :ptr<void>)

create an independent copy of a path.

(ok handle) on success; (err 0) on allocation failure.

Since: PV2

defn

path-clone-flatten

(path-clone-flatten [p :int] :ptr<void>)

copy a path with all curves approximated by line segments.

(ok handle) on success; (err 0) on allocation failure.

Since: PV2

defn

path-clone-dashed

(path-clone-dashed [p :int offset :float dashes :int] :ptr<void>)

copy a path, replacing every segment with the

psource path handle
offsetphase offset into the dash pattern
dashesdash-array handle (from plutovg/canvas dash-array-create /
dash-array-add); empty buffer disables dashing

(ok handle) on success; (err 0) on allocation failure. Release the returned path with path-destroy.

(let [da (ok-val (dash-array-create))]
    (dash-array-add da 4.0)  ; 4 on
    (dash-array-add da 2.0)  ; 2 off
    (let [r (path-clone-dashed p 0.0 da)] ...)
    (dash-array-destroy da))

Since: PV6

defn

path-parse

(path-parse [p :int svg :cstr] :ptr<void>)

populate p with an SVG path-data string.

pdestination path (existing contents are preserved; new commands
are appended after the current point)
svgSVG path-data, e.g. "M 10 20 L 30 40 Z"

(ok 0) on success; (err 0) if plutovg rejected the string.

(path-parse p "M 0 0 L 4 0 L 4 4 Z")

Since: PV2

defn

path-extents

(path-extents [p :int] :ptr<void>)

compute the bounding box of a path.

ppath handle

(ok rect-handle) holding x/y/w/h floats accessible via rect-x etc. Release with rect-destroy.

(let [r (path-extents p)]
    (let [box (ok-val r)]
      (println (rect-w box))
      (rect-destroy box)))

Since: PV2

defn

path-length

(path-length [p :int] :float)

compute the total length of all path segments in pixels.

ppath handle

Total path length as :float.

(println (path-length p))

Since: PV2

defn

rect-destroy

(rect-destroy [box :int] :void)

release a rect allocated by path-extents / text-extents.

Since: PV2

defn

rect-x

(rect-x [box :int] :float)

read the x component of a rect.

Since: PV2

defn

rect-y

(rect-y [box :int] :float)

read the y component of a rect.

Since: PV2

defn

rect-w

(rect-w [box :int] :float)

read the width of a rect.

Since: PV2

defn

rect-h

(rect-h [box :int] :float)

read the height of a rect.

Since: PV2

Internal definitions
__ok-- create an ok result wrapping integer value v.
__err-- create an err result wrapping integer error value e.