Skia.Picture (Skia v0.1.1)

Copy Markdown View Source

Recorded Skia picture resource.

Pictures store reusable drawing subtrees. Record a document once, replay it as a draw command, serialize it, or turn it into an image/shader.

{:ok, picture} = Skia.Picture.record(document)
{:ok, bytes} = Skia.Picture.encode(picture)
{:ok, picture} = Skia.Picture.decode(bytes, width: 64, height: 64)

Summary

Types

cull_rect()

@type cull_rect() :: {float(), float(), float(), float()}

t()

@type t() :: %Skia.Picture{
  height: pos_integer(),
  ref: reference(),
  width: pos_integer()
}

Functions

decode(bytes, opts)

@spec decode(
  binary(),
  keyword()
) :: {:ok, t()} | {:error, atom()}

decode(bytes, width, height)

@spec decode(binary(), pos_integer(), pos_integer()) :: {:ok, t()} | {:error, atom()}

encode(picture)

@spec encode(t()) :: {:ok, binary()} | {:error, atom()}

height(picture)

@spec height(t()) :: pos_integer()

info(picture)

@spec info(t()) ::
  {:ok,
   %{
     cull_rect: cull_rect(),
     op_count: non_neg_integer(),
     nested_op_count: non_neg_integer(),
     bytes_used: non_neg_integer()
   }}
  | {:error, atom()}

record(document)

@spec record(Skia.Document.t()) :: {:ok, t()} | {:error, atom(), map()}

width(picture)

@spec width(t()) :: pos_integer()