tiny-skia-cpp
A C++20 2D rendering library (port of tiny-skia)
Loading...
Searching...
No Matches
Paint.h
Go to the documentation of this file.
1#pragma once
2
5
6#include <cstdint>
7
9#include "tiny_skia/Color.h"
10#include "tiny_skia/shaders/Shaders.h"
11
12namespace tiny_skia {
13
15struct Paint {
17 Shader shader = Color::black;
18
20 BlendMode blendMode = BlendMode::SourceOver;
21
23 bool antiAlias = true;
24
26 ColorSpace colorspace = ColorSpace::Linear;
27
29 bool forceHqPipeline = false;
30
35 bool unpremulStore = false;
36
38 void setColor(const Color& color) { shader = color; }
39
41 void setColorRgba8(std::uint8_t r, std::uint8_t g, std::uint8_t b, std::uint8_t a) {
42 setColor(Color::fromRgba8(r, g, b, a));
43 }
44
46 [[nodiscard]] bool isSolidColor() const { return std::holds_alternative<Color>(shader); }
47};
48
49} // namespace tiny_skia
Porter-Duff and advanced blend modes.
BlendMode
Blend mode for compositing source over destination. Includes Porter-Duff modes and advanced (separabl...
Definition BlendMode.h:14
Color types (8-bit and floating-point, straight and premultiplied).
ColorSpace
Colorspace for gamma-correct blending.
Definition Color.h:167
Floating-point RGBA color [0,1] (straight alpha).
Definition Color.h:88
static Color fromRgba8(AlphaU8 red, AlphaU8 green, AlphaU8 blue, AlphaU8 alpha)
Creates from 8-bit components.
Controls how a shape is painted (shader, blend mode, anti-aliasing).
Definition Paint.h:15
bool unpremulStore
Store output as unpremultiplied (straight) alpha. Default: false. When true, the pipeline unpremultip...
Definition Paint.h:35
bool forceHqPipeline
Force the high-quality (highp) rendering pipeline. Default: false.
Definition Paint.h:29
void setColor(const Color &color)
Sets the shader to a solid color.
Definition Paint.h:38
bool antiAlias
Enable anti-aliased rendering. Default: true.
Definition Paint.h:23
ColorSpace colorspace
Colorspace for gamma-correct blending. Default: Linear.
Definition Paint.h:26
BlendMode blendMode
Blend mode. Default: SourceOver.
Definition Paint.h:20
bool isSolidColor() const
Returns true if the shader is a solid color.
Definition Paint.h:46
Shader shader
Paint shader source. Default: solid black.
Definition Paint.h:17
void setColorRgba8(std::uint8_t r, std::uint8_t g, std::uint8_t b, std::uint8_t a)
Sets the shader to a solid color from 8-bit RGBA components.
Definition Paint.h:41