Batched, immutable drawing documents rendered through Skia.
Build a %Skia.Document{} with pipe-friendly commands, then end the pipeline
with a renderer such as to_png/1, to_raw/1, or render/2.
{:ok, png} =
Skia.canvas(800, 600)
|> Skia.clear(:white)
|> Skia.rect(x: 40, y: 40, width: 120, height: 80, fill: :red)
|> Skia.to_png()
Summary
Functions
Adds a arc command to the document.
Creates an empty drawing document.
Adds a circle command to the document.
Adds a clear command to the document.
Adds a clip_circle command to the document.
Adds a clip_path command to the document.
Adds a clip_rect command to the document.
Returns normalized commands in render order.
Adds a concat command to the document.
Adds a saved canvas group with optional transforms.
Adds a image command to the document.
Adds a saved layer with optional opacity.
Adds a line command to the document.
Measures text using the native text engine.
Adds a oval command to the document.
Adds a path command to the document.
Adds a path_op command to the document.
Adds a path_outline command to the document.
Adds a picture command to the document.
Records the document into a reusable Skia picture.
Adds a rect command to the document.
Renders the document according to Skia.RenderOptions.
Adds a rotate_at command to the document.
Adds a scale command to the document.
Adds a style scope for following commands in the group.
Adds text with optional %Skia.TextStyle{} and %Skia.ParagraphStyle{} values.
Adds a text_blob command to the document.
Encodes the document to the term batch a native renderer would consume.
Renders the document to JPEG through the native renderer.
Renders the document to PNG through the native renderer.
Renders the document to a raw RGBA buffer.
Renders the document to WEBP through the native renderer.
Validates the document before handing it to native code.
Adds a vertices command to the document.
Types
@type document() :: Skia.Document.t()
Functions
@spec arc( Skia.Document.t(), keyword() ) :: Skia.Document.t()
Adds a arc command to the document.
@spec canvas(pos_integer(), pos_integer()) :: Skia.Document.t()
Creates an empty drawing document.
@spec circle( Skia.Document.t(), keyword() ) :: Skia.Document.t()
Adds a circle command to the document.
@spec clear(Skia.Document.t(), term(), keyword()) :: Skia.Document.t()
Adds a clear command to the document.
@spec clip_circle( Skia.Document.t(), keyword() ) :: Skia.Document.t()
Adds a clip_circle command to the document.
@spec clip_path(Skia.Document.t(), term(), keyword()) :: Skia.Document.t()
Adds a clip_path command to the document.
@spec clip_rect( Skia.Document.t(), keyword() ) :: Skia.Document.t()
Adds a clip_rect command to the document.
@spec commands(Skia.Document.t()) :: [Skia.Command.t()]
Returns normalized commands in render order.
@spec concat( Skia.Document.t(), keyword() ) :: Skia.Document.t()
Adds a concat command to the document.
@spec group(Skia.Document.t(), keyword(), (Skia.Document.t() -> Skia.Document.t())) :: Skia.Document.t()
Adds a saved canvas group with optional transforms.
@spec image(Skia.Document.t(), term(), keyword()) :: Skia.Document.t()
Adds a image command to the document.
@spec layer(Skia.Document.t(), keyword(), (Skia.Document.t() -> Skia.Document.t())) :: Skia.Document.t()
Adds a saved layer with optional opacity.
@spec line( Skia.Document.t(), keyword() ) :: Skia.Document.t()
Adds a line command to the document.
@spec measure_text( String.t(), keyword() ) :: {:ok, %{width: float(), bounds: {float(), float(), float(), float()}}} | {:error, atom()}
Measures text using the native text engine.
@spec oval( Skia.Document.t(), keyword() ) :: Skia.Document.t()
Adds a oval command to the document.
@spec path(Skia.Document.t(), term(), keyword()) :: Skia.Document.t()
Adds a path command to the document.
@spec path_op(Skia.Document.t(), term(), term(), keyword()) :: Skia.Document.t()
Adds a path_op command to the document.
@spec path_outline(Skia.Document.t(), term(), keyword()) :: Skia.Document.t()
Adds a path_outline command to the document.
@spec picture(Skia.Document.t(), term(), keyword()) :: Skia.Document.t()
Adds a picture command to the document.
@spec record_picture(Skia.Document.t()) :: {:ok, Skia.Picture.t()} | {:error, atom(), map()}
Records the document into a reusable Skia picture.
@spec rect( Skia.Document.t(), keyword() ) :: Skia.Document.t()
Adds a rect command to the document.
@spec render(Skia.Document.t(), keyword() | Skia.RenderOptions.t()) :: {:ok, binary() | map()} | {:error, atom(), map()}
Renders the document according to Skia.RenderOptions.
@spec rotate_at( Skia.Document.t(), keyword() ) :: Skia.Document.t()
Adds a rotate_at command to the document.
@spec scale( Skia.Document.t(), keyword() ) :: Skia.Document.t()
Adds a scale command to the document.
@spec style(Skia.Document.t(), keyword(), (Skia.Document.t() -> Skia.Document.t())) :: Skia.Document.t()
Adds a style scope for following commands in the group.
@spec text(Skia.Document.t(), String.t(), keyword()) :: Skia.Document.t()
Adds text with optional %Skia.TextStyle{} and %Skia.ParagraphStyle{} values.
@spec text_blob(Skia.Document.t(), term(), keyword()) :: Skia.Document.t()
Adds a text_blob command to the document.
@spec to_batch(Skia.Document.t()) :: %{ width: pos_integer(), height: pos_integer(), commands: [Skia.Command.t()] }
Encodes the document to the term batch a native renderer would consume.
@spec to_jpeg( Skia.Document.t(), keyword() ) :: {:ok, binary()} | {:error, atom(), map()}
Renders the document to JPEG through the native renderer.
@spec to_png(Skia.Document.t()) :: {:ok, binary()} | {:error, atom(), map()}
Renders the document to PNG through the native renderer.
@spec to_raw(Skia.Document.t()) :: {:ok, %{ width: pos_integer(), height: pos_integer(), stride: pos_integer(), data: binary() }} | {:error, atom(), map()}
Renders the document to a raw RGBA buffer.
@spec to_webp( Skia.Document.t(), keyword() ) :: {:ok, binary()} | {:error, atom(), map()}
Renders the document to WEBP through the native renderer.
@spec validate(Skia.Document.t()) :: :ok | {:error, atom(), map()}
Validates the document before handing it to native code.
@spec vertices(Skia.Document.t(), term(), keyword()) :: Skia.Document.t()
Adds a vertices command to the document.