/* built with Studio Sketchpad: * https://sketchpad.cc * * observe the evolution of this sketch: * https://p5js.sketchpad.cc/sp/pad/view/ro.9Lwhble52ds/rev.6 * * authors: * GoToLoop * license (unless otherwise specified): * creative commons attribution-share alike 3.0 license. * https://creativecommons.org/licenses/by-sa/3.0/ */ /** * Method Eval Sample (v1.0) * Java/p5.js Cross-Mode * GoToLoop 2015-Nov-01 * * https://forum.Processing.org/two/discussion/13345/ * trouble-with-converting-a-sketch-from-processing-to-p5js * * http://p5js.ProcessingTogether.com/sp/pad/export/ro.Ca0XtGgd$dJc59 */ const BG = 0350, FG = 0200, STROKE = 0100, BOLDNESS = 10; function setup() { createCanvas(600, 400); fill(FG).stroke(STROKE).strokeCap(SQUARE).strokeWeight(BOLDNESS); rectMode(CORNER).ellipseMode(CENTER).background(0).noLoop(); } function draw() { } function keyPressed() { const k = keyCode, letter = String.fromCharCode(k + 040); console.info(key, k, letter); if (letter >= 'a' & 'c' >= letter) { background(BG); eval(letter + '();'); redraw(); } } function a() { line(0, 0, width, height).line(width, 0, 0, height); } function b() { rect(0, 0, width>>1, height>>1); } function c() { ellipse(width>>1, height>>1, width>>1, height>>1); }