Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

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: about 1 month ago
JSON representation

Tiny 2D vector graphics library in C

Lists

README

        

# PlutoVG
PlutoVG is a standalone 2D vector graphics library in C.

## Features
- Path Filling, Stroking and Dashing
- Soild, Gradient and Texture Paints
- Clipping and Compositing
- Transformations

## Example
```c

#include "plutovg.h"

int main(void)
{
const int width = 150;
const int height = 150;

plutovg_surface_t* surface = plutovg_surface_create(width, height);
plutovg_t* pluto = plutovg_create(surface);

double center_x = width * 0.5;
double center_y = height * 0.5;
double face_radius = 70;
double eye_radius = 10;
double mouth_radius = 50;
double eye_offset_x = 25;
double eye_offset_y = 20;
double eye_x = center_x - eye_offset_x;
double eye_y = center_y - eye_offset_y;

const double pi = 3.14159265358979323846;

plutovg_save(pluto);
plutovg_arc(pluto, center_x, center_y, face_radius, 0, 2 * pi, 0);
plutovg_set_rgb(pluto, 1, 1, 0);
plutovg_fill_preserve(pluto);
plutovg_set_rgb(pluto, 0, 0, 0);
plutovg_set_line_width(pluto, 5);
plutovg_stroke(pluto);
plutovg_restore(pluto);

plutovg_save(pluto);
plutovg_arc(pluto, eye_x, eye_y, eye_radius, 0, 2 * pi, 0);
plutovg_arc(pluto, center_x + eye_offset_x, eye_y, eye_radius, 0, 2 * pi, 0);
plutovg_fill(pluto);
plutovg_restore(pluto);

plutovg_save(pluto);
plutovg_arc(pluto, center_x, center_y, mouth_radius, 0, pi, 0);
plutovg_set_line_width(pluto, 5);
plutovg_stroke(pluto);
plutovg_restore(pluto);

plutovg_surface_write_to_png(surface, "smiley.png");
plutovg_surface_destroy(surface);
plutovg_destroy(pluto);

return 0;
}
```

output :

![smiley.png](smiley.png)

## Build
Install [cmake](https://cmake.org/download/) if not already installed

```
mkdir build
cd build
cmake ..
make
```

## Projects using PlutoVG
- [LunaSVG](https://github.com/sammycage/lunasvg)
- [PlutoSVG](https://github.com/sammycage/plutosvg)

## Support
If you like what we do, [you can buy us a coffee](https://www.paypal.me/sammycage)