#![cfg_attr(not(feature = "std"), no_std)]
#![cfg_attr(docsrs, feature(doc_cfg))]
#![warn(missing_docs)]
#![warn(clippy::all)]
#![allow(clippy::module_inception)]
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;
#[cfg(feature = "text")]
#[cfg_attr(docsrs, doc(cfg(feature = "text")))]
pub use skia_rs_text as text;
#[cfg(feature = "codec")]
#[cfg_attr(docsrs, doc(cfg(feature = "codec")))]
pub use skia_rs_codec as codec;
#[cfg(feature = "svg")]
#[cfg_attr(docsrs, doc(cfg(feature = "svg")))]
pub use skia_rs_svg as svg;
#[cfg(feature = "pdf")]
#[cfg_attr(docsrs, doc(cfg(feature = "pdf")))]
pub use skia_rs_pdf as pdf;
#[cfg(feature = "gpu")]
#[cfg_attr(docsrs, doc(cfg(feature = "gpu")))]
pub use skia_rs_gpu as gpu;
#[cfg(feature = "skottie")]
#[cfg_attr(docsrs, doc(cfg(feature = "skottie")))]
pub use skia_rs_skottie as skottie;
#[cfg(feature = "ffi")]
#[cfg_attr(docsrs, doc(cfg(feature = "ffi")))]
pub use skia_rs_ffi as ffi;
pub mod prelude {
pub use skia_rs_core::{
AlphaType, Color, Color4f, ColorSpace, ColorType, IPoint, IRect, ISize, ImageInfo, Matrix,
Point, Rect, Scalar, Size,
};
pub use skia_rs_path::{FillType, Path, PathBuilder, PathDirection};
pub use skia_rs_paint::{BlendMode, Paint, Style};
pub use skia_rs_canvas::{Canvas, ClipOp, SaveLayerRec, Surface};
pub use skia_rs_safe::prelude::*;
#[cfg(feature = "text")]
#[cfg_attr(docsrs, doc(cfg(feature = "text")))]
pub use skia_rs_text::{Font, FontStyle, TextBlob, Typeface};
#[cfg(feature = "codec")]
#[cfg_attr(docsrs, doc(cfg(feature = "codec")))]
pub use skia_rs_codec::{ImageDecoder, ImageEncoder, ImageFormat};
#[cfg(feature = "svg")]
#[cfg_attr(docsrs, doc(cfg(feature = "svg")))]
pub use skia_rs_svg::SvgDom;
#[cfg(feature = "pdf")]
#[cfg_attr(docsrs, doc(cfg(feature = "pdf")))]
pub use skia_rs_pdf::PdfDocument;
#[cfg(feature = "gpu")]
#[cfg_attr(docsrs, doc(cfg(feature = "gpu")))]
pub use skia_rs_gpu::GpuContext;
#[cfg(feature = "skottie")]
#[cfg_attr(docsrs, doc(cfg(feature = "skottie")))]
pub use skia_rs_skottie::Animation;
}
pub mod version {
pub const MAJOR: u32 = parse_component(env!("CARGO_PKG_VERSION_MAJOR"));
pub const MINOR: u32 = parse_component(env!("CARGO_PKG_VERSION_MINOR"));
pub const PATCH: u32 = parse_component(env!("CARGO_PKG_VERSION_PATCH"));
pub const VERSION: &str = env!("CARGO_PKG_VERSION");
#[inline]
pub const fn as_tuple() -> (u32, u32, u32) {
(MAJOR, MINOR, PATCH)
}
const fn parse_component(s: &str) -> u32 {
let bytes = s.as_bytes();
let mut i = 0;
let mut n: u32 = 0;
while i < bytes.len() {
let b = bytes[i];
assert!(b >= b'0' && b <= b'9', "version component must be decimal");
n = n * 10 + (b - b'0') as u32;
i += 1;
}
n
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_version() {
assert_eq!(version::VERSION, env!("CARGO_PKG_VERSION"));
let parts: Vec<u32> = env!("CARGO_PKG_VERSION")
.split('.')
.map(|p| p.parse().unwrap())
.collect();
assert_eq!(
version::as_tuple(),
(parts[0], parts[1], parts[2])
);
}
#[test]
fn test_core_re_export() {
let point = core::Point::new(10.0, 20.0);
assert_eq!(point.x, 10.0);
assert_eq!(point.y, 20.0);
}
#[test]
fn test_prelude_imports() {
use crate::prelude::*;
let color = Color::RED;
assert_eq!(color.red(), 255);
let rect = Rect::from_xywh(0.0, 0.0, 100.0, 100.0);
assert_eq!(rect.width(), 100.0);
}
}