mirror of
https://github.com/KevinMidboe/cubewaves.git
synced 2025-10-29 17:40:17 +00:00
Added buttons to toggle the width of each box. They are spaced nicely on smaller screens and call decrement function to change with of the boxes.
This commit is contained in:
@@ -1,20 +1,37 @@
|
|||||||
let angle = 0;
|
let angle = 0;
|
||||||
let w = 40;
|
let w = 60;
|
||||||
let ma;
|
let ma;
|
||||||
let maxD;
|
let maxD;
|
||||||
let window_w;
|
let w_w;
|
||||||
|
|
||||||
function setup() {
|
function setup() {
|
||||||
window_w = min(window.innerWidth, 1200);
|
w_w = min(window.innerWidth, 1200);
|
||||||
createCanvas(window_w, window_w, WEBGL);
|
|
||||||
|
createCanvas(w_w, w_w, WEBGL);
|
||||||
ma = atan(1 / sqrt(2));
|
ma = atan(1 / sqrt(2));
|
||||||
maxD = dist(0, 0, 200, 200);
|
maxD = dist(0, 0, 200, 200);
|
||||||
|
|
||||||
|
draw_ui()
|
||||||
|
frameRate(60);
|
||||||
|
}
|
||||||
|
|
||||||
|
function draw_ui() {
|
||||||
|
let dec = createButton('Decrement');
|
||||||
|
let inc = createButton('Increment');
|
||||||
|
|
||||||
|
let c_c = window.innerWidth / 2;
|
||||||
|
let spacing = min(c_c * 0.2);
|
||||||
|
|
||||||
|
dec.position(c_c - (spacing + inc.width), 25);
|
||||||
|
inc.position(c_c + spacing, 25);
|
||||||
|
dec.mousePressed(() => { decrement(5) });
|
||||||
|
inc.mousePressed(() => { decrement(-5) });
|
||||||
}
|
}
|
||||||
|
|
||||||
function draw() {
|
function draw() {
|
||||||
background("#1e1e1e");
|
background("#1e1e1e");
|
||||||
|
|
||||||
let o_w = window_w + 100;
|
let o_w = w_w + 100;
|
||||||
ortho(-o_w, o_w, o_w, -o_w, 0, o_w + 500);
|
ortho(-o_w, o_w, o_w, -o_w, 0, o_w + 500);
|
||||||
|
|
||||||
if (o_w > 750) {
|
if (o_w > 750) {
|
||||||
@@ -24,7 +41,6 @@ function draw() {
|
|||||||
rotateX(-ma);
|
rotateX(-ma);
|
||||||
rotateY(QUARTER_PI);
|
rotateY(QUARTER_PI);
|
||||||
|
|
||||||
|
|
||||||
rectMode(CENTER);
|
rectMode(CENTER);
|
||||||
|
|
||||||
let offset = 0;
|
let offset = 0;
|
||||||
@@ -45,3 +61,7 @@ function draw() {
|
|||||||
|
|
||||||
angle -= 0.08;
|
angle -= 0.08;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function decrement(val) {
|
||||||
|
w += val;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user