| 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 135 of file path_component.h.

## Member Typedef Documentation

## ◆ PointProc

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

Definition at line 155 of file path_component.h.

## Constructor & Destructor Documentation

## ◆ QuadraticPathComponent() [1/2]

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

Definition at line 143 of file path_component.h.

143 {}

## ◆ QuadraticPathComponent() [2/2]

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

Definition at line 145 of file path_component.h.

146 : p1(ap1), cp(acp), p2(ap2) {}
impeller::QuadraticPathComponent::p2
Point p2
Definition: path_component.h:141
impeller::QuadraticPathComponent::cp
Point cp
Definition: path_component.h:139
impeller::QuadraticPathComponent::p1
Point p1
Definition: path_component.h:137

## Member Function Documentation

## ◆ AppendPolylinePoints()

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

Definition at line 279 of file path_component.cc.

281 {
282 ToLinearPathComponents(scale_factor, [&points](const Point& point) {
283 points.emplace_back(point);
284 });
285 }
impeller::Point
TPoint< Scalar > Point
Definition: point.h:327
impeller::QuadraticPathComponent::ToLinearPathComponents
void ToLinearPathComponents(Scalar scale_factor, const PointProc &proc) const
Definition: path_component.cc:287

References ToLinearPathComponents().

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

## ◆ CountLinearPathComponents()

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

Definition at line 298 of file path_component.cc.

298 {
299 return std::ceilf(ComputeQuadradicSubdivisions(scale, *this)) + 2;
300 }
impeller::ComputeQuadradicSubdivisions
Scalar ComputeQuadradicSubdivisions(Scalar scale_factor, Point p0, Point p1, Point p2)
Definition: wangs_formula.cc:34
scale
const Scalar scale
Definition: stroke_path_geometry.cc:319

References impeller::ComputeQuadradicSubdivisions(), and scale.

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

## ◆ Extrema()

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

Definition at line 302 of file path_component.cc.

302 {
303 CubicPathComponent elevated(*this);
304 return elevated.Extrema();
305 }

References impeller::CubicPathComponent::Extrema().

## ◆ GetEndDirection()

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

Definition at line 317 of file path_component.cc.

317 {
318 if (p2 != cp) {
319 return (p2 - cp).Normalize();
320 }
321 if (p2 != p1) {
322 return (p2 - p1).Normalize();
323 }
324 return std::nullopt;
325 }

References cp, p1, and p2.

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

## ◆ GetStartDirection()

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

Definition at line 307 of file path_component.cc.

307 {
308 if (p1 != cp) {
309 return (p1 - cp).Normalize();
310 }
311 if (p1 != p2) {
312 return (p1 - p2).Normalize();
313 }
314 return std::nullopt;
315 }

References cp, p1, and p2.

## ◆ operator==()

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

Definition at line 165 of file path_component.h.

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

References cp, p1, and p2.

## ◆ Solve()

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

Definition at line 255 of file path_component.cc.

255 {
256 return {
257 QuadraticSolve(time, p1.x, cp.x, p2.x), // x
258 QuadraticSolve(time, p1.y, cp.y, p2.y), // y
259 };
260 }
impeller::QuadraticSolve
static Scalar QuadraticSolve(Scalar t, Scalar p0, Scalar p1, Scalar p2)
Definition: path_component.cc:173
impeller::TPoint::y
Type y
Definition: point.h:31
impeller::TPoint::x
Type x
Definition: point.h:30

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 262 of file path_component.cc.

262 {
263 return {
264 QuadraticSolveDerivative(time, p1.x, cp.x, p2.x), // x
265 QuadraticSolveDerivative(time, p1.y, cp.y, p2.y), // y
266 };
267 }
impeller::QuadraticSolveDerivative
static Scalar QuadraticSolveDerivative(Scalar t, Scalar p0, Scalar p1, Scalar p2)
Definition: path_component.cc:179

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 269 of file path_component.cc.

271 {
272 Scalar line_count = std::ceilf(ComputeQuadradicSubdivisions(scale, *this));
273 for (size_t i = 1; i < line_count; i += 1) {
274 writer.Write(Solve(i / line_count));
275 }
276 writer.Write(p2);
277 }
impeller::Scalar
float Scalar
Definition: scalar.h:18
impeller::QuadraticPathComponent::Solve
Point Solve(Scalar time) const
Definition: path_component.cc:255

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 287 of file path_component.cc.

289 {
290 Scalar line_count =
291 std::ceilf(ComputeQuadradicSubdivisions(scale_factor, *this));
292 for (size_t i = 1; i < line_count; i += 1) {
293 proc(Solve(i / line_count));
294 }
295 proc(p2);
296 }

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

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

## Member Data Documentation

## ◆ cp

Point impeller::QuadraticPathComponent::cp

Definition at line 139 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 137 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 141 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