aboutsummaryrefslogtreecommitdiff
path: root/docs/SkPath_Overview.bmh
blob: 70ab8bd35945098790ae0c6bd8a4269cf5243935 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#Topic Path_Overview

Path contains Lines and Curves which can be stroked or filled. Contour is
composed of a series of connected Lines and Curves. Path may contain zero,
one, or more Contours.
Each Line and Curve are described by Verb, Points, and optional Path_Conic_Weight.

Each pair of connected Lines and Curves share common Point; for instance, Path
containing two connected Lines are described the Path_Verb sequence:
SkPath::kMove_Verb, SkPath::kLine_Verb, SkPath::kLine_Verb; and a Point sequence
with three entries, sharing
the middle entry as the end of the first Line and the start of the second Line.

Path components Arc, Rect, Round_Rect, Circle, and Oval are composed of
Lines and Curves with as many Verbs and Points required
for an exact description. Once added to Path, these components may lose their
identity; although Path can be inspected to determine if it describes a single
Rect, Oval, Round_Rect, and so on.

#Example
#Height 192
#Description
Path contains three Contours: Line, Circle, and Quad. Line is stroked but
not filled. Circle is stroked and filled; Circle stroke forms a loop. Quad
is stroked and filled, but since it is not closed, Quad does not stroke a loop.
##
void draw(SkCanvas* canvas) {
    SkPaint paint;
    paint.setAntiAlias(true);
    SkPath path;
    path.moveTo(124, 108);
    path.lineTo(172, 24);
    path.addCircle(50, 50, 30);
    path.moveTo(36, 148);
    path.quadTo(66, 188, 120, 136);
    canvas->drawPath(path, paint);
    paint.setStyle(SkPaint::kStroke_Style);
    paint.setColor(SK_ColorBLUE);
    paint.setStrokeWidth(3);
    canvas->drawPath(path, paint);
}
##

Path contains a Path_Fill_Type which determines whether overlapping Contours
form fills or holes. Path_Fill_Type also determines whether area inside or outside
Lines and Curves is filled.

#Example
#Height 192
#Description
Path is drawn filled, then stroked, then stroked and filled.
##
void draw(SkCanvas* canvas) {
    SkPaint paint;
    paint.setAntiAlias(true);
    SkPath path;
    path.moveTo(36, 48);
    path.quadTo(66, 88, 120, 36);
    canvas->drawPath(path, paint);
    paint.setStyle(SkPaint::kStroke_Style);
    paint.setColor(SK_ColorBLUE);
    paint.setStrokeWidth(8);
    canvas->translate(0, 50);
    canvas->drawPath(path, paint);
    paint.setStyle(SkPaint::kStrokeAndFill_Style);
    paint.setColor(SK_ColorRED);
    canvas->translate(0, 50);
    canvas->drawPath(path, paint);
}
##

Path contents are never shared. Copying Path by value effectively creates
a new Path independent of the original. Internally, the copy does not duplicate
its contents until it is edited, to reduce memory use and improve performance.

#Subtopic Contour
#Alias Path_Contour ##
#Alias Contour ##
#Alias Contours ##
#Line # loop of lines and curves ##

Contour contains one or more Verbs, and as many Points as
are required to satisfy Path_Verb_Array. First Path_Verb in Path is always
SkPath::kMove_Verb; each SkPath::kMove_Verb that follows starts a new Contour.

#Example
#Description
Each SkPath::moveTo starts a new Contour, and content after SkPath::close()
also starts a new Contour. Since SkPath::conicTo is not preceded by
SkPath::moveTo, the first Point of the third Contour starts at the last Point
of the second Contour.
##
#Height 192
    SkPaint paint;
    paint.setAntiAlias(true);
    canvas->drawString("1st contour", 150, 100, paint);
    canvas->drawString("2nd contour", 130, 160, paint);
    canvas->drawString("3rd contour", 40, 30, paint);
    paint.setStyle(SkPaint::kStroke_Style);
    SkPath path;
    path.moveTo(124, 108);
    path.lineTo(172, 24);
    path.moveTo(36, 148);
    path.quadTo(66, 188, 120, 136);
    path.close();
    path.conicTo(70, 20, 110, 40, 0.6f);
    canvas->drawPath(path, paint);
##

If final Path_Verb in Contour is SkPath::kClose_Verb, Line connects Path_Last_Point in
Contour with first Point. A closed Contour, stroked, draws
Paint_Stroke_Join at Path_Last_Point and first Point. Without SkPath::kClose_Verb
as final Verb, Path_Last_Point and first Point are not connected; Contour
remains open. An open Contour, stroked, draws Paint_Stroke_Cap at
Path_Last_Point and first Point.

#Example
#Height 160
#Description
Path is drawn stroked, with an open Contour and a closed Contour.
##
void draw(SkCanvas* canvas) {
    SkPaint paint;
    paint.setAntiAlias(true);
    paint.setStyle(SkPaint::kStroke_Style);
    paint.setStrokeWidth(8);
    SkPath path;
    path.moveTo(36, 48);
    path.quadTo(66, 88, 120, 36);
    canvas->drawPath(path, paint);
    path.close();
    canvas->translate(0, 50);
    canvas->drawPath(path, paint);
}
##

#Subtopic Zero_Length
#Alias Zero_Length_Contour ##
#Line # consideration when contour has no length ##
Contour length is distance traveled from first Point to Path_Last_Point,
plus, if Contour is closed, distance from Path_Last_Point to first Point.
Even if Contour length is zero, stroked Lines are drawn if Paint_Stroke_Cap
makes them visible.

#Example
#Height 64
    SkPaint paint;
    paint.setAntiAlias(true);
    paint.setStyle(SkPaint::kStroke_Style);
    paint.setStrokeWidth(8);
    paint.setStrokeCap(SkPaint::kRound_Cap);
    SkPath path;
    path.moveTo(36, 48);
    path.lineTo(36, 48);
    canvas->drawPath(path, paint);
    path.reset();
    paint.setStrokeCap(SkPaint::kSquare_Cap);
    path.moveTo(56, 48);
    path.close();
    canvas->drawPath(path, paint);
##

#Subtopic Zero_Length ##

#Subtopic Contour ##

# ------------------------------------------------------------------------------

#Topic Path_Overview ##