40 releases

new 0.8.4 Apr 11, 2024
0.8.3 Sep 15, 2023
0.8.2 Jan 19, 2023
0.8.1 Jul 22, 2022
0.6.1 Jul 23, 2019

#15 in Graphics APIs

Download history 941/week @ 2023-12-23 1213/week @ 2023-12-30 1319/week @ 2024-01-06 1470/week @ 2024-01-13 1789/week @ 2024-01-20 1367/week @ 2024-01-27 1259/week @ 2024-02-03 1576/week @ 2024-02-10 1619/week @ 2024-02-17 1809/week @ 2024-02-24 2325/week @ 2024-03-02 2499/week @ 2024-03-09 2674/week @ 2024-03-16 2661/week @ 2024-03-23 1966/week @ 2024-03-30 1429/week @ 2024-04-06

9,198 downloads per month
Used in 33 crates (18 directly)

BSD-3-Clause

160KB
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

~2–11MB
~86K SLoC