No matching definitions.

plutovg/paint

src/plutovg/paint.tur
defn

paint-create-color

(paint-create-color [r :float g :float b :float a :float] :ptr<void>)

create a paint with a solid RGBA color.

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

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

(paint-create-color 1.0 0.0 0.0 1.0)  ; opaque red

Since: PV3

defn

paint-create-color-hex

(paint-create-color-hex [hex :cstr] :ptr<void>)

create a paint from a CSS-style color string.

hexcolor string, e.g. "#ff0000", "#ff0000ff", "red", "rgba(...)"

(ok paint-handle) on success; (err 0) if plutovg cannot parse the string.

(paint-create-color-hex "#ff0000")

Since: PV3

defn

paint-destroy

(paint-destroy [paint :int] :void)

release a paint allocated by any paint-create-* call.

paintpaint handle

void

Since: PV3

defn

gradient-stops-create

(gradient-stops-create :ptr<void>)

allocate an empty stops buffer.

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

(let [s (gradient-stops-create)]
    (when (ok? s) (gradient-stops-destroy (ok-val s))))

Since: PV3

defn

gradient-stops-add

(gradient-stops-add [stops :int offset :float r :float g :float b :float a :float] :void)

append a stop to a stops buffer.

stopsstops buffer handle
offsetstop offset in [0.0, 1.0]
r/g/bcolor components in [0.0, 1.0]
aalpha in [0.0, 1.0]

void (the buffer is grown in place if capacity is exceeded; the handle stays valid, but callers must hold the result of any earlier gradient-stops-* call rather than caching the underlying pointer).

(gradient-stops-add s 0.0 1.0 0.0 0.0 1.0)
  (gradient-stops-add s 1.0 0.0 0.0 1.0 1.0)

Since: PV3

defn

gradient-stops-count

(gradient-stops-count [stops :int] :int)

return how many stops have been added.

Since: PV3

defn

gradient-stops-destroy

(gradient-stops-destroy [stops :int] :void)

release a stops buffer.

Since: PV3

defn

paint-create-linear-gradient

(paint-create-linear-gradient [x1 :float y1 :float x2 :float y2 :float spread :cstr stops :int] :ptr<void>)

create a linear-gradient paint.

x1gradient start x
y1gradient start y
x2gradient end x
y2gradient end y
spreadspread keyword ":pad" / ":reflect" / ":repeat"
stopsgradient-stops buffer (must contain at least 2 stops)

(ok paint-handle) on success; (err 0) on allocation failure. The buffer can be freed immediately after the call -- plutovg copies its stops internally.

(let [stops (ok-val (gradient-stops-create))]
    (gradient-stops-add stops 0.0 1.0 0.0 0.0 1.0)
    (gradient-stops-add stops 1.0 0.0 0.0 1.0 1.0)
    (let [p (ok-val (paint-create-linear-gradient 0.0 0.0 100.0 0.0 ":pad" stops))]
      (canvas-set-source c p)
      (gradient-stops-destroy stops)
      (paint-destroy p)))

Since: PV3

defn

paint-create-radial-gradient

(paint-create-radial-gradient [cx :float cy :float cr :float fx :float fy :float fr :float spread :cstr stops :int] :ptr<void>)

create a radial-gradient paint.

cxgradient center x
cygradient center y
crcenter-circle radius
fxfocal point x
fyfocal point y
frfocal-circle radius
spread":pad" / ":reflect" / ":repeat"
stopsgradient-stops buffer

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

Since: PV3

defn

paint-create-texture

(paint-create-texture [surface :int tex-type :cstr opacity :float] :ptr<void>)

create a paint backed by a surface.

surfacesurface handle (from plutovg/surface)
tex-type":plain" (clamp / one-shot) or ":tiled" (repeat)
opacity:float in [0.0, 1.0]

(ok paint-handle) on success; (err 0) on allocation failure. The surface must outlive the paint.

(paint-create-texture s ":plain" 1.0)

Since: PV3

defn

canvas-set-source

(canvas-set-source [c :int paint :int] :void)

set the canvas's current paint.

ccanvas handle
paintpaint handle (any flavour)

void

(canvas-set-source c my-paint)

Since: PV3

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