Skip to content

Commit 6b35b3c

Browse files
committed
Renames widthAndHeight to diameter. Factors keyCode example out to own example
1 parent f916a95 commit 6b35b3c

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

src/events/keyboard.js

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,6 @@ p5.prototype._onblur = function(e) {
322322
* <div><code>
323323
* var x = 100;
324324
* var y = 100;
325-
* var widthAndHeight = 50;
326325
*
327326
* function setup() {
328327
* createCanvas(512, 512);
@@ -345,24 +344,39 @@ p5.prototype._onblur = function(e) {
345344
* y += 5;
346345
* }
347346
*
347+
* clear();
348+
* fill(255, 0, 0);
349+
* ellipse(x, y, 50, 50);
350+
* }
351+
* </code></div>
352+
*
353+
* <div><code>
354+
* var diameter = 50;
355+
*
356+
* function setup() {
357+
* createCanvas(512, 512);
358+
* }
359+
*
360+
* function draw() {
348361
* // 107 and 187 are keyCodes for "+"
349362
* if (keyIsDown(107) || keyIsDown(187)) {
350-
* widthAndHeight += 1;
363+
* diameter += 1;
351364
* }
352365
*
353366
* // 109 and 189 are keyCodes for "-"
354367
* if (keyIsDown(109) || keyIsDown(189)) {
355-
* widthAndHeight -= 1;
368+
* diameter -= 1;
356369
* }
357370
*
358371
* clear();
359372
* fill(255, 0, 0);
360-
* ellipse(x, y, widthAndHeight, widthAndHeight);
373+
* ellipse(50, 50, diameter, diameter);
361374
* }
362375
* </code></div>
363376
*
364377
* @alt
365378
* 50x50 red ellipse moves left, right, up and down with arrow presses.
379+
* 50x50 red ellipse gets bigger or smaller when + or - are pressed.
366380
*
367381
*/
368382
p5.prototype.keyIsDown = function(code) {

0 commit comments

Comments
 (0)