motion-core 0.2.0

Backend-independent motion engine primitives
Documentation
//! Logical drawing contracts and bounded rectangle/path fill commands.

mod atmosphere;
mod blend;
mod canvas;
mod clip;
mod command;
mod context;
mod evaluation;
pub mod mesh;
pub mod paint;
mod stroke;

pub use crate::shape::{Shape, Styled};
pub use atmosphere::{AtmosphereKind, AtmospherePaint, AtmosphereParameters};
pub use blend::{BlendMode, BlendSpace, FillRule, MaskMode};
pub use canvas::Canvas;
pub use clip::{ClipGeometry, ClipMode, IntoShapeClip, PathClip, RectClip, ShapeClip};
pub use command::DrawCommand;
pub use context::{DeferredContent, DrawContext, Drawable, RenderQuality};
pub use evaluation::Evaluation;

pub use mesh::{
    MAX_MESH_POINTS_PER_AXIS, MAX_MESH_SUBDIVISIONS, MeshGradient, MeshImage, MeshPaint, MeshPatch,
    MeshVertex,
};
pub use paint::{
    GradientExtend, GradientSpace, GradientUnits, ImagePattern, LinearGradient, Paint,
    PatternImage, RadialGradient, SweepGradient, WeakPatternImage,
};
pub use stroke::{LineCap, LineJoin, MAX_STROKE_VERBS, StrokeStyle};

use std::sync::Arc;

use crate::validation::ValidationState;
use crate::{Path2D, Rect, Transform, ValidationError, ValidationLimits};

/// Rejects nonfinite/inverted corners or nonfinite spans; zero-area rectangles are valid.
pub fn validate_rect(bounds: Rect, path: &str, field: &str) -> Result<(), ValidationError> {
    if !bounds.is_finite()
        || bounds.right < bounds.left
        || bounds.bottom < bounds.top
        || !bounds.width().is_finite()
        || !bounds.height().is_finite()
    {
        return Err(ValidationError::invalid(
            path,
            field,
            "Require finite, noninverted rectangle bounds and finite spans",
        ));
    }
    Ok(())
}

#[cfg(test)]
mod tests;