16 auto path = prototype_;
17 path.SetFillType(fill);
22 auto path = prototype_;
23 path.SetFillType(fill);
24 path.SetConvexity(convexity_);
25 if (!did_compute_bounds_) {
28 did_compute_bounds_ =
false;
33 current_ = relative ? current_ + point : point;
34 subpath_start_ = current_;
35 prototype_.AddContourComponent(current_);
41 prototype_.SetContourClosed(
true);
42 prototype_.AddContourComponent(current_);
47 point = relative ? current_ + point : point;
48 prototype_.AddLinearComponent(current_, point);
55 relative ?
Point{current_.
x + x, current_.
y} :
Point{x, current_.
y};
56 prototype_.AddLinearComponent(current_, endpoint);
63 relative ?
Point{current_.
x, current_.
y + y} :
Point{current_.
x, y};
64 prototype_.AddLinearComponent(current_, endpoint);
72 point = relative ? current_ + point : point;
73 controlPoint = relative ? current_ + controlPoint : controlPoint;
74 prototype_.AddQuadraticComponent(current_, controlPoint, point);
79 Point PathBuilder::ReflectedQuadraticControlPoint1()
const {
88 QuadraticPathComponent quad;
98 return (current_ * 2.0) - quad.cp;
102 point = relative ? current_ + point : point;
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);
128 Point PathBuilder::ReflectedCubicControlPoint1()
const {
138 CubicPathComponent cubic;
148 return (current_ * 2.0) - cubic.cp2;
154 auto controlPoint1 = ReflectedCubicControlPoint1();
155 controlPoint2 = relative ? current_ + controlPoint2 : controlPoint2;
156 auto endpoint = relative ? current_ + point : point;
168 prototype_.AddQuadraticComponent(p1, cp, p2);
177 prototype_.AddCubicComponent(p1, cp1, cp2, p2);
190 prototype_.AddLinearComponent(tl, tr)
191 .AddLinearComponent(tr, br)
192 .AddLinearComponent(br, bl);
203 return radius <= 0.0 ?
AddRect(rect)
219 prototype_.AddLinearComponent(
226 AddRoundedRectTopRight(rect, radii);
231 prototype_.AddLinearComponent(
239 AddRoundedRectBottomRight(rect, radii);
244 prototype_.AddLinearComponent(
252 AddRoundedRectBottomLeft(rect, radii);
257 prototype_.AddLinearComponent(
264 AddRoundedRectTopLeft(rect, radii);
272 RoundingRadii radii) {
274 prototype_.AddCubicComponent(
276 {rect.
origin.
x, rect.
origin.
y + radii.top_left.y - magic_top_left.y},
277 {rect.
origin.
x + radii.top_left.x - magic_top_left.x, rect.
origin.
y},
282 PathBuilder& PathBuilder::AddRoundedRectTopRight(
Rect rect,
283 RoundingRadii radii) {
285 prototype_.AddCubicComponent(
286 {rect.origin.x + rect.size.width - radii.top_right.x, rect.origin.y},
287 {rect.origin.x + rect.size.width - radii.top_right.x + magic_top_right.x,
289 {rect.origin.x + rect.size.width,
290 rect.origin.y + radii.top_right.y - magic_top_right.y},
291 {rect.origin.x + rect.size.width, rect.origin.y + radii.top_right.y});
295 PathBuilder& PathBuilder::AddRoundedRectBottomRight(
Rect rect,
296 RoundingRadii radii) {
298 prototype_.AddCubicComponent(
299 {rect.origin.x + rect.size.width,
300 rect.origin.y + rect.size.height - radii.bottom_right.y},
301 {rect.origin.x + rect.size.width, rect.origin.y + rect.size.height -
302 radii.bottom_right.y +
303 magic_bottom_right.y},
304 {rect.origin.x + rect.size.width - radii.bottom_right.x +
305 magic_bottom_right.x,
306 rect.origin.y + rect.size.height},
307 {rect.origin.x + rect.size.width - radii.bottom_right.x,
308 rect.origin.y + rect.size.height});
312 PathBuilder& PathBuilder::AddRoundedRectBottomLeft(
Rect rect,
313 RoundingRadii radii) {
315 prototype_.AddCubicComponent(
316 {rect.origin.x + radii.bottom_left.x, rect.origin.y + rect.size.height},
317 {rect.origin.x + radii.bottom_left.x - magic_bottom_left.x,
318 rect.origin.y + rect.size.height},
319 {rect.origin.x, rect.origin.y + rect.size.height - radii.bottom_left.y +
320 magic_bottom_left.y},
321 {rect.origin.x, rect.origin.y + rect.size.height - radii.bottom_left.y});
345 LineTo(center + p1_unit * radius);
347 MoveTo(center + p1_unit * radius);
354 quadrant_angle = sweep.
radians;
356 std::sin(start.
radians + quadrant_angle));
359 p2_unit =
Vector2(-p1_unit.
y, p1_unit.
x);
365 Point p1 = center + p1_unit * radius;
366 Point p2 = center + p2_unit * radius;
370 prototype_.AddCubicComponent(p1, cp1, cp2, p2);
373 start.
radians += quadrant_angle;
374 sweep.
radians -= quadrant_angle;
395 prototype_.AddCubicComponent({c.
x, c.
y - r.
y},
396 {c.
x + m.
x, c.
y - r.
y},
397 {c.
x + r.
x, c.
y - m.
y},
404 prototype_.AddCubicComponent({c.
x + r.
x, c.
y},
405 {c.
x + r.
x, c.
y + m.
y},
406 {c.
x + m.
x, c.
y + r.
y},
413 prototype_.AddCubicComponent({c.
x, c.
y + r.
y},
414 {c.
x - m.
x, c.
y + r.
y},
415 {c.
x - r.
x, c.
y + m.
y},
422 prototype_.AddCubicComponent({c.
x - r.
x, c.
y},
423 {c.
x - r.
x, c.
y - m.
y},
424 {c.
x - m.
x, c.
y - r.
y},
435 prototype_.AddLinearComponent(p1, p2);
445 prototype_.AddLinearComponent(l.p1, l.p2);
448 prototype_.AddQuadraticComponent(q.p1, q.cp, q.p2);
451 prototype_.AddCubicComponent(c.p1, c.cp1, c.cp2, c.p2);
454 prototype_.AddContourComponent(m.destination);
461 prototype_.Shift(offset);
466 prototype_.SetBounds(bounds);
467 did_compute_bounds_ =
true;