Skip to content
Rust 2D graphics library
Branch: master
Clone or download
Latest commit 91e2365 Jun 20, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
examples Add 'Spread' to gradients. May 20, 2019
src Fix unused warning Jun 20, 2019
.gitignore Add .gitignore May 10, 2019
.travis.yml Update miri Jun 20, 2019
Cargo.toml Bump version Jun 20, 2019
DESIGN.md Add 'alpha' to DrawOptions. May 19, 2019
LICENSE.md Add a license file. May 11, 2019
README.md Implement extended blend modes Jun 8, 2019
README.tpl Use cargo-readme. May 12, 2019
example.png Update example.png for sw-composite changes Jun 18, 2019
release.toml Fix template... Jun 19, 2019

README.md

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?

Example:

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: 0xff00ff00,
            },
            GradientStop {
                position: 0.8,
                color: 0xffffffff,
            },
            GradientStop {
                position: 1.,
                color: 0xffff00ff,
            },
        ],
    },
    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

You can’t perform that action at this time.