https://github.com/sammycage/plutovg
Tiny 2D vector graphics library in C
https://github.com/sammycage/plutovg
2d c canvas graphics plutovg svg vector
Last synced: 4 months ago
JSON representation
Tiny 2D vector graphics library in C
- Host: GitHub
- URL: https://github.com/sammycage/plutovg
- Owner: sammycage
- License: mit
- Created: 2020-11-07T17:14:29.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2025-07-22T07:49:41.000Z (5 months ago)
- Last Synced: 2025-07-22T08:50:40.649Z (5 months ago)
- Topics: 2d, c, canvas, graphics, plutovg, svg, vector
- Language: C
- Homepage:
- Size: 530 KB
- Stars: 434
- Watchers: 16
- Forks: 43
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
- awesome-c-zh - PlutoVG - 一个独立的二维矢量图形库在C[](https://spdx.org/licenses/MIT.html) (图形)
- awesomecpp - PlutoVG - - standalone 2D vector graphics library in C. (Graphics)
- awesome-c - PlutoVG - A standalone 2D vector graphics library in C [MIT](https://spdx.org/licenses/MIT.html) (Graphics)
- awesome-2d-graphics-rendering - plutovg
README
[](https://github.com/sammycage/plutovg/actions)
[](https://github.com/sammycage/plutovg/blob/main/LICENSE)
[](https://github.com/sammycage/plutovg/releases)
[](https://www.codefactor.io/repository/github/sammycage/plutovg)
# PlutoVG
PlutoVG is a standalone 2D vector graphics library in C.
## Features
- Path Filling, Stroking and Dashing
- Solid, Gradient and Texture Paints
- Fonts and Texts
- Clipping and Compositing
- Transformations
- Images
## Example
```c
#include
int main(void)
{
const int width = 150;
const int height = 150;
const float center_x = width / 2.f;
const float center_y = height / 2.f;
const float face_radius = 70;
const float mouth_radius = 50;
const float eye_radius = 10;
const float eye_offset_x = 25;
const float eye_offset_y = 20;
const float eye_x = center_x - eye_offset_x;
const float eye_y = center_y - eye_offset_y;
plutovg_surface_t* surface = plutovg_surface_create(width, height);
plutovg_canvas_t* canvas = plutovg_canvas_create(surface);
plutovg_canvas_save(canvas);
plutovg_canvas_arc(canvas, center_x, center_y, face_radius, 0, PLUTOVG_TWO_PI, 0);
plutovg_canvas_set_rgb(canvas, 1, 1, 0);
plutovg_canvas_fill_preserve(canvas);
plutovg_canvas_set_rgb(canvas, 0, 0, 0);
plutovg_canvas_set_line_width(canvas, 5);
plutovg_canvas_stroke(canvas);
plutovg_canvas_restore(canvas);
plutovg_canvas_save(canvas);
plutovg_canvas_arc(canvas, eye_x, eye_y, eye_radius, 0, PLUTOVG_TWO_PI, 0);
plutovg_canvas_arc(canvas, center_x + eye_offset_x, eye_y, eye_radius, 0, PLUTOVG_TWO_PI, 0);
plutovg_canvas_set_rgb(canvas, 0, 0, 0);
plutovg_canvas_fill(canvas);
plutovg_canvas_restore(canvas);
plutovg_canvas_save(canvas);
plutovg_canvas_arc(canvas, center_x, center_y, mouth_radius, 0, PLUTOVG_PI, 0);
plutovg_canvas_set_rgb(canvas, 0, 0, 0);
plutovg_canvas_set_line_width(canvas, 5);
plutovg_canvas_stroke(canvas);
plutovg_canvas_restore(canvas);
plutovg_surface_write_to_png(surface, "smiley.png");
plutovg_canvas_destroy(canvas);
plutovg_surface_destroy(surface);
return 0;
}
```
output:

## Installation
Follow the steps below to install PlutoVG using either [Meson](https://mesonbuild.com/) or [CMake](https://cmake.org/).
### Using Meson
```bash
git clone https://github.com/sammycage/plutovg.git
cd plutovg
meson setup build
meson compile -C build
meson install -C build
```
### Using CMake
```bash
git clone https://github.com/sammycage/plutovg.git
cd plutovg
cmake -B build .
cmake --build build
cmake --install build
```
## Projects using PlutoVG
- [LunaSVG](https://github.com/sammycage/lunasvg)
- [PlutoSVG](https://github.com/sammycage/plutosvg)