14 std::vector<uint16_t>& indices)
15 : points_(
points), indices_(indices) {}
18 if (points_.size() == 0u || contour_start_ == points_.size() - 1) {
23 auto start = contour_start_;
24 auto end = points_.size() - 1;
29 if (points_[
end] == points_[
start]) {
34 if (contour_start_ != 0) {
35 auto back = indices_.back();
36 indices_.push_back(back);
37 indices_.push_back(
start);
38 indices_.push_back(
start);
43 if (previous_contour_odd_points_) {
44 indices_.push_back(
start);
47 indices_.push_back(
start);
53 indices_.push_back(
a);
54 indices_.push_back(
b);
59 indices_.push_back(
a);
60 previous_contour_odd_points_ =
false;
62 previous_contour_odd_points_ =
true;
64 contour_start_ = points_.size();
68 points_.push_back(point);
76 return p0 + t * (p1 - p0);
80 return (1 - t) * (1 - t) * p0 +
81 2 * (1 - t) * t * p1 +
89 return 2 * (1 - t) * (p1 - p0) +
98 return (1 - t) * (1 - t) * (1 - t) * p0 +
99 3 * (1 - t) * (1 - t) * t * p1 +
100 3 * (1 - t) * t * t * p2 +
109 return -3 * p0 * (1 - t) * (1 - t) +
110 p1 * (3 * (1 - t) * (1 - t) - 6 * (1 - t) * t) +
111 p2 * (6 * (1 - t) * t - 3 * t * t) +
123 std::vector<Point>&
points)
const {
137 return (
p1 -
p2).Normalize();
144 return (
p2 -
p1).Normalize();
165 for (
size_t i = 1;
i < line_count;
i += 1) {
173 std::vector<Point>&
points)
const {
175 points.emplace_back(point);
184 for (
size_t i = 1;
i < line_count;
i += 1) {
185 proc(
Solve(
i / line_count));
197 return (
p1 -
cp).Normalize();
200 return (
p1 -
p2).Normalize();
207 return (
p2 -
cp).Normalize();
210 return (
p2 -
p1).Normalize();
231 std::vector<Point>&
points)
const {
239 for (
size_t i = 1;
i < line_count;
i++) {
254 auto scale = (t1 - t0) * (1.0 / 3.0);
263 for (
size_t i = 1;
i < line_count;
i++) {
264 proc(
Solve(
i / line_count));
270 return (
a > (
b - epsilon)) && (
a < (
b + epsilon));
282 const Scalar a = 3.0 * (-p1 + 3.0 * p2 - 3.0 * p3 + p4);
283 const Scalar b = 6.0 * (p1 - 2.0 * p2 + p3);
284 const Scalar c = 3.0 * (p2 - p1);
295 if (t >= 0.0 && t <= 1.0) {
301 Scalar b2Minus4AC = (
b *
b) - (4.0 *
a * c);
303 if (b2Minus4AC < 0.0) {
315 Scalar q = (
b < 0) ? -(
b - rootB2Minus4AC) / 2 : -(
b + rootB2Minus4AC) / 2;
319 if (t >= 0.0 && t <= 1.0) {
326 if (t >= 0.0 && t <= 1.0) {
336 std::vector<Scalar>
values;
352 return (
p1 -
cp1).Normalize();
355 return (
p1 -
cp2).Normalize();
358 return (
p1 -
p2).Normalize();
365 return (
p2 -
cp2).Normalize();
368 return (
p2 -
cp1).Normalize();
371 return (
p2 -
p1).Normalize();
static const int points[]
An interface for generating a multi contour polyline as a triangle strip.
VertexWriter(std::vector< Point > &points, std::vector< uint16_t > &indices)
VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE auto & d
static void CubicPathBoundingPopulateValues(std::vector< Scalar > &values, Scalar p1, Scalar p2, Scalar p3, Scalar p4)
static bool NearZero(Scalar a)
static Scalar LinearSolve(Scalar t, Scalar p0, Scalar p1)
static Scalar CubicSolve(Scalar t, Scalar p0, Scalar p1, Scalar p2, Scalar p3)
static Scalar CubicSolveDerivative(Scalar t, Scalar p0, Scalar p1, Scalar p2, Scalar p3)
static Scalar QuadraticSolve(Scalar t, Scalar p0, Scalar p1, Scalar p2)
static Scalar QuadraticSolveDerivative(Scalar t, Scalar p0, Scalar p1, Scalar p2)
Scalar ComputeQuadradicSubdivisions(Scalar scale_factor, Point p0, Point p1, Point p2)
Scalar ComputeCubicSubdivisions(Scalar scale_factor, Point p0, Point p1, Point p2, Point p3)
static bool NearEqual(Scalar a, Scalar b, Scalar epsilon)
SIN Vec< N, float > sqrt(const Vec< N, float > &x)
static double time(int loops, Benchmark *bench, Target *target)
void ToLinearPathComponents(Scalar scale, const PointProc &proc) const
void AppendPolylinePoints(Scalar scale, std::vector< Point > &points) const
std::function< void(const Point &point)> PointProc
CubicPathComponent Subsegment(Scalar t0, Scalar t1) const
Point Solve(Scalar time) const
std::optional< Vector2 > GetStartDirection() const
std::vector< Point > Extrema() const
std::optional< Vector2 > GetEndDirection() const
Point SolveDerivative(Scalar time) const
std::optional< Vector2 > GetEndDirection() const
std::optional< Vector2 > GetStartDirection() const
std::vector< Point > Extrema() const
Point Solve(Scalar time) const
void AppendPolylinePoints(std::vector< Point > &points) const
std::optional< Vector2 > operator()(const LinearPathComponent *component)
std::optional< Vector2 > operator()(const LinearPathComponent *component)
std::optional< Vector2 > GetEndDirection() const
void AppendPolylinePoints(Scalar scale_factor, std::vector< Point > &points) const
std::function< void(const Point &point)> PointProc
std::vector< Point > Extrema() const
Point SolveDerivative(Scalar time) const
std::optional< Vector2 > GetStartDirection() const
void ToLinearPathComponents(Scalar scale_factor, const PointProc &proc) const
Point Solve(Scalar time) const