| Flutter Impeller |

Classes | Public Member Functions | Static Public Attributes | List of all members
impeller::PathBuilder Class Reference

`#include <path_builder.h>`

## Classes
struct | RoundingRadii

## Public Member Functions
| PathBuilder ()
| ~PathBuilder ()
Path | CopyPath (FillType fill=FillType::kNonZero) const
Path | TakePath (FillType fill=FillType::kNonZero)
const Path & | GetCurrentPath () const
PathBuilder & | SetConvexity (Convexity value)
PathBuilder & | MoveTo (Point point, bool relative=false)
PathBuilder & | Close ()
PathBuilder & | LineTo (Point point, bool relative=false)
| Insert a line from the current position to `point`. More...
PathBuilder & | HorizontalLineTo (Scalar x, bool relative=false)
PathBuilder & | VerticalLineTo (Scalar y, bool relative=false)
PathBuilder & | QuadraticCurveTo (Point controlPoint, Point point, bool relative=false)
| Insert a quadradic curve from the current position to `point` using the control point `controlPoint`. More...
PathBuilder & | SmoothQuadraticCurveTo (Point point, bool relative=false)
PathBuilder & | CubicCurveTo (Point controlPoint1, Point controlPoint2, Point point, bool relative=false)
| Insert a cubic curve from the curren position to `point` using the control points `controlPoint1` and `controlPoint2`. More...
PathBuilder & | SmoothCubicCurveTo (Point controlPoint2, Point point, bool relative=false)
PathBuilder & | AddRect (Rect rect)
PathBuilder & | AddCircle (const Point &center, Scalar radius)
PathBuilder & | AddArc (const Rect &oval_bounds, Radians start, Radians sweep, bool use_center=false)
PathBuilder & | AddOval (const Rect &rect)
PathBuilder & | AddLine (const Point &p1, const Point &p2)
| Move to point `p1`, then insert a line from `p1` to `p2`. More...
PathBuilder & | AddQuadraticCurve (Point p1, Point cp, Point p2)
| Move to point `p1`, then insert a quadradic curve from `p1` to `p2` with the control point `cp`. More...
PathBuilder & | AddCubicCurve (Point p1, Point cp1, Point cp2, Point p2)
| Move to point `p1`, then insert a cubic curve from `p1` to `p2` with control points `cp1` and `cp2`. More...
PathBuilder & | Shift (Point offset)
| Transform the existing path segments and contours by the given `offset`. More...
PathBuilder & | SetBounds (Rect bounds)
| Set the bounding box that will be used by `Path.GetBoundingBox` in place of performing the computation. More...
PathBuilder & | AddRoundedRect (Rect rect, RoundingRadii radii)
PathBuilder & | AddRoundedRect (Rect rect, Scalar radius)
PathBuilder & | AddPath (const Path &path)

## Static Public Attributes
constexpr static const Scalar | kArcApproximationMagic = 0.551915024494f

## Detailed Description

Definition at line 13 of file path_builder.h.

## Constructor & Destructor Documentation

## ◆ PathBuilder()

impeller::PathBuilder::PathBuilder | ( |  | ) |
| default

## ◆ ~PathBuilder()

impeller::PathBuilder::~PathBuilder | ( |  | ) |
| default

## Member Function Documentation

## ◆ AddArc()

PathBuilder & impeller::PathBuilder::AddArc | ( | const Rect & | oval_bounds,
|  | Radians | start,
|  | Radians | sweep,
|  | bool | use_center = `false`
| ) |  |

Definition at line 325 of file path_builder.cc.

328 {
329 if (sweep.radians < 0) {
330 start.radians += sweep.radians;
331 sweep.radians *= -1;
332 }
333 sweep.radians = std::min(k2Pi, sweep.radians);
334 start.radians = std::fmod(start.radians, k2Pi);
335
336 const Point radius = {oval_bounds.size.width * 0.5f,
337 oval_bounds.size.height * 0.5f};
338 const Point center = {oval_bounds.origin.x + radius.x,
339 oval_bounds.origin.y + radius.y};
340
341 Vector2 p1_unit(std::cos(start.radians), std::sin(start.radians));
342
343 if (use_center) {
344 MoveTo(center);
345 LineTo(center + p1_unit * radius);
346 } else {
347 MoveTo(center + p1_unit * radius);
348 }
349
350 while (sweep.radians > 0) {
351 Vector2 p2_unit;
352 Scalar quadrant_angle;
353 if (sweep.radians < kPiOver2) {
354 quadrant_angle = sweep.radians;
355 p2_unit = Vector2(std::cos(start.radians + quadrant_angle),
356 std::sin(start.radians + quadrant_angle));
357 } else {
358 quadrant_angle = kPiOver2;
359 p2_unit = Vector2(-p1_unit.y, p1_unit.x);
360 }
361
362 Vector2 arc_cp_lengths =
363 (quadrant_angle / kPiOver2) * kArcApproximationMagic * radius;
364
365 Point p1 = center + p1_unit * radius;
366 Point p2 = center + p2_unit * radius;
367 Point cp1 = p1 + Vector2(-p1_unit.y, p1_unit.x) * arc_cp_lengths;
368 Point cp2 = p2 + Vector2(p2_unit.y, -p2_unit.x) * arc_cp_lengths;
369
370 prototype_.AddCubicComponent(p1, cp1, cp2, p2);
371 current_ = p2;
372
373 start.radians += quadrant_angle;
374 sweep.radians -= quadrant_angle;
375 p1_unit = p2_unit;
376 }
377
378 if (use_center) {
379 Close();
380 }
381
382 return *this;
383 }

References Close(), impeller::TSize< T >::height, impeller::k2Pi, kArcApproximationMagic, impeller::kPiOver2, LineTo(), MoveTo(), impeller::TRect< T >::origin, impeller::Radians::radians, impeller::TRect< T >::size, impeller::TSize< T >::width, impeller::TPoint< T >::x, and impeller::TPoint< T >::y.

Referenced by impeller::DlDispatcher::drawArc().

## ◆ AddCircle()

PathBuilder & impeller::PathBuilder::AddCircle | ( | const Point & | center,
|  | Scalar | radius
| ) |  |

Definition at line 198 of file path_builder.cc.

198 {
199 return AddOval(Rect{c.x - r, c.y - r, 2.0f * r, 2.0f * r});
200 }

References AddOval(), impeller::TPoint< T >::x, and impeller::TPoint< T >::y.

Referenced by impeller::Canvas::DrawCircle(), impeller::testing::TEST(), and impeller::testing::TEST_P().

## ◆ AddCubicCurve()

PathBuilder & impeller::PathBuilder::AddCubicCurve | ( | Point | p1,
|  | Point | cp1,
|  | Point | cp2,
|  | Point | p2
| ) |  |

Move to point `p1`, then insert a cubic curve from `p1` to `p2` with control points `cp1` and `cp2`.

Definition at line 172 of file path_builder.cc.

175 {
176 MoveTo(p1);
177 prototype_.AddCubicComponent(p1, cp1, cp2, p2);
178 return *this;
179 }

References MoveTo().

Referenced by impeller::testing::TEST(), and impeller::testing::TEST_P().

## ◆ AddLine()

PathBuilder & impeller::PathBuilder::AddLine | ( | const Point & | p1,
|  | const Point & | p2
| ) |  |

Move to point `p1`, then insert a line from `p1` to `p2`.

Definition at line 433 of file path_builder.cc.

433 {
434 MoveTo(p1);
435 prototype_.AddLinearComponent(p1, p2);
436 return *this;
437 }

References MoveTo().

Referenced by impeller::DlDispatcher::drawLine(), impeller::DlDispatcher::drawPoints(), impeller::testing::TEST(), and impeller::testing::TEST_P().

## ◆ AddOval()

PathBuilder & impeller::PathBuilder::AddOval | ( | const Rect & | rect | ) |

Definition at line 385 of file path_builder.cc.

385 {
386 const Point r = {container.size.width * 0.5f, container.size.height * 0.5f};
387 const Point c = {container.origin.x + r.x, container.origin.y + r.y};
388 const Point m = {kArcApproximationMagic * r.x, kArcApproximationMagic * r.y};
389
390 MoveTo({c.x, c.y - r.y});
391
392 //----------------------------------------------------------------------------
393 // Top right arc.
394 //
395 prototype_.AddCubicComponent({c.x, c.y - r.y}, // p1
396 {c.x + m.x, c.y - r.y}, // cp1
397 {c.x + r.x, c.y - m.y}, // cp2
398 {c.x + r.x, c.y} // p2
399 );
400
401 //----------------------------------------------------------------------------
402 // Bottom right arc.
403 //
404 prototype_.AddCubicComponent({c.x + r.x, c.y}, // p1
405 {c.x + r.x, c.y + m.y}, // cp1
406 {c.x + m.x, c.y + r.y}, // cp2
407 {c.x, c.y + r.y} // p2
408 );
409
410 //----------------------------------------------------------------------------
411 // Bottom left arc.
412 //
413 prototype_.AddCubicComponent({c.x, c.y + r.y}, // p1
414 {c.x - m.x, c.y + r.y}, // cp1
415 {c.x - r.x, c.y + m.y}, // cp2
416 {c.x - r.x, c.y} // p2
417 );
418
419 //----------------------------------------------------------------------------
420 // Top left arc.
421 //
422 prototype_.AddCubicComponent({c.x - r.x, c.y}, // p1
423 {c.x - r.x, c.y - m.y}, // cp1
424 {c.x - m.x, c.y - r.y}, // cp2
425 {c.x, c.y - r.y} // p2
426 );
427
428 Close();
429
430 return *this;
431 }

References Close(), impeller::TSize< T >::height, kArcApproximationMagic, MoveTo(), impeller::TRect< T >::origin, impeller::TRect< T >::size, impeller::TSize< T >::width, impeller::TPoint< T >::x, and impeller::TPoint< T >::y.

Referenced by AddCircle(), impeller::DlDispatcher::drawOval(), and impeller::testing::TEST().

## ◆ AddPath()

PathBuilder & impeller::PathBuilder::AddPath | ( | const Path & | path | ) |

Definition at line 443 of file path_builder.cc.

443 {
444 auto linear = [&](size_t index, const LinearPathComponent& l) {
445 prototype_.AddLinearComponent(l.p1, l.p2);
446 };
447 auto quadratic = [&](size_t index, const QuadraticPathComponent& q) {
448 prototype_.AddQuadraticComponent(q.p1, q.cp, q.p2);
449 };
450 auto cubic = [&](size_t index, const CubicPathComponent& c) {
451 prototype_.AddCubicComponent(c.p1, c.cp1, c.cp2, c.p2);
452 };
453 auto move = [&](size_t index, const ContourComponent& m) {
454 prototype_.AddContourComponent(m.destination);
455 };
456 path.EnumerateComponents(linear, quadratic, cubic, move);
457 return *this;
458 }

References impeller::Path::EnumerateComponents().

Referenced by impeller::DlDispatcher::drawDRRect().

## ◆ AddQuadraticCurve()

PathBuilder & impeller::PathBuilder::AddQuadraticCurve | ( | Point | p1,
|  | Point | cp,
|  | Point | p2
| ) |  |

Move to point `p1`, then insert a quadradic curve from `p1` to `p2` with the control point `cp`.

Definition at line 166 of file path_builder.cc.

166 {
167 MoveTo(p1);
168 prototype_.AddQuadraticComponent(p1, cp, p2);
169 return *this;
170 }

References MoveTo().

Referenced by impeller::testing::TEST(), and impeller::testing::TEST_P().

## ◆ AddRect()

PathBuilder & impeller::PathBuilder::AddRect | ( | Rect | rect | ) |

Definition at line 181 of file path_builder.cc.

181 {
182 current_ = rect.origin;
183
184 auto tl = rect.origin;
185 auto bl = rect.origin + Point{0.0, rect.size.height};
186 auto br = rect.origin + Point{rect.size.width, rect.size.height};
187 auto tr = rect.origin + Point{rect.size.width, 0.0};
188
189 MoveTo(tl);
190 prototype_.AddLinearComponent(tl, tr)
191 .AddLinearComponent(tr, br)
192 .AddLinearComponent(br, bl);
193 Close();
194
195 return *this;
196 }

References Close(), impeller::TSize< T >::height, MoveTo(), impeller::TRect< T >::origin, impeller::TRect< T >::size, and impeller::TSize< T >::width.

Referenced by AddRoundedRect(), impeller::testing::CreatePassWithRectPath(), impeller::Canvas::DrawRect(), impeller::testing::TEST(), and impeller::testing::TEST_P().

## ◆ AddRoundedRect() [1/2]

PathBuilder & impeller::PathBuilder::AddRoundedRect | ( | Rect | rect,
|  | RoundingRadii | radii
| ) |  |

Definition at line 207 of file path_builder.cc.

207 {
208 if (radii.AreAllZero()) {
209 return AddRect(rect);
210 }
211
212 current_ = rect.origin + Point{radii.top_left.x, 0.0};
213
214 MoveTo({rect.origin.x + radii.top_left.x, rect.origin.y});
215
216 //----------------------------------------------------------------------------
217 // Top line.
218 //
219 prototype_.AddLinearComponent(
220 {rect.origin.x + radii.top_left.x, rect.origin.y},
221 {rect.origin.x + rect.size.width - radii.top_right.x, rect.origin.y});
222
223 //----------------------------------------------------------------------------
224 // Top right arc.
225 //
226 AddRoundedRectTopRight(rect, radii);
227
228 //----------------------------------------------------------------------------
229 // Right line.
230 //
231 prototype_.AddLinearComponent(
232 {rect.origin.x + rect.size.width, rect.origin.y + radii.top_right.y},
233 {rect.origin.x + rect.size.width,
234 rect.origin.y + rect.size.height - radii.bottom_right.y});
235
236 //----------------------------------------------------------------------------
237 // Bottom right arc.
238 //
239 AddRoundedRectBottomRight(rect, radii);
240
241 //----------------------------------------------------------------------------
242 // Bottom line.
243 //
244 prototype_.AddLinearComponent(
245 {rect.origin.x + rect.size.width - radii.bottom_right.x,
246 rect.origin.y + rect.size.height},
247 {rect.origin.x + radii.bottom_left.x, rect.origin.y + rect.size.height});
248
249 //----------------------------------------------------------------------------
250 // Bottom left arc.
251 //
252 AddRoundedRectBottomLeft(rect, radii);
253
254 //----------------------------------------------------------------------------
255 // Left line.
256 //
257 prototype_.AddLinearComponent(
258 {rect.origin.x, rect.origin.y + rect.size.height - radii.bottom_left.y},
259 {rect.origin.x, rect.origin.y + radii.top_left.y});
260
261 //----------------------------------------------------------------------------
262 // Top left arc.
263 //
264 AddRoundedRectTopLeft(rect, radii);
265
266 Close();
267
268 return *this;
269 }

References AddRect(), impeller::PathBuilder::RoundingRadii::AreAllZero(), impeller::PathBuilder::RoundingRadii::bottom_left, impeller::PathBuilder::RoundingRadii::bottom_right, Close(), impeller::TSize< T >::height, MoveTo(), impeller::TRect< T >::origin, impeller::TRect< T >::size, impeller::PathBuilder::RoundingRadii::top_left, impeller::PathBuilder::RoundingRadii::top_right, impeller::TSize< T >::width, impeller::TPoint< T >::x, and impeller::TPoint< T >::y.

Referenced by AddRoundedRect(), impeller::Canvas::ClipRRect(), impeller::Canvas::DrawRRect(), impeller::testing::TEST(), impeller::testing::TEST_P(), and impeller::skia_conversions::ToPath().

## ◆ AddRoundedRect() [2/2]

PathBuilder & impeller::PathBuilder::AddRoundedRect | ( | Rect | rect,
|  | Scalar | radius
| ) |  |

Definition at line 202 of file path_builder.cc.

202 {
203 return radius <= 0.0 ? AddRect(rect)
204 : AddRoundedRect(rect, {radius, radius, radius, radius});
205 }

References AddRect(), and AddRoundedRect().

## ◆ Close()

PathBuilder & impeller::PathBuilder::Close | ( |  | ) |

Definition at line 39 of file path_builder.cc.

39 {
40 LineTo(subpath_start_);
41 prototype_.SetContourClosed(true);
42 prototype_.AddContourComponent(current_);
43 return *this;
44 }

References LineTo().

Referenced by AddArc(), AddOval(), AddRect(), AddRoundedRect(), impeller::Close(), impeller::testing::TEST(), impeller::testing::TEST_P(), and impeller::skia_conversions::ToPath().

## ◆ CopyPath()

Path impeller::PathBuilder::CopyPath | ( | FillType | fill = `FillType::kNonZero` | ) | const

Definition at line 15 of file path_builder.cc.

15 {
16 auto path = prototype_;
17 path.SetFillType(fill);
18 return path;
19 }

Referenced by impeller::Tessellate().

## ◆ CubicCurveTo()

PathBuilder & impeller::PathBuilder::CubicCurveTo | ( | Point | controlPoint1,
|  | Point | controlPoint2,
|  | Point | point,
|  | bool | relative = `false`
| ) |  |

Insert a cubic curve from the curren position to `point` using the control points `controlPoint1` and `controlPoint2`.

If `relative` is true the `point`, `controlPoint1`, and `controlPoint2` are relative to current location.

Definition at line 116 of file path_builder.cc.

119 {
120 controlPoint1 = relative ? current_ + controlPoint1 : controlPoint1;
121 controlPoint2 = relative ? current_ + controlPoint2 : controlPoint2;
122 point = relative ? current_ + point : point;
123 prototype_.AddCubicComponent(current_, controlPoint1, controlPoint2, point);
124 current_ = point;
125 return *this;
126 }

Referenced by impeller::CubicTo(), SmoothCubicCurveTo(), and impeller::skia_conversions::ToPath().

## ◆ GetCurrentPath()

const Path & impeller::PathBuilder::GetCurrentPath | ( |  | ) | const

Definition at line 439 of file path_builder.cc.

439 {
440 return prototype_;
441 }

## ◆ HorizontalLineTo()

PathBuilder & impeller::PathBuilder::HorizontalLineTo | ( | Scalar | x,
|  | bool | relative = `false`
| ) |  |

Definition at line 53 of file path_builder.cc.

53 {
54 Point endpoint =
55 relative ? Point{current_.x + x, current_.y} : Point{x, current_.y};
56 prototype_.AddLinearComponent(current_, endpoint);
57 current_ = endpoint;
58 return *this;
59 }

References impeller::TPoint< T >::x, and impeller::TPoint< T >::y.

## ◆ LineTo()

PathBuilder & impeller::PathBuilder::LineTo | ( | Point | point,
|  | bool | relative = `false`
| ) |  |

Insert a line from the current position to `point`.

If `relative` is true, then `point` is relative to the current location.

Definition at line 46 of file path_builder.cc.

46 {
47 point = relative ? current_ + point : point;
48 prototype_.AddLinearComponent(current_, point);
49 current_ = point;
50 return *this;
51 }

Referenced by AddArc(), Close(), impeller::LineTo(), impeller::testing::TEST(), impeller::testing::TEST_P(), and impeller::skia_conversions::ToPath().

## ◆ MoveTo()

PathBuilder & impeller::PathBuilder::MoveTo | ( | Point | point,
|  | bool | relative = `false`
| ) |  |

Definition at line 32 of file path_builder.cc.

32 {
33 current_ = relative ? current_ + point : point;
34 subpath_start_ = current_;
35 prototype_.AddContourComponent(current_);
36 return *this;
37 }

Referenced by AddArc(), AddCubicCurve(), AddLine(), AddOval(), AddQuadraticCurve(), AddRect(), AddRoundedRect(), impeller::MoveTo(), impeller::testing::TEST(), impeller::testing::TEST_P(), and impeller::skia_conversions::ToPath().

## ◆ QuadraticCurveTo()

PathBuilder & impeller::PathBuilder::QuadraticCurveTo | ( | Point | controlPoint,
|  | Point | point,
|  | bool | relative = `false`
| ) |  |

Insert a quadradic curve from the current position to `point` using the control point `controlPoint`.

If `relative` is true the `point` and `controlPoint` are relative to current location.

Definition at line 69 of file path_builder.cc.

71 {
72 point = relative ? current_ + point : point;
73 controlPoint = relative ? current_ + controlPoint : controlPoint;
74 prototype_.AddQuadraticComponent(current_, controlPoint, point);
75 current_ = point;
76 return *this;
77 }

Referenced by SmoothQuadraticCurveTo(), and impeller::skia_conversions::ToPath().

## ◆ SetBounds()

PathBuilder & impeller::PathBuilder::SetBounds | ( | Rect | bounds | ) |

Set the bounding box that will be used by `Path.GetBoundingBox` in place of performing the computation.

       When Impeller recieves Skia Path objects, many of these already
       have computed bounds. This method is used to avoid needlessly
       recomputing these bounds.

Definition at line 465 of file path_builder.cc.

465 {
466 prototype_.SetBounds(bounds);
467 did_compute_bounds_ = true;
468 return *this;
469 }

Referenced by impeller::skia_conversions::ToPath().

## ◆ SetConvexity()

PathBuilder & impeller::PathBuilder::SetConvexity | ( | Convexity | value | ) |

Definition at line 111 of file path_builder.cc.

111 {
112 convexity_ = value;
113 return *this;
114 }

Referenced by impeller::Canvas::ClipRRect(), impeller::Canvas::DrawCircle(), impeller::DlDispatcher::drawLine(), impeller::DlDispatcher::drawOval(), impeller::Canvas::DrawRRect(), impeller::testing::TEST_P(), and impeller::skia_conversions::ToPath().

## ◆ Shift()

PathBuilder & impeller::PathBuilder::Shift | ( | Point | offset | ) |

Transform the existing path segments and contours by the given `offset`.

Definition at line 460 of file path_builder.cc.

460 {
461 prototype_.Shift(offset);
462 return *this;
463 }

Referenced by impeller::testing::TEST(), and impeller::skia_conversions::ToPath().

## ◆ SmoothCubicCurveTo()

PathBuilder & impeller::PathBuilder::SmoothCubicCurveTo | ( | Point | controlPoint2,
|  | Point | point,
|  | bool | relative = `false`
| ) |  |

Definition at line 151 of file path_builder.cc.

153 {
154 auto controlPoint1 = ReflectedCubicControlPoint1();
155 controlPoint2 = relative ? current_ + controlPoint2 : controlPoint2;
156 auto endpoint = relative ? current_ + point : point;
157
158 CubicCurveTo(endpoint, // endpoint
159 controlPoint1, // control point 1
160 controlPoint2, // control point 2
161 false // relative since all points are already absolute
162 );
163 return *this;
164 }

References CubicCurveTo().

## ◆ SmoothQuadraticCurveTo()

PathBuilder & impeller::PathBuilder::SmoothQuadraticCurveTo | ( | Point | point,
|  | bool | relative = `false`
| ) |  |

Definition at line 101 of file path_builder.cc.

101 {
102 point = relative ? current_ + point : point;
103 /*
104 * The reflected control point is absolute and we made the endpoint absolute
105 * too. So there the last argument is always false (i.e, not relative).
106 */
107 QuadraticCurveTo(point, ReflectedQuadraticControlPoint1(), false);
108 return *this;
109 }

References QuadraticCurveTo().

## ◆ TakePath()

Path impeller::PathBuilder::TakePath | ( | FillType | fill = `FillType::kNonZero` | ) |

Definition at line 21 of file path_builder.cc.

21 {
22 auto path = prototype_;
23 path.SetFillType(fill);
24 path.SetConvexity(convexity_);
25 if (!did_compute_bounds_) {
26 path.ComputeBounds();
27 }
28 did_compute_bounds_ = false;
29 return path;
30 }

Referenced by impeller::Canvas::ClipRRect(), impeller::DlDispatcher::drawArc(), impeller::Canvas::DrawCircle(), impeller::DlDispatcher::drawDRRect(), impeller::DlDispatcher::drawLine(), impeller::DlDispatcher::drawOval(), impeller::DlDispatcher::drawPoints(), impeller::Canvas::DrawRRect(), impeller::testing::TEST(), impeller::testing::TEST_P(), and impeller::skia_conversions::ToPath().

## ◆ VerticalLineTo()

PathBuilder & impeller::PathBuilder::VerticalLineTo | ( | Scalar | y,
|  | bool | relative = `false`
| ) |  |

Definition at line 61 of file path_builder.cc.

61 {
62 Point endpoint =
63 relative ? Point{current_.x, current_.y + y} : Point{current_.x, y};
64 prototype_.AddLinearComponent(current_, endpoint);
65 current_ = endpoint;
66 return *this;
67 }

References impeller::TPoint< T >::x, and impeller::TPoint< T >::y.

## Member Data Documentation

## ◆ kArcApproximationMagic

constexpr static const Scalar impeller::PathBuilder::kArcApproximationMagic = 0.551915024494f
| static constexpr

Used for approximating quarter circle arcs with cubic curves. This is the control point distance which results in the smallest possible unit circle integration for a right angle arc. It can be used to approximate arcs less than 90 degrees to great effect by simply reducing it proportionally to the angle. However, accuracy rapidly diminishes if magnified for obtuse angle arcs, and so multiple cubic curves should be used when approximating arcs greater than 90 degrees.

Definition at line 22 of file path_builder.h.

Referenced by AddArc(), and AddOval().

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

- impeller/geometry/path_builder.h
- impeller/geometry/path_builder.cc

impeller::TPoint::y
Type y
Definition: point.h:24
impeller::Scalar
float Scalar
Definition: scalar.h:15
impeller::PathBuilder::CubicCurveTo
PathBuilder & CubicCurveTo(Point controlPoint1, Point controlPoint2, Point point, bool relative=false)
Insert a cubic curve from the curren position to point using the control points controlPoint1 and con...
Definition: path_builder.cc:116
impeller::Vector2
Point Vector2
Definition: point.h:310
impeller::PathBuilder::AddRoundedRect
PathBuilder & AddRoundedRect(Rect rect, RoundingRadii radii)
Definition: path_builder.cc:207
impeller::PathBuilder::kArcApproximationMagic
constexpr static const Scalar kArcApproximationMagic
Definition: path_builder.h:22
impeller::PathBuilder::AddRect
PathBuilder & AddRect(Rect rect)
Definition: path_builder.cc:181
impeller::kPiOver2
constexpr float kPiOver2
Definition: constants.h:31
impeller::Point
TPoint< Scalar > Point
Definition: point.h:306
impeller::k2Pi
constexpr float k2Pi
Definition: constants.h:28
impeller::Path::EnumerateComponents
void EnumerateComponents(const Applier< LinearPathComponent > &linear_applier, const Applier< QuadraticPathComponent > &quad_applier, const Applier< CubicPathComponent > &cubic_applier, const Applier< ContourComponent > &contour_applier) const
Definition: path.cc:125
impeller::PathBuilder::QuadraticCurveTo
PathBuilder & QuadraticCurveTo(Point controlPoint, Point point, bool relative=false)
Insert a quadradic curve from the current position to point using the control point controlPoint.
Definition: path_builder.cc:69
impeller::PathBuilder::LineTo
PathBuilder & LineTo(Point point, bool relative=false)
Insert a line from the current position to point.
Definition: path_builder.cc:46
impeller::Rect
TRect< Scalar > Rect
Definition: rect.h:306
impeller::TPoint::x
Type x
Definition: point.h:23
impeller::PathBuilder::Close
PathBuilder & Close()
Definition: path_builder.cc:39
impeller::PathBuilder::MoveTo
PathBuilder & MoveTo(Point point, bool relative=false)
Definition: path_builder.cc:32
impeller::PathBuilder::AddOval
PathBuilder & AddOval(const Rect &rect)
Definition: path_builder.cc:385