Tiny 2D vector graphics library in C
  • C 99.2%
  • CMake 0.5%
  • Meson 0.3%
Find a file
Samuel Ugochukwu dd73459d66
Merge pull request #81 from iliaal/fix-linux-limits-musl
Use <limits.h> for PATH_MAX instead of <linux/limits.h>
2026-06-06 06:33:48 +01:00
.github Update FUNDING.yml 2025-06-03 20:11:06 +01:00
cmake plutovgConfig.cmake.in 2025-09-18 14:56:53 +03:00
examples cmake, meson: tweak disabling examples' build for rimage-write option: 2026-05-30 22:20:37 +03:00
include Release v1.3.3 2026-05-18 05:56:54 +01:00
source Use <limits.h> for PATH_MAX instead of <linux/limits.h> 2026-06-05 06:58:59 -04:00
.gitignore Update codebase for initial release 2024-06-29 20:55:28 +01:00
CMakeLists.txt cmake, meson: tweak disabling examples' build for rimage-write option: 2026-05-30 22:20:37 +03:00
LICENSE Update copyright year to 2026 2026-01-08 10:05:04 +01:00
meson.build cmake, meson: tweak disabling examples' build for rimage-write option: 2026-05-30 22:20:37 +03:00
meson_options.txt add image write option to build system after PR/75. 2026-05-30 20:14:50 +03:00
README.md Release v1.2.0 2025-07-14 10:34:04 +01:00
smiley.png Fix 2022-11-18 18:35:22 +01:00

Actions License Releases CodeFactor

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

#include <plutovg.h>

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:

smiley.png

Installation

Follow the steps below to install PlutoVG using either Meson or CMake.

Using Meson

git clone https://github.com/sammycage/plutovg.git
cd plutovg
meson setup build
meson compile -C build
meson install -C build

Using CMake

git clone https://github.com/sammycage/plutovg.git
cd plutovg
cmake -B build .
cmake --build build
cmake --install build

Projects using PlutoVG