Files
craft-libs/crates/vectordrawable/src/lib.rs
T
Dylan M. Taylor 81307f8274 Add craft-vectordrawable: Android Vector Drawable writer (#874)
The format half of FigCraft's crates/vectordrawable (at 24cf7032): the
model of paths, groups, clips and gradients, the XML writer, and the
mapping of a gradient on an affine frame to what a drawable can say.
The walk over FigCraft's document, its compatibility modes and warnings
stay in FigCraft.

Part of #778.
2026-11-11 16:23:23 -05:00

24 lines
1.3 KiB
Rust

//! Android Vector Drawable: a `<vector>` XML drawable written from a small model.
//!
//! Written from Android's public `VectorDrawable` documentation (elements `<vector>`, `<group>`,
//! `<path>`, `<clip-path>`, gradients as inline `GradientColor` resources through `aapt:attr`).
//!
//! - [`model`]: what a drawable holds, in viewport coordinates: paths with a solid or gradient
//! fill and a stroke Android draws itself, and groups with a scale-rotate-translate transform
//! and a clip outline.
//! - [`write`]: the XML ([`write::document`]), with its numbers, colours, path data and escaping.
//! - [`paint`]: fitting a gradient drawn through any affine frame to what a drawable can say: a
//! linear gradient's end point projected, radial and sweep gradients in a `<group>` that maps
//! the unit circle, a sweep's stops turned.
//!
//! A drawable has no images, patterns, effects, blend modes, masks, dashes or layer opacity, a
//! `<group>` can only scale, rotate and translate, and a `<path>` has no transform at all. What
//! the caller's document has of those is the caller's to bake in, approximate or leave out
//! before it builds the model. There is no reader.
#![deny(clippy::unwrap_used, clippy::expect_used, clippy::panic, clippy::unimplemented, clippy::todo, clippy::unreachable)]
#![forbid(unsafe_code)]
pub mod model;
pub mod paint;
pub mod write;