Flutter Engine
 
Loading...
Searching...
No Matches
path_builder.cc
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
6
8
9namespace impeller::interop {
10
11PathBuilder::PathBuilder() = default;
12
13PathBuilder::~PathBuilder() = default;
14
15void PathBuilder::MoveTo(const Point& point) {
16 builder_.moveTo(ToSkiaType(point));
17}
18
19void PathBuilder::LineTo(const Point& location) {
20 builder_.lineTo(ToSkiaType(location));
21}
22
23void PathBuilder::QuadraticCurveTo(const Point& control_point,
24 const Point& end_point) {
25 builder_.quadTo(ToSkiaType(control_point), ToSkiaType(end_point));
26}
27
28void PathBuilder::CubicCurveTo(const Point& control_point_1,
29 const Point& control_point_2,
30 const Point& end_point) {
31 builder_.cubicTo(ToSkiaType(control_point_1), //
32 ToSkiaType(control_point_2), //
33 ToSkiaType(end_point) //
34 );
35}
36
37void PathBuilder::AddRect(const Rect& rect) {
38 builder_.addRect(ToSkiaType(rect));
39}
40
41void PathBuilder::AddArc(const Rect& oval_bounds,
42 Degrees start_angle,
43 Degrees end_angle) {
44 builder_.addArc(ToSkiaType(oval_bounds), //
45 start_angle.degrees, //
46 end_angle.degrees - start_angle.degrees // sweep
47 );
48}
49
50void PathBuilder::AddOval(const Rect& oval_bounds) {
51 builder_.addOval(ToSkiaType(oval_bounds));
52}
53
54void PathBuilder::AddRoundedRect(const Rect& rect, const RoundingRadii& radii) {
55 builder_.addRRect(ToSkiaType(rect, radii));
56}
57
59 builder_.close();
60}
61
63 builder_.setFillType(ToSkiaType(fill));
64 return Create<Path>(builder_.detach());
65}
66
68 builder_.setFillType(ToSkiaType(fill));
69 return Create<Path>(builder_.snapshot());
70}
71
72} // namespace impeller::interop
DlPathBuilder & LineTo(DlPoint p2)
Draw a line from the current point to the indicated point p2.
DlPathBuilder & MoveTo(DlPoint p2)
Start a new contour that will originate at the indicated point p2.
const DlPath CopyPath()
Returns the path constructed by this path builder so far and retains all current geometry to continue...
const DlPath TakePath()
Returns the path constructed by this path builder and resets its internal state to the default state ...
DlPathBuilder & AddRect(const DlRect &rect)
Append a closed rectangular contour to the path.
DlPathBuilder & QuadraticCurveTo(DlPoint cp, DlPoint p2)
Draw a quadratic bezier curve from the current point to the indicated point p2, using the indicated p...
DlPathBuilder & Close()
The path is closed back to the location of the most recent MoveTo call. Contours that are filled are ...
DlPathBuilder & AddArc(const DlRect &bounds, DlDegrees start, DlDegrees sweep, bool use_center=false)
Append an arc contour to the path which:
DlPathBuilder & AddOval(const DlRect &bounds)
Append a closed elliptical contour to the path inscribed in the provided bounds.
DlPathBuilder & CubicCurveTo(DlPoint cp1, DlPoint cp2, DlPoint p2)
Draw a cubic bezier curve from the current point to the indicated point p2, using the indicated point...
constexpr std::optional< SkRect > ToSkiaType(const ImpellerRect *rect)
Definition formats.h:30
Scalar degrees
Definition scalar.h:67