pub struct ShapeClip {
pub geometry: ClipGeometry,
pub transform: Transform,
pub rule: FillRule,
}Expand description
A snapshotted Shape used for geometric intersection, not coverage multiplication.
Fields§
§geometry: ClipGeometrySnapshot of the local clipping geometry, not a bounding-box substitute.
transform: TransformLocal mapping in authoring, device mapping in a DisplayList.
rule: FillRuleInterior interpretation of this shape independently of its ancestors.
Implementations§
Source§impl ShapeClip
impl ShapeClip
Sourcepub fn new(shape: &(impl Shape + ?Sized)) -> Result<Self, ValidationError>
pub fn new(shape: &(impl Shape + ?Sized)) -> Result<Self, ValidationError>
Captures a shape once; trait objects are accepted without retaining them.
Exact rectangles retain raw bounds so invalid rectangles fail validation with the clip. Other shapes share a checked path and report its errors.
use motion_core::prelude::*;
use motion_core::{
DisplayList, RasterLimits, ResourceStore, ValidatedDisplayList, MAX_PATH_VERBS,
MAX_STROKE_VERBS, MAX_SVG_PATH_BYTES, sample_offsets,
};
let path = Path2D::from_rect(Rect::new(0.0, 0.0, 1.0, 1.0))?;
let shape: &dyn Shape = &path;
let mut clip = ShapeClip::new(shape)?;
clip.rule = FillRule::EvenOdd;
clip.transform = Transform::translate(0.5, 0.0);
let frame = Node::from(Rect::new(0.0, 0.0, 2.0, 1.0).fill(Color::WHITE))
.clip_with(clip, motion_core::ClipMode::Geometric)
.compile(
Size::new(2.0, 1.0),
PixelSize::new(2, 1),
ValidationLimits::default(),
)?;Trait Implementations§
Source§impl IntoShapeClip for ShapeClip
impl IntoShapeClip for ShapeClip
Source§fn into_shape_clip(self) -> Result<ShapeClip, ValidationError>
fn into_shape_clip(self) -> Result<ShapeClip, ValidationError>
Captures the clip geometry, reporting invalid shapes.
impl StructuralPartialEq for ShapeClip
Auto Trait Implementations§
impl Forget for ShapeClip
impl Freeze for ShapeClip
impl Move for ShapeClip
impl RefUnwindSafe for ShapeClip
impl Send for ShapeClip
impl Sync for ShapeClip
impl Unpin for ShapeClip
impl UnsafeUnpin for ShapeClip
impl UnwindSafe for ShapeClip
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more