| Flutter Impeller |

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

`#include <path_component.h>`

## Public Member Functions
| LinearPathComponent ()
| LinearPathComponent (Point ap1, Point ap2)
Point | Solve (Scalar time) const
void | AppendPolylinePoints (std::vector< Point > &points) const
std::vector< Point > | Extrema () const
bool | operator== (const LinearPathComponent &other) const
std::optional< Vector2 > | GetStartDirection () const
std::optional< Vector2 > | GetEndDirection () const

## Public Attributes
Point | p1
Point | p2

## Detailed Description

Definition at line 110 of file path_component.h.

## Constructor & Destructor Documentation

## ◆ LinearPathComponent() [1/2]

impeller::LinearPathComponent::LinearPathComponent | ( |  | ) |
| inline

Definition at line 114 of file path_component.h.

114 {}

## ◆ LinearPathComponent() [2/2]

impeller::LinearPathComponent::LinearPathComponent | ( | Point | ap1,
|  | Point | ap2
| ) |  |
| inline

Definition at line 116 of file path_component.h.

116 : p1(ap1), p2(ap2) {}

## Member Function Documentation

## ◆ AppendPolylinePoints()

void impeller::LinearPathComponent::AppendPolylinePoints | ( | std::vector< Point > & | points | ) | const

Definition at line 215 of file path_component.cc.

216 {
217 if (points.size() == 0 || points.back() != p2) {
218 points.push_back(p2);
219 }
220 }

References p2.

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

## ◆ Extrema()

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

Definition at line 222 of file path_component.cc.

222 {
223 return {p1, p2};
224 }

References p1, and p2.

## ◆ GetEndDirection()

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

Definition at line 233 of file path_component.cc.

233 {
234 if (p1 == p2) {
235 return std::nullopt;
236 }
237 return (p2 - p1).Normalize();
238 }

References p1, and p2.

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

## ◆ GetStartDirection()

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

Definition at line 226 of file path_component.cc.

226 {
227 if (p1 == p2) {
228 return std::nullopt;
229 }
230 return (p1 - p2).Normalize();
231 }

References p1, and p2.

## ◆ operator==()

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

Definition at line 124 of file path_component.h.

124 {
125 return p1 == other.p1 && p2 == other.p2;
126 }

References p1, and p2.

## ◆ Solve()

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

Definition at line 208 of file path_component.cc.

208 {
209 return {
210 LinearSolve(time, p1.x, p2.x), // x
211 LinearSolve(time, p1.y, p2.y), // y
212 };
213 }

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

## Member Data Documentation

## ◆ p1

Point impeller::LinearPathComponent::p1

Definition at line 111 of file path_component.h.

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

## ◆ p2

Point impeller::LinearPathComponent::p2

Definition at line 112 of file path_component.h.

Referenced by AppendPolylinePoints(), Extrema(), GetEndDirection(), GetStartDirection(), operator==(), Solve(), impeller::testing::TEST(), and impeller::Path::WritePolyline().

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

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

impeller::TPoint::y
Type y
Definition: point.h:31
impeller::LinearPathComponent::p2
Point p2
Definition: path_component.h:112
impeller::LinearPathComponent::p1
Point p1
Definition: path_component.h:111
impeller::TPoint::x
Type x
Definition: point.h:30
impeller::LinearSolve
static Scalar LinearSolve(Scalar t, Scalar p0, Scalar p1)
Definition: path_component.cc:168