| Flutter Impeller |

Public Types | Public Member Functions | Public Attributes | List of all members
impeller::QuadraticPathComponent Struct Reference

`#include <path_component.h>`

## Public Types
using | PointProc = std::function< void(const Point &point)>

## Public Member Functions
| QuadraticPathComponent ()
| QuadraticPathComponent (Point ap1, Point acp, Point ap2)
Point | Solve (Scalar time) const
Point | SolveDerivative (Scalar time) const
void | AppendPolylinePoints (Scalar scale_factor, std::vector< Point > &points) const
void | ToLinearPathComponents (Scalar scale_factor, const PointProc &proc) const
void | ToLinearPathComponents (Scalar scale, VertexWriter &writer) const
size_t | CountLinearPathComponents (Scalar scale) const
std::vector< Point > | Extrema () const
bool | operator== (const QuadraticPathComponent &other) const
std::optional< Vector2 > | GetStartDirection () const
std::optional< Vector2 > | GetEndDirection () const

## Public Attributes
Point | p1
Point | cp
Point | p2

## Detailed Description

Definition at line 134 of file path_component.h.

## Member Typedef Documentation

## ◆ PointProc

using impeller::QuadraticPathComponent::PointProc = std::function<void(const Point& point)>

Definition at line 154 of file path_component.h.

## Constructor & Destructor Documentation

## ◆ QuadraticPathComponent() [1/2]

impeller::QuadraticPathComponent::QuadraticPathComponent | ( |  | ) |
| inline

Definition at line 142 of file path_component.h.

142 {}

## ◆ QuadraticPathComponent() [2/2]

impeller::QuadraticPathComponent::QuadraticPathComponent | ( | Point | ap1,
|  | Point | acp,
|  | Point | ap2
| ) |  |
| inline

Definition at line 144 of file path_component.h.

145 : p1(ap1), cp(acp), p2(ap2) {}

## Member Function Documentation

## ◆ AppendPolylinePoints()

void impeller::QuadraticPathComponent::AppendPolylinePoints | ( | Scalar | scale_factor,
|  | std::vector< Point > & | points
| ) |  | const

Definition at line 264 of file path_component.cc.

266 {
267 ToLinearPathComponents(scale_factor, [&points](const Point& point) {
268 points.emplace_back(point);
269 });
270 }

References ToLinearPathComponents().

Referenced by impeller::Path::CreatePolyline().

## ◆ CountLinearPathComponents()

size_t impeller::QuadraticPathComponent::CountLinearPathComponents | ( | Scalar | scale | ) | const

Definition at line 283 of file path_component.cc.

283 {
284 return std::ceilf(ComputeQuadradicSubdivisions(scale, *this)) + 2;
285 }

References impeller::ComputeQuadradicSubdivisions(), and scale.

Referenced by impeller::Path::CountStorage().

## ◆ Extrema()

std::vector< Point > impeller::QuadraticPathComponent::Extrema | ( |  | ) | const

Definition at line 287 of file path_component.cc.

287 {
288 CubicPathComponent elevated(*this);
289 return elevated.Extrema();
290 }

References impeller::CubicPathComponent::Extrema().

## ◆ GetEndDirection()

std::optional< Vector2 > impeller::QuadraticPathComponent::GetEndDirection | ( |  | ) | const

Definition at line 302 of file path_component.cc.

302 {
303 if (p2 != cp) {
304 return (p2 - cp).Normalize();
305 }
306 if (p2 != p1) {
307 return (p2 - p1).Normalize();
308 }
309 return std::nullopt;
310 }

References cp, p1, and p2.

Referenced by impeller::Path::EndContour().

## ◆ GetStartDirection()

std::optional< Vector2 > impeller::QuadraticPathComponent::GetStartDirection | ( |  | ) | const

Definition at line 292 of file path_component.cc.

292 {
293 if (p1 != cp) {
294 return (p1 - cp).Normalize();
295 }
296 if (p1 != p2) {
297 return (p1 - p2).Normalize();
298 }
299 return std::nullopt;
300 }

References cp, p1, and p2.

## ◆ operator==()

bool impeller::QuadraticPathComponent::operator== | ( | const QuadraticPathComponent & | other | ) | const
| inline

Definition at line 164 of file path_component.h.

164 {
165 return p1 == other.p1 && cp == other.cp && p2 == other.p2;
166 }

References cp, p1, and p2.

## ◆ Solve()

Point impeller::QuadraticPathComponent::Solve | ( | Scalar | time | ) | const

Definition at line 240 of file path_component.cc.

240 {
241 return {
242 QuadraticSolve(time, p1.x, cp.x, p2.x), // x
243 QuadraticSolve(time, p1.y, cp.y, p2.y), // y
244 };
245 }

References cp, p1, p2, impeller::QuadraticSolve(), impeller::TPoint< T >::x, and impeller::TPoint< T >::y.

Referenced by ToLinearPathComponents().

## ◆ SolveDerivative()

Point impeller::QuadraticPathComponent::SolveDerivative | ( | Scalar | time | ) | const

Definition at line 247 of file path_component.cc.

247 {
248 return {
249 QuadraticSolveDerivative(time, p1.x, cp.x, p2.x), // x
250 QuadraticSolveDerivative(time, p1.y, cp.y, p2.y), // y
251 };
252 }

References cp, p1, p2, impeller::QuadraticSolveDerivative(), impeller::TPoint< T >::x, and impeller::TPoint< T >::y.

## ◆ ToLinearPathComponents() [1/2]

void impeller::QuadraticPathComponent::ToLinearPathComponents | ( | Scalar | scale,
|  | VertexWriter & | writer
| ) |  | const

Definition at line 254 of file path_component.cc.

256 {
257 Scalar line_count = std::ceilf(ComputeQuadradicSubdivisions(scale, *this));
258 for (size_t i = 1; i < line_count; i += 1) {
259 writer.Write(Solve(i / line_count));
260 }
261 writer.Write(p2);
262 }

References impeller::ComputeQuadradicSubdivisions(), p2, scale, Solve(), and impeller::VertexWriter::Write().

## ◆ ToLinearPathComponents() [2/2]

void impeller::QuadraticPathComponent::ToLinearPathComponents | ( | Scalar | scale_factor,
|  | const PointProc & | proc
| ) |  | const

Definition at line 272 of file path_component.cc.

274 {
275 Scalar line_count =
276 std::ceilf(ComputeQuadradicSubdivisions(scale_factor, *this));
277 for (size_t i = 1; i < line_count; i += 1) {
278 proc(Solve(i / line_count));
279 }
280 proc(p2);
281 }

References impeller::ComputeQuadradicSubdivisions(), p2, and Solve().

Referenced by AppendPolylinePoints(), and impeller::Path::WritePolyline().

## Member Data Documentation

## ◆ cp

Point impeller::QuadraticPathComponent::cp

Definition at line 138 of file path_component.h.

Referenced by impeller::ComputeQuadradicSubdivisions(), GetEndDirection(), GetStartDirection(), operator==(), Solve(), SolveDerivative(), and impeller::testing::TEST().

## ◆ p1

Point impeller::QuadraticPathComponent::p1

Definition at line 136 of file path_component.h.

Referenced by impeller::ComputeQuadradicSubdivisions(), GetEndDirection(), GetStartDirection(), operator==(), impeller::PathBuilder::Shift(), Solve(), SolveDerivative(), impeller::testing::TEST(), and impeller::Path::WritePolyline().

## ◆ p2

Point impeller::QuadraticPathComponent::p2

Definition at line 140 of file path_component.h.

Referenced by impeller::ComputeQuadradicSubdivisions(), GetEndDirection(), GetStartDirection(), operator==(), Solve(), SolveDerivative(), impeller::testing::TEST(), and ToLinearPathComponents().

The documentation for this struct was generated from the following files:

- impeller/geometry/path_component.h
- impeller/geometry/path_component.cc

impeller::ComputeQuadradicSubdivisions
Scalar ComputeQuadradicSubdivisions(Scalar scale_factor, Point p0, Point p1, Point p2)
Definition: wangs_formula.cc:34
impeller::TPoint::y
Type y
Definition: point.h:31
impeller::Scalar
float Scalar
Definition: scalar.h:18
impeller::QuadraticPathComponent::p1
Point p1
Definition: path_component.h:136
impeller::QuadraticPathComponent::cp
Point cp
Definition: path_component.h:138
impeller::QuadraticSolve
static Scalar QuadraticSolve(Scalar t, Scalar p0, Scalar p1, Scalar p2)
Definition: path_component.cc:172
impeller::QuadraticPathComponent::ToLinearPathComponents
void ToLinearPathComponents(Scalar scale_factor, const PointProc &proc) const
Definition: path_component.cc:272
impeller::Point
TPoint< Scalar > Point
Definition: point.h:327
impeller::QuadraticPathComponent::Solve
Point Solve(Scalar time) const
Definition: path_component.cc:240
impeller::TPoint::x
Type x
Definition: point.h:30
impeller::QuadraticSolveDerivative
static Scalar QuadraticSolveDerivative(Scalar t, Scalar p0, Scalar p1, Scalar p2)
Definition: path_component.cc:178
impeller::QuadraticPathComponent::p2
Point p2
Definition: path_component.h:140
scale
const Scalar scale
Definition: stroke_path_geometry.cc:316