tiny-skia-cpp
A C++20 2D rendering library (port of tiny-skia)
Loading...
Searching...
No Matches
Stroke.h
Go to the documentation of this file.
1#pragma once
2
5
6#include <cstdint>
7#include <optional>
8#include <vector>
9
10#include "tiny_skia/Path.h"
11#include "tiny_skia/Scalar.h"
12
13namespace tiny_skia {
14
16enum class LineJoin : std::uint8_t {
17 Miter,
18 MiterClip,
19 Round,
20 Bevel,
21};
22
24struct StrokeDash {
26 std::vector<float> array;
28 float offset = 0.0f;
29
31 [[nodiscard]] static std::optional<StrokeDash> create(std::vector<float> dashArray,
32 float dashOffset);
33};
34
36struct Stroke {
37 float width = 1.0f;
38 float miterLimit = 4.0f;
39 LineCap lineCap = LineCap::Butt;
40 LineJoin lineJoin = LineJoin::Miter;
41 std::optional<StrokeDash> dash;
42};
43
44} // namespace tiny_skia
Immutable vector path and related types.
LineCap
Line cap style for stroke endpoints.
Definition Path.h:32
@ Round
Semicircle cap.
LineJoin
Line join style for stroke corners.
Definition Stroke.h:16
@ Bevel
Flat corner.
@ MiterClip
Miter clipped at the limit distance.
@ Miter
Sharp corner (extends to miter limit).
Dash pattern for stroked paths.
Definition Stroke.h:24
std::vector< float > array
Dash/gap lengths. Must have an even count with all values > 0.
Definition Stroke.h:26
float offset
Offset into the dash pattern.
Definition Stroke.h:28
static std::optional< StrokeDash > create(std::vector< float > dashArray, float dashOffset)
Creates a validated dash. Returns nullopt if the array is invalid.
Stroke properties for Painter::strokePath.
Definition Stroke.h:36
std::optional< StrokeDash > dash
Optional dash pattern.
Definition Stroke.h:41
LineCap lineCap
Endpoint cap style.
Definition Stroke.h:39
LineJoin lineJoin
Corner join style.
Definition Stroke.h:40
float width
Stroke width in pixels.
Definition Stroke.h:37
float miterLimit
Miter join limit (ratio of miter length to stroke width).
Definition Stroke.h:38