sammycage/lunasvg logo

sammycage/lunasvg

Free

SVG rendering and manipulation library in C++

FreeFree tier
Type
Open Source

About sammycage/lunasvg

LunaSVG is a lightweight and portable SVG rendering and manipulation library written in C++. It provides efficient rendering of Scalable Vector Graphics (SVG) files, supporting dynamic styling via CSS-like stylesheets, element hit testing, and bitmap output to PNG. Designed for integration into C++ applications, it offers a simple API for loading SVG from files or data strings, applying styles, and rendering to bitmaps.

Key Features

Efficient SVG rendering and manipulation in C++
Lightweight and portable design
Dynamic styling via CSS-like stylesheets
Hit testing on SVG elements using elementFromPoint
Load SVG from files or data strings
Render SVG to bitmap and export as PNG

Pros & Cons

Pros
  • Lightweight and easy to integrate
  • Portable across platforms
  • Supports dynamic styling with CSS
  • Provides hit testing for interactive applications
  • Simple API with clear examples
Cons
  • Limited to C++ usage only
  • May not support advanced SVG features (full spec coverage not stated)
  • Only outputs PNG format from examples

Best For

Embedding SVG rendering in C++ applicationsGame development for UI and vector graphicsGenerating PNG images from SVG templatesDynamic styling of SVG graphics (e.g., theme switching)Server-side SVG rendering

FAQ

What is LunaSVG?
LunaSVG is an open-source SVG rendering and manipulation library in C++, designed to be lightweight and portable.
How do I use LunaSVG in my project?
Include lunasvg.h, load an SVG file or data string using Document::loadFromFile or loadFromData, then call renderToBitmap() and writeToPng() to export a PNG image.
Does LunaSVG support CSS styling?
Yes, you can apply CSS-like stylesheets to SVG documents using applyStyleSheet() for dynamic styling.
Is LunaSVG free?
Yes, LunaSVG is open source and free to use.