Flutter Impeller
wangs_formula.h
Go to the documentation of this file.
1
// Copyright 2013 The Flutter Authors. All rights reserved.
2
// Use of this source code is governed by a BSD-style license that can be
3
// found in the LICENSE file.
4
5
#ifndef FLUTTER_IMPELLER_GEOMETRY_WANGS_FORMULA_H_
6
#define FLUTTER_IMPELLER_GEOMETRY_WANGS_FORMULA_H_
7
8
#include "
impeller/geometry/path_component.h
"
9
#include "
impeller/geometry/point.h
"
10
#include "
impeller/geometry/scalar.h
"
11
12
// Skia GPU Ports
13
14
// Wang's formula gives the minimum number of evenly spaced (in the parametric
15
// sense) line segments that a bezier curve must be chopped into in order to
16
// guarantee all lines stay within a distance of "1/precision" pixels from the
17
// true curve. Its definition for a bezier curve of degree "n" is as follows:
18
//
19
// maxLength = max([length(p[i+2] - 2p[i+1] + p[i]) for (0 <= i <= n-2)])
20
// numParametricSegments = sqrt(maxLength * precision * n*(n - 1)/8)
21
//
22
// (Goldman, Ron. (2003). 5.6.3 Wang's Formula. "Pyramid Algorithms: A Dynamic
23
// Programming Approach to Curves and Surfaces for Geometric Modeling". Morgan
24
// Kaufmann Publishers.)
25
namespace
impeller
{
26
27
/// Returns the minimum number of evenly spaced (in the parametric sense) line
28
/// segments that the cubic must be chopped into in order to guarantee all lines
29
/// stay within a distance of "1/intolerance" pixels from the true curve.
30
///
31
/// The scale_factor should be the max basis XY of the current transform.
32
Scalar
ComputeCubicSubdivisions
(
Scalar
scale_factor,
33
Point
p0,
34
Point
p1,
35
Point
p2,
36
Point
p3);
37
38
/// Returns the minimum number of evenly spaced (in the parametric sense) line
39
/// segments that the quadratic must be chopped into in order to guarantee all
40
/// lines stay within a distance of "1/intolerance" pixels from the true curve.
41
///
42
/// The scale_factor should be the max basis XY of the current transform.
43
Scalar
ComputeQuadradicSubdivisions
(
Scalar
scale_factor,
44
Point
p0,
45
Point
p1,
46
Point
p2);
47
48
/// Returns the minimum number of evenly spaced (in the parametric sense) line
49
/// segments that the quadratic must be chopped into in order to guarantee all
50
/// lines stay within a distance of "1/intolerance" pixels from the true curve.
51
///
52
/// The scale_factor should be the max basis XY of the current transform.
53
Scalar
ComputeQuadradicSubdivisions
(
Scalar
scale_factor,
54
const
QuadraticPathComponent& quad);
55
56
/// Returns the minimum number of evenly spaced (in the parametric sense) line
57
/// segments that the cubic must be chopped into in order to guarantee all lines
58
/// stay within a distance of "1/intolerance" pixels from the true curve.
59
///
60
/// The scale_factor should be the max basis XY of the current transform.
61
Scalar
ComputeCubicSubdivisions
(
float
scale_factor,
62
const
CubicPathComponent& cub);
63
}
// namespace impeller
64
65
#endif // FLUTTER_IMPELLER_GEOMETRY_WANGS_FORMULA_H_
impeller::ComputeQuadradicSubdivisions
Scalar ComputeQuadradicSubdivisions(Scalar scale_factor, Point p0, Point p1, Point p2)
Definition:
wangs_formula.cc:34
point.h
impeller::Scalar
float Scalar
Definition:
scalar.h:18
impeller::Point
TPoint< Scalar > Point
Definition:
point.h:327
scalar.h
impeller::ComputeCubicSubdivisions
Scalar ComputeCubicSubdivisions(Scalar scale_factor, Point p0, Point p1, Point p2, Point p3)
Definition:
wangs_formula.cc:23
path_component.h
impeller
Definition:
allocation.cc:12
impeller
geometry
wangs_formula.h
Generated by
1.8.17