| 1 |
|
| 2 |
#pragma once |
| 3 |
|
| 4 |
#include <vector> |
| 5 |
#include "base.h" |
| 6 |
|
| 7 |
namespace msdfgen { |
| 8 |
|
| 9 |
|
| 10 |
enum FillRule { |
| 11 |
FILL_NONZERO, |
| 12 |
FILL_ODD, |
| 13 |
FILL_POSITIVE, |
| 14 |
FILL_NEGATIVE |
| 15 |
}; |
| 16 |
|
| 17 |
|
| 18 |
bool interpretFillRule(int intersections, FillRule fillRule); |
| 19 |
|
| 20 |
|
| 21 |
class Scanline { |
| 22 |
|
| 23 |
public: |
| 24 |
|
| 25 |
struct Intersection { |
| 26 |
|
| 27 |
double x; |
| 28 |
|
| 29 |
int direction; |
| 30 |
}; |
| 31 |
|
| 32 |
static double overlap(const Scanline &a, const Scanline &b, double xFrom, double xTo, FillRule fillRule); |
| 33 |
|
| 34 |
Scanline(); |
| 35 |
|
| 36 |
void setIntersections(const std::vector<Intersection> &intersections); |
| 37 |
#ifdef MSDFGEN_USE_CPP11 |
| 38 |
void setIntersections(std::vector<Intersection> &&intersections); |
| 39 |
#endif |
| 40 |
|
| 41 |
int countIntersections(double x) const; |
| 42 |
|
| 43 |
int sumIntersections(double x) const; |
| 44 |
|
| 45 |
bool filled(double x, FillRule fillRule) const; |
| 46 |
|
| 47 |
private: |
| 48 |
std::vector<Intersection> intersections; |
| 49 |
mutable int lastIndex; |
| 50 |
|
| 51 |
void preprocess(); |
| 52 |
int moveTo(double x) const; |
| 53 |
|
| 54 |
}; |
| 55 |
|
| 56 |
} |