Skip to main content

Crate skia_rs

Crate skia_rs 

Source
Expand description

§skia-rs

A pure Rust implementation of Google’s Skia 2D graphics library.

This crate provides a comprehensive 2D graphics API for rendering shapes, images, text, and more. It is designed to be a drop-in replacement for the original Skia library while providing a safe, idiomatic Rust API.

§Quick Start

use skia_rs::prelude::*;

// Create a surface to draw on
let mut surface = Surface::new_raster_n32_premul(800, 600).unwrap();
let mut canvas = surface.canvas();

// Create a paint for styling
let mut paint = Paint::default();
paint.set_color(Color::RED.into());
paint.set_anti_alias(true);

// Draw a circle
canvas.draw_circle(Point::new(400.0, 300.0), 100.0, &paint);

§Feature Flags

This crate uses feature flags to control which components are included:

  • default = ["std", "codec", "svg"] - Standard features for most use cases
  • std - Standard library support (disable for no_std environments)
  • serde - Serialization support via serde

§Image Codecs

  • codec - Base image codec support
  • codec-png - PNG encoding/decoding
  • codec-jpeg - JPEG encoding/decoding
  • codec-webp - WebP encoding/decoding
  • codec-gif - GIF decoding
  • codec-avif - AVIF encoding/decoding
  • codec-raw - RAW image processing
  • codec-all - All image codecs

§Specialized Modules

  • svg - SVG parsing and rendering
  • pdf - PDF document generation
  • text - Advanced text rendering and shaping
  • skottie - Lottie animation support

§GPU Backends

  • gpu - Base GPU support
  • vulkan - Vulkan backend
  • opengl - OpenGL backend
  • metal - Metal backend (macOS/iOS only)
  • wgpu-backend / webgpu - wgpu backend (cross-platform)

§FFI

  • ffi - C FFI bindings for interoperability

§Full Features

  • full - Enables all features except platform-specific GPU backends

§Module Organization

  • core - Fundamental types: Scalar, Point, Rect, Color, Matrix
  • path - Path geometry: Path, PathBuilder, PathOps, PathEffect
  • paint - Styling: Paint, Shader, BlendMode, Filter
  • canvas - Drawing: Canvas, Surface, Picture
  • safe - High-level ergonomic API (recommended for most users)

Optional modules (enabled via features):

  • text - Typography: font loading, text shaping, layout
  • codec - Image I/O: PNG, JPEG, GIF, WebP, AVIF
  • svg - SVG parsing and rendering
  • pdf - PDF document generation
  • gpu - GPU rendering backends
  • skottie - Lottie/Skottie animation
  • ffi - C FFI bindings

Re-exports§

pub use skia_rs_core as core;
pub use skia_rs_path as path;
pub use skia_rs_paint as paint;
pub use skia_rs_canvas as canvas;
pub use skia_rs_safe as safe;
pub use skia_rs_text as text;text
pub use skia_rs_codec as codec;codec
pub use skia_rs_svg as svg;svg
pub use skia_rs_pdf as pdf;pdf
pub use skia_rs_gpu as gpu;gpu
pub use skia_rs_skottie as skottie;skottie
pub use skia_rs_ffi as ffi;ffi

Modules§

prelude
Prelude module for convenient imports.
version
Version information for the skia-rs library.