#pragma once
#include <vector>
#include "base.h"
namespace msdfgen {
enum FillRule {
FILL_NONZERO,
FILL_ODD,
FILL_POSITIVE,
FILL_NEGATIVE
};
bool interpretFillRule(int intersections, FillRule fillRule);
class Scanline {
public:
struct Intersection {
double x;
int direction;
};
static double overlap(const Scanline &a, const Scanline &b, double xFrom, double xTo, FillRule fillRule);
Scanline();
void setIntersections(const std::vector<Intersection> &intersections);
#ifdef MSDFGEN_USE_CPP11
void setIntersections(std::vector<Intersection> &&intersections);
#endif
int countIntersections(double x) const;
int sumIntersections(double x) const;
bool filled(double x, FillRule fillRule) const;
private:
std::vector<Intersection> intersections;
mutable int lastIndex;
void preprocess();
int moveTo(double x) const;
};
}