Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
svg.hpp
Go to the documentation of this file.
1#pragma once
2
4#include <string>
5#include <vector>
6#include <memory>
7#include <cstdint>
8
9namespace pulp::canvas {
10
11// Parsed SVG image — can be rendered to any Canvas at any size
12class SvgImage {
13public:
14 SvgImage() = default;
16
17 SvgImage(SvgImage&& other) noexcept;
18 SvgImage& operator=(SvgImage&& other) noexcept;
19
20 SvgImage(const SvgImage&) = delete;
21 SvgImage& operator=(const SvgImage&) = delete;
22
23 // Load from SVG string
24 static SvgImage from_string(const std::string& svg_data);
25
26 // Load from file
27 static SvgImage from_file(const std::string& path);
28
29 // Check if loaded
30 bool is_valid() const { return image_ != nullptr; }
31
32 // Original dimensions
33 float width() const;
34 float height() const;
35
36 // Rasterize to RGBA pixel buffer at a given size
37 std::vector<uint8_t> rasterize(int width, int height) const;
38
39 // Render into a Canvas (draws paths using Canvas primitives)
40 void render(Canvas& canvas, float x, float y, float width, float height) const;
41
42private:
43 void* image_ = nullptr; // NSVGimage*
44};
45
46} // namespace pulp::canvas
Definition canvas.hpp:240
SvgImage(const SvgImage &)=delete
std::vector< uint8_t > rasterize(int width, int height) const
SvgImage(SvgImage &&other) noexcept
void render(Canvas &canvas, float x, float y, float width, float height) const
bool is_valid() const
Definition svg.hpp:30
SvgImage & operator=(SvgImage &&other) noexcept
SvgImage & operator=(const SvgImage &)=delete
static SvgImage from_string(const std::string &svg_data)
float height() const
static SvgImage from_file(const std::string &path)
Definition affine_transform.hpp:24
@ path
Definition scene_node.hpp:93