2023-10-17 15:15:41 +01:00
|
|
|
/**
|
|
|
|
* @file This file provides a canvas class wrapper for the p5.js canvas
|
|
|
|
* @author Arlo Filley
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* this class provides a wrapper around the
|
|
|
|
* p5.js canvas, with easier methods to work with.
|
|
|
|
*/
|
|
|
|
class Canvas {
|
|
|
|
constructor() {
|
|
|
|
this.x = 0;
|
|
|
|
this.y = 0;
|
|
|
|
this.canvas = createCanvas(0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
center() {
|
2024-03-25 09:40:43 +00:00
|
|
|
this.canvas.position(this.x, this.y + windowHeight / 100 * 5);
|
2023-10-17 15:15:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
resize() {
|
2024-03-25 09:40:43 +00:00
|
|
|
this.canvas.resize(windowWidth, windowHeight - windowHeight / 100 * 5);
|
2023-10-17 15:15:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
disable() {
|
|
|
|
this.canvas.resize(0, 0);
|
|
|
|
}
|
|
|
|
}
|