RavenRS · Rust GUI

CropOverlay

Edit and run the CropOverlay RavenRS example in your browser. Explore its Rust code and download a Cargo project for desktop and WebAssembly.

One declarative Rust interface, GPU rendering, reactive state and semantic design tokens. Free and open source under MIT OR Apache-2.0.

Rust source

fn crop_overlay() -> impl View {
    let crop = State::new(CropArea::new(Rect::new(70.0, 30.0, 240.0, 150.0)));
    let picture = Canvas::new(|frame, scene| {
        // ravenrs-lint: allow(raw_color) the sky of the stand-in photograph being cropped
        let sky = LinearGradient::vertical(Color::rgb(0.3, 0.45, 0.7), Color::rgb(0.85, 0.6, 0.45));
        scene.push_quad(Quad::new(frame, sky));
    })
    .size(400.0, 220.0);
    VStack::new((
        CropOverlay::new(crop.binding()).stage(picture),
        Protractor::new(crop.binding().map(|c| c.angle, |c, angle| c.angle = angle)).width(400.0),
    ))
    .spacing(8.0)
}

The interactive preview loads when JavaScript and WebGPU or WebGL2 are available. You can read the guide and examples here at any time.

More examples