raqote

Build Status Crates.io Documentation

A pure Rust 2D Graphics Library.

Raqote aims to be a small, simple, fast software 2D graphics library with roughly the same capabilities as the cairo image backend.

Current functionality - path filling - stroking - dashing - image, solid, and gradient fills - rectangular and path clipping - blend modes - layers - repeat modes for images - global alpha

Planned functionality - perspective image drawing - shadows?

Notable users

Example:

```rust use raqote::*;

let mut dt = DrawTarget::new(400, 400);

let mut pb = PathBuilder::new(); pb.moveto(100., 10.); pb.cubicto(150., 40., 175., 0., 200., 10.); pb.quadto(120., 100., 80., 200.); pb.quadto(150., 180., 300., 300.); pb.close(); let path = pb.finish();

let gradient = Source::newradialgradient( Gradient { stops: vec![ GradientStop { position: 0.2, color: Color::new(0xff, 0, 0xff, 0), }, GradientStop { position: 0.8, color: Color::new(0xff, 0xff, 0xff, 0xff), }, GradientStop { position: 1., color: Color::new(0xff, 0xff, 0, 0xff), }, ], }, Point::new(150., 150.), 128., Spread::Pad, ); dt.fill(&path, &gradient, &DrawOptions::new());

let mut pb = PathBuilder::new(); pb.moveto(100., 100.); pb.lineto(300., 300.); pb.line_to(200., 300.); let path = pb.finish();

dt.stroke( &path, &Source::Solid(SolidSource { r: 0x0, g: 0x0, b: 0x80, a: 0x80, }), &StrokeStyle { cap: LineCap::Round, join: LineJoin::Round, width: 10., miterlimit: 2., dasharray: vec![10., 18.], dash_offset: 16., }, &DrawOptions::new() );

dt.write_png("example.png"); ```

Produces:

example.png