• Stars
    star
    2,213
  • Rank 19,975 (Top 0.5 %)
  • Language
    Rust
  • License
    Other
  • Created almost 8 years ago
  • Updated 4 months ago

Reviews

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

Repository Details

2D graphics rendering on the GPU in rust using path tessellation.

Lyon

A path tessellation library written in rust for GPU-based 2D graphics rendering.

Project logo

crates.io Build Status documentation Gitter Chat

Motivation

For now the goal is to provide efficient SVG-compliant path tessellation tools to help with rendering vector graphics on the GPU. For now think of this library as a way to turn complex paths into triangles for use in your own rendering engine.

The intent is for this library to be useful in projects like Servo and games.

Example

extern crate lyon;
use lyon::math::point;
use lyon::path::Path;
use lyon::tessellation::*;
fn main() {
    // Build a Path.
    let mut builder = Path::builder();
    builder.begin(point(0.0, 0.0));
    builder.line_to(point(1.0, 0.0));
    builder.quadratic_bezier_to(point(2.0, 0.0), point(2.0, 1.0));
    builder.cubic_bezier_to(point(1.0, 1.0), point(0.0, 1.0), point(0.0, 0.0));
    builder.end(true);
    let path = builder.build();
    // Let's use our own custom vertex type instead of the default one.
    #[derive(Copy, Clone, Debug)]
    struct MyVertex { position: [f32; 2] }
    // Will contain the result of the tessellation.
    let mut geometry: VertexBuffers<MyVertex, u16> = VertexBuffers::new();
    let mut tessellator = FillTessellator::new();
    {
        // Compute the tessellation.
        tessellator.tessellate_path(
            &path,
            &FillOptions::default(),
            &mut BuffersBuilder::new(&mut geometry, |vertex: FillVertex| {
                MyVertex {
                    position: vertex.position().to_array(),
                }
            }),
        ).unwrap();
    }
    // The tessellated geometry is ready to be uploaded to the GPU.
    println!(" -- {} vertices {} indices",
        geometry.vertices.len(),
        geometry.indices.len()
    );
}

FAQ

In a nutshell, what is a tessellator?

Tessellators such as the ones provided by lyon take complex shapes as input and generate geometry made of triangles that can be easily consumed by graphics APIs such as OpenGL, Vulkan or D3D.

How do I render an SVG file with lyon?

Lyon is not an SVG renderer. For now lyon mainly provides primitives to tessellate complex path fills and strokes in a way that is convenient to use with GPU APIs such as gfx-rs, glium, OpenGL, D3D, etc. How the tessellated geometry is rendered is completely up to the user of this crate.

How do I render the output of the tessellators?

Although the format of the output of the tessellators is customizable, the algorithms are designed to generate a vertex and an index buffer. See the lyon::tessellation documentation for more details.

Is anti-aliasing supported?

There is currently no built-in support for antialiasing in the tessellators. Antialiasing can still be achieved by users of this crate using techniques commonly employed in video games (msaa, taa, fxaa, etc.).

I need help!

Don't hesitate to file an issue, ask questions on gitter, or contact @nical by e-mail.

How can I help?

See CONTRIBUTING.md.

License

Licensed under either of

at your option.

Dual MIT/Apache2 is strictly more permissive

Contribution

There is useful information for contributors in the contribution guidelines.

More Repositories

1

guillotiere

A dynamic texture atlas allocator with fast deallocation and rectangle coalescing.
Rust
141
star
2

etagere

Rust
89
star
3

kiwi

Generic pipeline system working with filters and resources that are connected through ports
C++
68
star
4

GLSL-Raymarching

Rendering course project at DTU
C++
33
star
5

parasol

A multi-threaded job scheduler in Rust.
Rust
13
star
6

shared_vector

Efficient reference counted vector data structure is Rust
Rust
12
star
7

rust_debug

Misc debugging utilities.
Rust
9
star
8

notes

Various notes for my own use
9
star
9

misc

Miscellaneous stuff.
Rust
8
star
10

webgl-flares

A 24h long webgl demoscene project
JavaScript
8
star
11

half_edge

A half-edge (doubly connected edge list) data structure in rust
Rust
7
star
12

toy-render-graph

Toy render graph to experiment with various allocation strategies for 2D renderers
Rust
7
star
13

talks

CSS
6
star
14

vodk.rs

Rust experiments, mostly around game programming related stuff.
Rust
5
star
15

texture-atlas

Experimenting with various texture atlas algorithms.
Rust
4
star
16

android_system_properties

A minimal rust wrapper over android system properties
Rust
3
star
17

backup

A simple backup tool in rust using rsync.
Rust
3
star
18

pph

Projet personnel en humanitΓ©s
2
star
19

prettylogs

Small CLI tools to make debugging logs less painfull.
Rust
2
star
20

onGameStart2013

Slides of my talk atonGameStart 2013
CSS
2
star
21

sid

Tiny rust crate providing strongly typed id types and an id-based vector.
Rust
2
star
22

DTU-ComputerGraphics

Computer Graphics course at DTU
C++
2
star
23

mini-task-scheduler

Tiny multi-threaded task scheduler meant to help with rendering we content on multiple threads. May end up in Firefox, or maybe not.
C++
2
star
24

nical.github.io

HTML
2
star
25

rectangle_occlusion

A simple occlusion culling algorithm for opaque and transparent rectangles
Rust
2
star
26

.dotfiles

My config files
Perl
1
star
27

segmented_vec

Experimenting with a semented Vec<T> data structure
Rust
1
star
28

DTU-ConcurrentProgramming

Concurrent programming assignement
Java
1
star
29

vodk

A very small game engine designed to be productive during game jams
C++
1
star
30

resume

My resume
1
star
31

ngf-slides

Slides for my talk at Next Game Frontier
CSS
1
star
32

DTU-school-projetcs

class work at DTU, for Computer Graphics, Rendering, and Concurrent Programming courses
C
1
star
33

tde-data-playground

Data repository for tde.js experiments
GLSL
1
star
34

oldStuff

My old projects
C++
1
star
35

moz-wgpu-update

Scripts to automate the process of updating wgpu in mozilla-central
Rust
1
star
36

dev-tools

A collection of small tools I write to make everyday development and debugging easier/nicer.
D
1
star
37

graphic-works

Some of my drawing/painting/etc. works
1
star