@@ -36,8 +36,47 @@ slug: learn/
36
36
<h3 >{{ #i18n " labeling-canvases-best-practices-what-requires-labeling" }} {{ /i18n }} </h3 >
37
37
<p >{{ #i18n " labeling-canvases-best-practices-what-requires-labeling-1" }} {{ /i18n }} </p >
38
38
<p >{{ #i18n " labeling-canvases-best-practices-what-requires-labeling-2" }} {{ /i18n }} </p >
39
+
40
+
41
+ <!-- Code example below copied from Reference page: https://p5js.org/reference/#/p5/describe-->
42
+
43
+ <script type =" text/p5" data-p5-version =" {{ version }} " >
44
+ function setup () {
45
+ createCanvas (100 , 100 );
46
+ }
47
+
48
+ function draw () {
49
+ background (255 ,192 ,203 );
50
+ noStroke ();
51
+ fill (200 ,0 ,0 );
52
+
53
+ describeElement (" Heart" ," Red heart in the bottom right corner." );
54
+ ellipse (67 , 67 , 20 , 20 );
55
+ ellipse (83 , 67 , 20 , 20 );
56
+ triangle (91 , 73 , 75 , 95 , 59 , 73 );
57
+ }
58
+ </script >
59
+
39
60
<p >{{ #i18n " labeling-canvases-best-practices-what-requires-labeling-3" }} {{ /i18n }} </p >
40
61
<p >{{ #i18n " labeling-canvases-best-practices-what-requires-labeling-4" }} {{ /i18n }} </p >
62
+
63
+ <script type =" text/p5" data-p5-version =" {{ version }} " >
64
+ function setup () {
65
+ createCanvas (100 , 100 );
66
+ }
67
+
68
+ function draw () {
69
+ background (255 ,192 ,203 );
70
+ noStroke ();
71
+ fill (200 ,0 ,0 );
72
+
73
+ textSize (12 );
74
+ textStyle (NORMAL );
75
+ describeElement (" Text" , " The text 'Hello world!' in the upper left corner of a pink canvas.'" );
76
+ text (' Hello world!' , 5 , 30 );
77
+ }
78
+ </script >
79
+
41
80
<p ><i >{{ #i18n " labeling-canvases-best-practices-what-requires-labeling-5" }} {{ /i18n }} </i ></p >
42
81
43
82
<h3 >{{ #i18n " labeling-canvases-best-practices-dont-label" }} {{ /i18n }} </h3 >
@@ -48,15 +87,92 @@ slug: learn/
48
87
49
88
<h4 >{{ #i18n " labeling-canvases-best-practices-using-labels-all-canvases" }} {{ /i18n }} </h4 >
50
89
<p >{{ #i18n " labeling-canvases-best-practices-using-labels-all-canvases-1" }} {{ /i18n }} </p >
90
+
91
+ <script type =" text/p5" data-p5-version =" {{ version }} " >
92
+ function setup () {
93
+ createCanvas (100 , 100 );
94
+ }
95
+
96
+ function draw () {
97
+ background (250 );
98
+ noStroke ();
99
+
100
+ describe (" Flower with red petals and a green stem on a white canvas." );
101
+
102
+ fill (" #0DCC23" );
103
+ rect (48 , 50 , 5 , 50 );
104
+
105
+ fill (200 ,0 ,0 );
106
+ ellipse (40 , 55 , 18 );
107
+ ellipse (40 , 45 , 18 );
108
+ ellipse (50 , 40 , 18 );
109
+ ellipse (60 , 55 , 18 );
110
+ ellipse (60 , 45 , 18 );
111
+ ellipse (50 , 60 , 18 );
112
+
113
+ fill (" #FFE200" );
114
+ ellipse (50 ,50 ,15 );
115
+ }
116
+ </script >
117
+
51
118
<p >{{ #i18n " labeling-canvases-best-practices-using-labels-all-canvases-2" }} {{ /i18n }} </p >
52
119
53
120
<h4 >{{ #i18n " labeling-canvases-best-practices-using-labels-simple" }} {{ /i18n }} </h4 >
54
121
<p >{{ #i18n " labeling-canvases-best-practices-using-labels-simple-1" }} {{ /i18n }} </p >
122
+
123
+ <script type =" text/p5" data-p5-version =" {{ version }} " >
124
+ function setup () {
125
+ createCanvas (100 , 100 );
126
+ }
127
+
128
+ function draw () {
129
+ background (250 );
130
+ noStroke ();
131
+
132
+ textOutput (LABEL );
133
+
134
+ fill (" #0DCC23" );
135
+ rect (48 , 50 , 5 , 50 );
136
+
137
+ fill (200 ,0 ,0 );
138
+ ellipse (40 , 55 , 18 );
139
+ ellipse (40 , 45 , 18 );
140
+ ellipse (50 , 40 , 18 );
141
+ ellipse (60 , 55 , 18 );
142
+ ellipse (60 , 45 , 18 );
143
+ ellipse (50 , 60 , 18 );
144
+
145
+ fill (" #FFE200" );
146
+ ellipse (50 ,50 ,15 );
147
+ }
148
+ </script >
149
+
55
150
<p >{{ #i18n " labeling-canvases-best-practices-using-labels-simple-2" }} {{ /i18n }} </p >
56
151
<p >{{ #i18n " labeling-canvases-best-practices-using-labels-simple-3" }} {{ /i18n }} </p >
57
152
58
153
<h4 >{{ #i18n " labeling-canvases-best-practices-using-labels-interactive" }} {{ /i18n }} </h4 >
59
154
<p >{{ #i18n " labeling-canvases-best-practices-using-labels-interactive-1" }} {{ /i18n }} </p >
155
+
156
+ <!-- Code example below copied from Reference page: https://p5js.org/reference/#/p5/describe-->
157
+
158
+ <script type =" text/p5" data-p5-version =" {{ version }} " >
159
+ function setup () {
160
+ createCanvas (100 , 100 );
161
+ }
162
+
163
+ let x = 0 ;
164
+ function draw () {
165
+ if (x > 100 ) {
166
+ x = 0 ;
167
+ }
168
+ background (220 );
169
+ fill (0 , 255 , 0 );
170
+ ellipse (x, 50 , 40 , 40 );
171
+ x = x + 0.1 ;
172
+ describe (' green circle at x pos ' + round (x) + ' moving to the right' , LABEL );
173
+ }
174
+ </script >
175
+
60
176
<p >{{ #i18n " labeling-canvases-best-practices-using-labels-interactive-2" }} {{ /i18n }} </p >
61
177
<p >{{ #i18n " labeling-canvases-best-practices-using-labels-interactive-3" }} {{ /i18n }} </p >
62
178
@@ -82,23 +198,33 @@ slug: learn/
82
198
83
199
<h2 >{{ #i18n " labeling-canvases-testing-labels" }} {{ /i18n }} </h2 >
84
200
<p >{{ #i18n " labeling-canvases-testing-labels-1" }} {{ /i18n }} </p >
85
- <p >{{ #i18n " labeling-canvases-testing-labels-2" }} {{ /i18n }} </p >
86
- <p >{{ #i18n " labeling-canvases-testing-labels-3" }} {{ /i18n }} </p >
87
- <br >
88
- <p >{{ #i18n " labeling-canvases-note" }} {{ /i18n }} </p >
89
201
90
- <!-- this script only needs to get added once even if there are multiple widget instances -->
91
- <script src =" //toolness.github.io/p5.js-widget/p5-widget.js" ></script >
92
- <script type =" text/p5" data-p5-version =" {{ version }} " >
202
+ <script type =" text/p5" data-p5-version =" {{ version }} " >
93
203
function setup () {
94
204
createCanvas (100 , 100 );
95
205
}
96
206
97
207
function draw () {
98
- background (255 , 0 , 200 );
208
+ gridOutput (LABEL );
209
+
210
+ background (255 ,192 ,203 );
211
+ noStroke ();
212
+ fill (200 ,0 ,0 );
213
+
214
+ ellipse (67 , 67 , 20 , 20 );
215
+ ellipse (83 , 67 , 20 , 20 );
216
+ triangle (91 , 73 , 75 , 95 , 59 , 73 );
99
217
}
100
218
</script >
101
219
220
+ <p >{{ #i18n " labeling-canvases-testing-labels-2" }} {{ /i18n }} </p >
221
+ <p >{{ #i18n " labeling-canvases-testing-labels-3" }} {{ /i18n }} </p >
222
+ <br >
223
+ <p >{{ #i18n " labeling-canvases-note" }} {{ /i18n }} </p >
224
+
225
+ <!-- this script only needs to get added once even if there are multiple widget instances -->
226
+ <script src =" //toolness.github.io/p5.js-widget/p5-widget.js" ></script >
227
+
102
228
</main >
103
229
104
230
{{> footer }}
0 commit comments