16 auto path = prototype_.
Clone();
17 path.SetFillType(fill);
22 auto path = std::move(prototype_);
23 path.SetFillType(fill);
24 path.SetConvexity(convexity_);
25 if (!did_compute_bounds_) {
28 did_compute_bounds_ =
false;
33 prototype_.points_.reserve(point_size);
34 prototype_.points_.reserve(verb_size);
38 current_ = relative ? current_ + point : point;
39 subpath_start_ = current_;
40 prototype_.AddContourComponent(current_);
46 prototype_.SetContourClosed(
true);
47 prototype_.AddContourComponent(current_);
52 point = relative ? current_ + point : point;
53 prototype_.AddLinearComponent(current_, point);
60 relative ?
Point{current_.
x + x, current_.
y} :
Point{x, current_.
y};
61 prototype_.AddLinearComponent(current_, endpoint);
68 relative ?
Point{current_.
x, current_.
y + y} :
Point{current_.
x, y};
69 prototype_.AddLinearComponent(current_, endpoint);
77 point = relative ? current_ + point : point;
78 controlPoint = relative ? current_ + controlPoint : controlPoint;
79 prototype_.AddQuadraticComponent(current_, controlPoint, point);
93 controlPoint1 = relative ? current_ + controlPoint1 : controlPoint1;
94 controlPoint2 = relative ? current_ + controlPoint2 : controlPoint2;
95 point = relative ? current_ + point : point;
96 prototype_.AddCubicComponent(current_, controlPoint1, controlPoint2, point);
103 prototype_.AddQuadraticComponent(p1, cp, p2);
112 prototype_.AddCubicComponent(p1, cp1, cp2, p2);
121 auto bl = origin +
Point{0.0, size.height};
122 auto br = origin + size;
123 auto tr = origin +
Point{size.width, 0.0};
139 return radius <= 0.0 ?
AddRect(rect)
155 auto rect_size = rect.
GetSize();
164 prototype_.AddLinearComponent(
165 {rect_origin.x + radii.
top_left.
x, rect_origin.y},
166 {rect_origin.x + rect_size.width - radii.
top_right.
x, rect_origin.y});
171 AddRoundedRectTopRight(rect, radii);
176 prototype_.AddLinearComponent(
177 {rect_origin.x + rect_size.width, rect_origin.y + radii.
top_right.
y},
178 {rect_origin.x + rect_size.width,
184 AddRoundedRectBottomRight(rect, radii);
189 prototype_.AddLinearComponent(
191 rect_origin.y + rect_size.height},
192 {rect_origin.x + radii.
bottom_left.
x, rect_origin.y + rect_size.height});
197 AddRoundedRectBottomLeft(rect, radii);
202 prototype_.AddLinearComponent(
203 {rect_origin.x, rect_origin.y + rect_size.height - radii.
bottom_left.
y},
204 {rect_origin.x, rect_origin.y + radii.
top_left.
y});
209 AddRoundedRectTopLeft(rect, radii);
217 RoundingRadii radii) {
220 prototype_.AddCubicComponent(
221 {corner.x, corner.y + radii.top_left.y},
222 {corner.x, corner.y + radii.top_left.y - magic_top_left.y},
223 {corner.x + radii.top_left.x - magic_top_left.x, corner.y},
224 {corner.x + radii.top_left.x, corner.y});
228 PathBuilder& PathBuilder::AddRoundedRectTopRight(
Rect rect,
229 RoundingRadii radii) {
231 const auto corner = rect.GetOrigin() +
Point{rect.GetWidth(), 0};
232 prototype_.AddCubicComponent(
233 {corner.x - radii.top_right.x, corner.y},
234 {corner.x - radii.top_right.x + magic_top_right.x, corner.y},
235 {corner.x, corner.y + radii.top_right.y - magic_top_right.y},
236 {corner.x, corner.y + radii.top_right.y});
240 PathBuilder& PathBuilder::AddRoundedRectBottomRight(
Rect rect,
241 RoundingRadii radii) {
243 const auto corner = rect.GetOrigin() + rect.GetSize();
244 prototype_.AddCubicComponent(
245 {corner.x, corner.y - radii.bottom_right.y},
246 {corner.x, corner.y - radii.bottom_right.y + magic_bottom_right.y},
247 {corner.x - radii.bottom_right.x + magic_bottom_right.x, corner.y},
248 {corner.x - radii.bottom_right.x, corner.y});
252 PathBuilder& PathBuilder::AddRoundedRectBottomLeft(
Rect rect,
253 RoundingRadii radii) {
255 const auto corner = rect.GetOrigin() +
Point{0, rect.GetHeight()};
256 prototype_.AddCubicComponent(
257 {corner.x + radii.bottom_left.x, corner.y},
258 {corner.x + radii.bottom_left.x - magic_bottom_left.x, corner.y},
259 {corner.x, corner.y - radii.bottom_left.y + magic_bottom_left.y},
260 {corner.x, corner.y - radii.bottom_left.y});
282 LineTo(center + p1_unit * radius);
284 MoveTo(center + p1_unit * radius);
291 quadrant_angle = sweep.
radians;
293 std::sin(start.
radians + quadrant_angle));
296 p2_unit =
Vector2(-p1_unit.
y, p1_unit.
x);
302 Point p1 = center + p1_unit * radius;
303 Point p2 = center + p2_unit * radius;
307 prototype_.AddCubicComponent(p1, cp1, cp2, p2);
310 start.
radians += quadrant_angle;
311 sweep.
radians -= quadrant_angle;
332 prototype_.AddCubicComponent({c.
x, c.
y - r.
y},
333 {c.
x + m.
x, c.
y - r.
y},
334 {c.
x + r.
x, c.
y - m.
y},
341 prototype_.AddCubicComponent({c.
x + r.
x, c.
y},
342 {c.
x + r.
x, c.
y + m.
y},
343 {c.
x + m.
x, c.
y + r.
y},
350 prototype_.AddCubicComponent({c.
x, c.
y + r.
y},
351 {c.
x - m.
x, c.
y + r.
y},
352 {c.
x - r.
x, c.
y + m.
y},
359 prototype_.AddCubicComponent({c.
x - r.
x, c.
y},
360 {c.
x - r.
x, c.
y - m.
y},
361 {c.
x - m.
x, c.
y - r.
y},
372 prototype_.AddLinearComponent(p1, p2);
382 prototype_.AddLinearComponent(l.p1, l.p2);
385 prototype_.AddQuadraticComponent(q.p1, q.cp, q.p2);
388 prototype_.AddCubicComponent(c.p1, c.cp1, c.cp2, c.p2);
391 prototype_.AddContourComponent(m.destination);
398 prototype_.Shift(offset);
403 prototype_.SetBounds(bounds);
404 did_compute_bounds_ =
true;