Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/thirdparty/msdfgen/core/Shape.h
9902 views
1
2
#pragma once
3
4
#include <vector>
5
#include "Contour.h"
6
#include "Scanline.h"
7
8
namespace msdfgen {
9
10
// Threshold of the dot product of adjacent edge directions to be considered convergent.
11
#define MSDFGEN_CORNER_DOT_EPSILON .000001
12
13
/// Vector shape representation.
14
class Shape {
15
16
public:
17
struct Bounds {
18
double l, b, r, t;
19
};
20
21
/// The list of contours the shape consists of.
22
std::vector<Contour> contours;
23
/// Specifies whether the shape uses bottom-to-top (false) or top-to-bottom (true) Y coordinates.
24
bool inverseYAxis;
25
26
Shape();
27
/// Adds a contour.
28
void addContour(const Contour &contour);
29
#ifdef MSDFGEN_USE_CPP11
30
void addContour(Contour &&contour);
31
#endif
32
/// Adds a blank contour and returns its reference.
33
Contour &addContour();
34
/// Normalizes the shape geometry for distance field generation.
35
void normalize();
36
/// Performs basic checks to determine if the object represents a valid shape.
37
bool validate() const;
38
/// Adjusts the bounding box to fit the shape.
39
void bound(double &l, double &b, double &r, double &t) const;
40
/// Adjusts the bounding box to fit the shape border's mitered corners.
41
void boundMiters(double &l, double &b, double &r, double &t, double border, double miterLimit, int polarity) const;
42
/// Computes the minimum bounding box that fits the shape, optionally with a (mitered) border.
43
Bounds getBounds(double border = 0, double miterLimit = 0, int polarity = 0) const;
44
/// Outputs the scanline that intersects the shape at y.
45
void scanline(Scanline &line, double y) const;
46
/// Returns the total number of edge segments
47
int edgeCount() const;
48
/// Assumes its contours are unoriented (even-odd fill rule). Attempts to orient them to conform to the non-zero winding rule.
49
void orientContours();
50
51
};
52
53
}
54
55