• Stars
    star
    819
  • Rank 55,659 (Top 2 %)
  • Language
    Rust
  • License
    BSD 3-Clause "New...
  • Created over 5 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Rust 2D graphics library

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

More Repositories

1

pdf-extract

A rust library for extracting content from pdfs
Rust
224
star
2

memcpy-find

A tool for finding large memcpy's in llvm ir
C++
54
star
3

pyunum

Python port of the Mathematica unum prototype from "The End of Error"
Python
52
star
4

rr-dataflow

An 'origin' command that continue to the origin of a piece of data in rr
Python
47
star
5

qcms

qcms
C
38
star
6

bnetd

C
32
star
7

mozilla-cvs-history

C++
31
star
8

kemufuzzer

Automatically exported from code.google.com/p/kemufuzzer
Diff
28
star
9

glsl-to-spirv

A glsl to spirv compiler
Rust
21
star
10

full-scene-rasterizer

Full-scene rasterizer
C++
20
star
11

ssim

A standalone tool for measuring SSIM
C
14
star
12

GLZA

A repository of Kennon Conrad's GLZA compressor releases
C
10
star
13

ogl-sample

C
10
star
14

minpng

A simple header that implements a png encoder
C
9
star
15

raqote-examples

8
star
16

gpu-db

JSON files to classify GPUs into different generations and chips
Python
8
star
17

http-recording-proxy

A proxy for recording and replaying http traces
Python
8
star
18

about-jank

Find the jank
JavaScript
8
star
19

etw-profiler

Rust
8
star
20

cg-debug

Something like Quartz Debug
C++
7
star
21

statprof.py

A port of Andy Wingo's statprof.py to newer python by Alex Fraser
Python
6
star
22

libunwind

C
6
star
23

sw-composite

Some software compositing routines in rust
Rust
6
star
24

KStack

Grabbing Kernel Stacks
C++
5
star
25

rubi

Rubi rules by Albert D. Rich
MATLAB
5
star
26

qpdf.js

JavaScript
4
star
27

rust-lzo

A pure rust implementation of lzo converted from Linux's C implementation using corrode
Rust
4
star
28

cc-mt

Rust
3
star
29

deadlock-rs

Static deadlock prevention
Rust
3
star
30

sw-wr

A software renderer for WebRender
Rust
3
star
31

fslogger

C
3
star
32

glsl-to-cxx

Rust
3
star
33

bincode-size

Rust
3
star
34

client-storage-rs

Client storage experiments
Rust
3
star
35

pdb-downloader

Download pdb's using rust
Rust
3
star
36

clangxr-experiments

C++
2
star
37

git-browse

A handy tool for browsing the history of a file
Python
2
star
38

path64-compiler

C
2
star
39

build-parallel

Do things in a parallel in build.rs using the jobserver
Rust
2
star
40

frame-timing

A fork of PresentMon that does frame timing
C++
2
star
41

rezip

Recompressor for deflate/gzip streams
C
2
star
42

png2txt

Convert a png file to textual description of the pixels
C
2
star
43

carenderer-yuv

Objective-C++
1
star
44

premultiply-rs

Rust
1
star
45

profile-store

profile store
Python
1
star
46

cache-map

C++
1
star
47

shader-time

Rust
1
star
48

adobe-cmap-parser

A rust library to parse Adobe CMap files
Rust
1
star
49

type1-encoding-parser

Rust
1
star
50

canvas2webgl

Draw the contents of a 2D canvas with WebGL
JavaScript
1
star
51

tracedump

Dump information about GPUView ETW traces
C++
1
star
52

mach-ipc-bench

Timing synchronous mach_msgs
C
1
star
53

cjpeg.js

JavaScript
1
star
54

image-scaling

Emscripten high quality image scaling
C++
1
star
55

glitter-paths

Glitter-paths is a stand alone polygon rasteriser derived from David Turner's reimplementation of Tor Anderssons's 15x17 supersampling rasteriser from the Apparition graphics library
C
1
star
56

glsl-cpu

GLSL
1
star
57

pixman-scaler

C
1
star
58

sha1trunc

A simple header that implements sha1
C
1
star
59

inverse-elliptic

C
1
star
60

pcode

Documentation for Microsoft C++ 7.0 P-Code
1
star
61

perf-convert

Convert perf profiles into perf-html.io profiles
Perl
1
star
62

thread-timings

Rust
1
star
63

cpu-features

crash stats cpu features querying
Python
1
star
64

concurrency-visualizer-scripts

Concurrency Visualizer Scripts
Python
1
star
65

profile-logs

Python
1
star
66

d3d-11-shared-surfaces

C++
1
star