Flutter Impeller
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< PointExtrema () const
 
bool operator== (const QuadraticPathComponent &other) const
 
std::optional< Vector2GetStartDirection () const
 
std::optional< Vector2GetEndDirection () 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

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 }
TPoint< Scalar > Point
Definition: point.h:327
void ToLinearPathComponents(Scalar scale_factor, const PointProc &proc) const

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 }
Scalar ComputeQuadradicSubdivisions(Scalar scale_factor, Point p0, Point p1, Point p2)
const Scalar scale

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 }
static Scalar QuadraticSolve(Scalar t, Scalar p0, Scalar p1, Scalar p2)

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 }
static Scalar QuadraticSolveDerivative(Scalar t, Scalar p0, Scalar p1, Scalar p2)

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 }
float Scalar
Definition: scalar.h:18
Point Solve(Scalar time) const

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

◆ p1

◆ p2


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