No matching definitions.

plutovg/surface

src/plutovg/surface.tur
defn

surface-create

(surface-create [width :int height :int] :ptr<void>)

allocate a new premultiplied-ARGB pixel buffer.

widthsurface width in pixels
heightsurface height in pixels

(ok handle) on success; (err 0) if plutovg refuses the dimensions. Free with surface-destroy when done.

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

Since: PV0

defn

surface-create-from-data

(surface-create-from-data [data :cstr width :int height :int stride :int] :ptr<void>)

wrap an existing pixel buffer as a surface.

datapointer to existing premultiplied-ARGB bytes (:cstr)
widthsurface width in pixels
heightsurface height in pixels
stridebytes per row (typically width * 4)

(ok handle) on success; (err 0) on failure. The buffer is NOT owned by the returned surface; the caller must keep it alive until the surface is destroyed.

(surface-create-from-data buf 64 64 (* 64 4))

Since: PV0

defn

surface-destroy

(surface-destroy [s :int] :void)

release a surface allocated by surface-create.

ssurface handle (ok-val from surface-create)

void

(surface-destroy s)

Since: PV0

defn

surface-width

(surface-width [s :int] :int)

return the width of a surface in pixels.

ssurface handle

Width as :int.

(println (surface-width s))

Since: PV0

defn

surface-height

(surface-height [s :int] :int)

return the height of a surface in pixels.

ssurface handle

Height as :int.

(println (surface-height s))

Since: PV0

defn

surface-stride

(surface-stride [s :int] :int)

return the row stride of a surface in bytes.

ssurface handle

Bytes per row as :int. For surfaces allocated by surface-create this is always width * 4.

(println (surface-stride s))

Since: PV0

defn

surface-data

(surface-data [s :int] :cstr)

return a raw pointer to the surface pixel buffer.

ssurface handle

Pointer to the pixel buffer as :cstr. Pixels are stored as 32-bit premultiplied ARGB (0xAARRGGBB); on a little-endian host the byte order in memory is B, G, R, A.

(let [buf (surface-data s)] ...)

Since: PV0

defn

surface-write-png

(surface-write-png [s :int path :cstr] :ptr<void>)

write the surface to a PNG file.

ssurface handle
pathdestination filesystem path

(ok 0) on success; (err 0) if plutovg could not write the file.

(let [r (surface-write-png s "out.png")]
    (if (ok? r) (println "written") (println "failed")))

Since: PV6

defn

surface-write-jpeg

(surface-write-jpeg [s :int path :cstr quality :int] :ptr<void>)

write the surface to a JPEG file.

ssurface handle
pathdestination filesystem path
qualityJPEG quality in [0, 100]; 90 is a good default

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

(surface-write-jpeg s "out.jpg" 90)

Since: PV6

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