Difference between revisions of "MediaWiki:Common.js"
Jump to navigation
Jump to search
Line 3: | Line 3: | ||
mw.loader.load('https://github.com/processing/p5.js/releases/download/v1.4.0/p5.js'); | mw.loader.load('https://github.com/processing/p5.js/releases/download/v1.4.0/p5.js'); | ||
mw.loader.load('https://vvvvvvaria.org/~mb/downloads/variable-geometry.js'); | mw.loader.load('https://vvvvvvaria.org/~mb/downloads/variable-geometry.js'); | ||
+ | |||
+ | let moving_size = 50; | ||
+ | let static_size = 20; | ||
+ | |||
+ | var c = createCanvas(600, 600); | ||
+ | c.parent("variable-geometry"); | ||
+ | c.frameRate(15); | ||
+ | //background | ||
+ | c.background(random(230, 240)); | ||
+ | //left | ||
+ | c.noStroke() | ||
+ | c.fill(0); | ||
+ | c.rect(97, 169, 79, 12); | ||
+ | |||
+ | //right | ||
+ | c.rect(365, 184, 20, 15); | ||
+ | c.fill(20, 20, 120); | ||
+ | |||
+ | beginShape(); | ||
+ | c.vertex(365, 199); | ||
+ | c.vertex(385, 199); | ||
+ | c.vertex(372, 216); | ||
+ | c.vertex(358, 216); | ||
+ | c.endShape(CLOSE); | ||
+ | |||
+ | //bottom | ||
+ | c.noFill(); | ||
+ | c.stroke(130); | ||
+ | c.strokeWeight(2); | ||
+ | c.ellipse(255, 350, static_size, static_size); | ||
+ | |||
+ | //mouse interactions | ||
+ | c.stroke(180); | ||
+ | c.ellipse(mouseX, mouseY, moving_size, moving_size); | ||
+ | |||
+ | if (mouseIsPressed) { | ||
+ | static_size = floor(random(5, 20)); | ||
+ | } |
Revision as of 12:15, 29 September 2021
/* Any JavaScript here will be loaded for all users on every page load. */ mw.loader.load('https://github.com/processing/p5.js/releases/download/v1.4.0/p5.js'); mw.loader.load('https://vvvvvvaria.org/~mb/downloads/variable-geometry.js'); let moving_size = 50; let static_size = 20; var c = createCanvas(600, 600); c.parent("variable-geometry"); c.frameRate(15); //background c.background(random(230, 240)); //left c.noStroke() c.fill(0); c.rect(97, 169, 79, 12); //right c.rect(365, 184, 20, 15); c.fill(20, 20, 120); beginShape(); c.vertex(365, 199); c.vertex(385, 199); c.vertex(372, 216); c.vertex(358, 216); c.endShape(CLOSE); //bottom c.noFill(); c.stroke(130); c.strokeWeight(2); c.ellipse(255, 350, static_size, static_size); //mouse interactions c.stroke(180); c.ellipse(mouseX, mouseY, moving_size, moving_size); if (mouseIsPressed) { static_size = floor(random(5, 20)); }