Skip to content

Latest commit

 

History

History
40 lines (36 loc) · 1.16 KB

README.md

File metadata and controls

40 lines (36 loc) · 1.16 KB

2D Rust Graphics Library (Super Simple, Super Efficient)

Render 1M+ 2D shapes, with 240+ FPS

Features

  • Super Simple API
  • Incredibly efficient
  • Render any NGon (Triangle, Rectangle, Pentagon, ... , Circle)
  • CSS like dynamic sizing
  • Text rendering
  • Efficient textured rendering
  • Colored rendering
  • Outline rendering
  • Outline color
  • Outline width
  • Antialiasing
  • Position/Rotation/Scale
  • Dynamic image updates

Example Usage

gfx.color = [255, 255, 255, 255];
gfx.stroke_color = [255, 0, 255, 255];
gfx.stroke_width = 0.3;
gfx.rotation = 3.14 + app.time;
gfx.roundness = 0.2;
gfx.set_image(my_image);
gfx.tri(Pc(0.0), Pc(0.5), Vmin(1.0), Px(64));
gfx.circle(Pc(0.0), Em(1.0), Vmax(0.8));
gfx.update_image_direct(&my_image, |img_data| rand.fill_bytes(img_data));

gfx.weight = 0.5;
gfx.text("Efficient Text Rendering", Vw(0.1), Vh(0.1), Em(1.0));

Renderer Technical Details

  • 2D primitives/shapes are rendered using a single shader for efficiency
  • Font SDF is generated in compute shader using bezier curves directly in 15ms for 96 chars (64x64) on GTX 1060, can be improved, but enough for now
  • Uses WGPU for rendering
  • Uses atlas for textures