Skip to main content

try_camera

Function try_camera 

Source
pub fn try_camera(
    context: &SceneContext<'_>,
    content: impl Into<Node>,
    view: Camera,
) -> Result<Node, ValidationError>
Expand description

Applies the inverse view to a subtree, not to subsequent HUD nodes. No font discovery, old layers, new node kind or implicit viewport clip is added.

use motion_core::prelude::*;
use motion_core::{
    DisplayList, RasterLimits, ResourceStore, ValidatedDisplayList, MAX_PATH_VERBS,
    MAX_STROKE_VERBS, MAX_SVG_PATH_BYTES, sample_offsets,
};
let cache = SceneCache::new(0);
let context = SceneContext::new(Time::ZERO, fps!(30), Size::new(8.0, 8.0), &cache);
let view = Camera {
    center: Point::new(10.0, 5.0),
    zoom: 2.0,
    rotation: 0.0,
};
let node = camera(
    &context,
    Rect::new(9.0, 4.0, 11.0, 6.0).fill(Color::WHITE),
    view,
);
assert_eq!(
    view.world_to_screen(&context, view.center)?,
    context.center()
);
node.compile(
    context.size(),
    PixelSize::new(8, 8),
    ValidationLimits::default(),
)?;