Flutter Engine
The Flutter Engine
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
 
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 63 of file path_component.h.

Member Typedef Documentation

◆ PointProc

Definition at line 83 of file path_component.h.

Constructor & Destructor Documentation

◆ QuadraticPathComponent() [1/2]

impeller::QuadraticPathComponent::QuadraticPathComponent ( )
inline

Definition at line 71 of file path_component.h.

71{}

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

173 {
174 ToLinearPathComponents(scale_factor, [&points](const Point& point) {
175 points.emplace_back(point);
176 });
177}
static const int points[]
TPoint< Scalar > Point
Definition: point.h:322
void ToLinearPathComponents(Scalar scale_factor, const PointProc &proc) const

◆ Extrema()

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

Definition at line 190 of file path_component.cc.

190 {
191 CubicPathComponent elevated(*this);
192 return elevated.Extrema();
193}

◆ GetEndDirection()

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

Definition at line 205 of file path_component.cc.

205 {
206 if (p2 != cp) {
207 return (p2 - cp).Normalize();
208 }
209 if (p2 != p1) {
210 return (p2 - p1).Normalize();
211 }
212 return std::nullopt;
213}

◆ GetStartDirection()

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

Definition at line 195 of file path_component.cc.

195 {
196 if (p1 != cp) {
197 return (p1 - cp).Normalize();
198 }
199 if (p1 != p2) {
200 return (p1 - p2).Normalize();
201 }
202 return std::nullopt;
203}

◆ operator==()

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

Definition at line 91 of file path_component.h.

91 {
92 return p1 == other.p1 && cp == other.cp && p2 == other.p2;
93 }

◆ Solve()

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

Definition at line 147 of file path_component.cc.

147 {
148 return {
149 QuadraticSolve(time, p1.x, cp.x, p2.x), // x
150 QuadraticSolve(time, p1.y, cp.y, p2.y), // y
151 };
152}
static Scalar QuadraticSolve(Scalar t, Scalar p0, Scalar p1, Scalar p2)
static double time(int loops, Benchmark *bench, Target *target)
Definition: nanobench.cpp:394

◆ SolveDerivative()

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

Definition at line 154 of file path_component.cc.

154 {
155 return {
158 };
159}
static Scalar QuadraticSolveDerivative(Scalar t, Scalar p0, Scalar p1, Scalar p2)

◆ ToLinearPathComponents() [1/2]

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

Definition at line 161 of file path_component.cc.

163 {
164 Scalar line_count = std::ceilf(ComputeQuadradicSubdivisions(scale, *this));
165 for (size_t i = 1; i < line_count; i += 1) {
166 writer.Write(Solve(i / line_count));
167 }
168 writer.Write(p2);
169}
float Scalar
Definition: scalar.h:18
Scalar ComputeQuadradicSubdivisions(Scalar scale_factor, Point p0, Point p1, Point p2)
const Scalar scale
Point Solve(Scalar time) const

◆ ToLinearPathComponents() [2/2]

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

Definition at line 179 of file path_component.cc.

181 {
182 Scalar line_count =
183 std::ceilf(ComputeQuadradicSubdivisions(scale_factor, *this));
184 for (size_t i = 1; i < line_count; i += 1) {
185 proc(Solve(i / line_count));
186 }
187 proc(p2);
188}

Member Data Documentation

◆ cp

Point impeller::QuadraticPathComponent::cp

Definition at line 67 of file path_component.h.

◆ p1

Point impeller::QuadraticPathComponent::p1

Definition at line 65 of file path_component.h.

◆ p2

Point impeller::QuadraticPathComponent::p2

Definition at line 69 of file path_component.h.


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