36 releases

✓ Uses Rust 2018 edition

0.8.0 May 29, 2020
0.7.14 Mar 13, 2020
0.7.13 Feb 25, 2020
0.7.7 Dec 19, 2019
0.6.1 Jul 23, 2019

#14 in Graphics APIs

Download history 1204/week @ 2020-03-25 867/week @ 2020-04-01 1019/week @ 2020-04-08 1352/week @ 2020-04-15 1186/week @ 2020-04-22 1389/week @ 2020-04-29 1274/week @ 2020-05-06 1822/week @ 2020-05-13 933/week @ 2020-05-20 2148/week @ 2020-05-27 2132/week @ 2020-06-03 2330/week @ 2020-06-10 1783/week @ 2020-06-17 1905/week @ 2020-06-24 1658/week @ 2020-07-01 1374/week @ 2020-07-08

4,922 downloads per month
Used in 21 crates (6 directly)

BSD-3-Clause and maybe MPL-2.0

155KB
3.5K SLoC

raqote

Build Status Crates.io Documentation

A pure Rust 2D Graphics Library.

Raqote is a small, simple, fast software 2D graphics library.

Current functionality

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

Notable users

  • resvg supports using raqote as a backend.
  • Servo uses raqote as its canvas backend.
  • orbtk uses raqote.

Example:

A simple example drawing to a window

Another example drawing to a png follows:

use raqote::*;

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

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

let gradient = Source::new_radial_gradient(
    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.move_to(100., 100.);
pb.line_to(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.,
        miter_limit: 2.,
        dash_array: vec![10., 18.],
        dash_offset: 16.,
    },
    &DrawOptions::new()
);

dt.write_png("example.png");

Produces:

example.png

Dependencies

~1.2–3MB
~65K SLoC