No matching definitions.

plutovg/canvas

src/plutovg/canvas.tur
defn

canvas-create

(canvas-create [s :int] :ptr<void>)

allocate a drawing context that writes into surface s.

ssurface handle (ok-val from surface-create)

(ok handle) on success; (err 0) on failure. Free with canvas-destroy when done. The surface must outlive the canvas.

(let [r (canvas-create s)]
    (if (ok? r) (let [c (ok-val r)] ...) (println "create failed")))

Since: PV0

defn

canvas-destroy

(canvas-destroy [c :int] :void)

release a canvas allocated by canvas-create.

ccanvas handle (ok-val from canvas-create)

void

(canvas-destroy c)

Since: PV0

defn

canvas-set-source-color

(canvas-set-source-color [c :int r :float g :float b :float a :float] :void)

set the current paint to a solid RGBA color.

ccanvas handle
rred in [0.0, 1.0]
ggreen in [0.0, 1.0]
bblue in [0.0, 1.0]
aalpha in [0.0, 1.0]

void

(canvas-set-source-color c 1.0 0.0 0.0 1.0)  ; opaque red

Since: PV0

defn

canvas-fill-rect

(canvas-fill-rect [c :int x :float y :float w :float h :float] :void)

fill an axis-aligned rectangle with the current paint.

ccanvas handle
xtop-left x in surface space
ytop-left y in surface space
wwidth in pixels
hheight in pixels

void

(canvas-fill-rect c 10.0 10.0 100.0 50.0)

Since: PV0

defn

canvas-move-to

(canvas-move-to [c :int x :float y :float] :void)

start a new subpath at (x, y).

ccanvas handle
xdestination x in surface space
ydestination y in surface space

void

(canvas-move-to c 10.0 10.0)

Since: PV1

defn

canvas-line-to

(canvas-line-to [c :int x :float y :float] :void)

append a straight line from the current point to (x, y).

ccanvas handle
xdestination x
ydestination y

void

(canvas-line-to c 100.0 10.0)

Since: PV1

defn

canvas-quad-to

(canvas-quad-to [c :int x1 :float y1 :float x :float y :float] :void)

append a quadratic Bezier from the current point to (x, y) via control (x1, y1).

ccanvas handle
x1control point x
y1control point y
xdestination x
ydestination y

void

(canvas-quad-to c 50.0 0.0 100.0 50.0)

Since: PV1

defn

canvas-cubic-to

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

append a cubic Bezier from the current point.

ccanvas handle
x1first control point x
y1first control point y
x2second control point x
y2second control point y
xdestination x
ydestination y

void

(canvas-cubic-to c 25.0 0.0 75.0 0.0 100.0 50.0)

Since: PV1

defn

canvas-close-path

(canvas-close-path [c :int] :void)

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

ccanvas handle

void

(canvas-close-path c)

Since: PV1

defn

canvas-rect

(canvas-rect [c :int x :float y :float w :float h :float] :void)

append an axis-aligned rectangle subpath to the current path.

ccanvas handle
xtop-left x
ytop-left y
wwidth in pixels
hheight in pixels

void

(canvas-rect c 0.0 0.0 100.0 50.0)

Since: PV1

defn

canvas-ellipse

(canvas-ellipse [c :int cx :float cy :float rx :float ry :float] :void)

append an axis-aligned ellipse subpath.

ccanvas handle
cxcenter x
cycenter y
rxhorizontal radius
ryvertical radius

void

(canvas-ellipse c 50.0 50.0 30.0 20.0)

Since: PV1

defn

canvas-circle

(canvas-circle [c :int cx :float cy :float r :float] :void)

append a circle subpath (convenience for canvas-ellipse with rx == ry).

ccanvas handle
cxcenter x
cycenter y
rradius

void

(canvas-circle c 50.0 50.0 25.0)

Since: PV1

defn

canvas-fill

(canvas-fill [c :int] :void)

fill the current path with the current paint, then clear the path.

ccanvas handle

void

(canvas-rect c 0.0 0.0 100.0 50.0)
  (canvas-fill c)

Since: PV1

defn

canvas-stroke

(canvas-stroke [c :int] :void)

stroke the current path with the current paint, then clear the path.

ccanvas handle

void

(canvas-rect c 0.0 0.0 100.0 50.0)
  (canvas-stroke c)

Since: PV1

defn

canvas-clip

(canvas-clip [c :int] :void)

intersect the clip region with the current path, then clear the path.

ccanvas handle

void

(canvas-circle c 50.0 50.0 25.0)
  (canvas-clip c)

Since: PV1

defn

canvas-add-path

(canvas-add-path [c :int path :int] :void)

append a pre-built path to the canvas's current path.

ccanvas handle
pathpath handle (from plutovg/path)

void

(canvas-add-path c my-path)

Since: PV2

defn

canvas-fill-path

(canvas-fill-path [c :int path :int] :void)

fill a pre-built path without disturbing the

ccanvas handle
pathpath handle

void

Since: PV2

defn

canvas-stroke-path

(canvas-stroke-path [c :int path :int] :void)

stroke a pre-built path without disturbing the

ccanvas handle
pathpath handle

void

Since: PV2

defn

canvas-save

(canvas-save [c :int] :void)

push the current drawing state (transform, paint, stroke

Since: PV4

defn

canvas-restore

(canvas-restore [c :int] :void)

pop the most recently saved drawing state.

Since: PV4

defn

canvas-translate

(canvas-translate [c :int tx :float ty :float] :void)

prepend a translation to the current transform.

ccanvas handle
txx offset
tyy offset

Since: PV4

defn

canvas-scale

(canvas-scale [c :int sx :float sy :float] :void)

prepend a scale to the current transform.

Since: PV4

defn

canvas-rotate

(canvas-rotate [c :int radians :float] :void)

prepend a rotation (in radians) to the current transform.

ccanvas handle
radiansrotation angle

Since: PV4

defn

canvas-transform

(canvas-transform [c :int a :float b :float cc :float d :float e :float f :float] :void)

multiply the current transform by a raw 2D matrix.

ccanvas handle
ahorizontal scaling factor
bvertical shear / skew
cchorizontal shear / skew
dvertical scaling factor
ehorizontal translation
fvertical translation

Since: PV4

defn

canvas-reset-transform

(canvas-reset-transform [c :int] :void)

reset the current transform to the identity.

Since: PV4

defn

canvas-set-line-width

(canvas-set-line-width [c :int w :float] :void)

set the stroke width in surface units.

Since: PV4

defn

canvas-set-line-cap

(canvas-set-line-cap [c :int cap :cstr] :void)

set the stroke end-cap style.

ccanvas handle
cap":butt" (default), ":round", or ":square"

Since: PV4

defn

canvas-set-line-join

(canvas-set-line-join [c :int join :cstr] :void)

set the stroke join style.

ccanvas handle
join":miter" (default), ":round", or ":bevel"

Since: PV4

defn

canvas-set-miter-limit

(canvas-set-miter-limit [c :int limit :float] :void)

set the miter-limit ratio for ":miter" joins.

Since: PV4

defn

dash-array-create

(dash-array-create :ptr<void>)

allocate an empty dash-length buffer.

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

Since: PV4

defn

dash-array-add

(dash-array-add [dashes :int length :float] :void)

append a dash-segment length.

Since: PV4

defn

dash-array-count

(dash-array-count [dashes :int] :int)

return the number of dash lengths added.

Since: PV4

defn

dash-array-destroy

(dash-array-destroy [dashes :int] :void)

release a dash-array buffer.

Since: PV4

defn

canvas-set-dash-offset

(canvas-set-dash-offset [c :int offset :float] :void)

set the phase offset into the dash pattern.

Since: PV4

defn

canvas-set-dash-array

(canvas-set-dash-array [c :int dashes :int] :void)

set the dash pattern to the lengths in a

ccanvas handle
dashesdash-array handle (from dash-array-create / dash-array-add)

Since: PV4

defn

canvas-set-fill-rule

(canvas-set-fill-rule [c :int rule :cstr] :void)

set the polygon fill rule for canvas-fill.

ccanvas handle
rule":non-zero" (default) or ":even-odd"

Since: PV4

defn

canvas-set-operator

(canvas-set-operator [c :int op :cstr] :void)

set the Porter-Duff compositing operator.

ccanvas handle
opone of:
":clear" ":src" ":dst" ":src-over" (default)
":dst-over" ":src-in" ":dst-in" ":src-out" ":dst-out"
":src-atop" ":dst-atop" ":xor"

Since: PV4

defn

canvas-set-opacity

(canvas-set-opacity [c :int alpha :float] :void)

set the global opacity multiplier in [0.0, 1.0].

Since: PV4

defn

canvas-arc

(canvas-arc [c :int cx :float cy :float r :float start-angle :float sweep-angle :float] :void)

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

ccanvas handle
cxcenter x
cycenter y
rradius
start-anglestart angle in radians
sweep-angleend angle in radians (interpreted as a0..a1; pass
start + sweep for a "start + delta" shape)
The underlying plutovg API takes a clockwise/counter-clockwise flag;
this binding uses clockwise (`ccw = false`). For counter-clockwise
arcs build the path manually with canvas-arc-to.

Since: PV6

defn

canvas-arc-to

(canvas-arc-to [c :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).

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

Since: PV6

defn

canvas-round-rect

(canvas-round-rect [c :int x :float y :float w :float h :float rx :float ry :float] :void)

append a rounded-corner rectangle subpath.

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

Since: PV6

defn

canvas-draw-image

(canvas-draw-image [c :int src :int x :float y :float w :float h :float] :void)

composite the pixels of `src` onto the canvas,

ccanvas handle
srcsource surface handle
xdestination top-left x
ydestination top-left y
wdestination width
hdestination height

void

Since: PV6

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