xxxxxxxxxx
36
/**
* I've modified this pen that was created by GoToLoop for mere mortals such as myself.
* It's far easier to read though I wonder if I've lost some functionality.
* Below you'll find info about the original creator.
*
* Element Relative to Canvas (v1.3)
* GoToLoop (2016-Jun-09)
*
* https://Forum.Processing.org/two/discussion/17074/
* placing-slider-relative-to-canvas-in-instance-mode#Item_3
*
* http://CodePen.io/GoSubRoutine/pen/KNbwLW/right/?editors=101
*/
//"use strict";
//new p5;
let slider;
function setup() {
createCanvas(600, 400);
slider = createSlider(0, 255, 128).size(width/2, AUTO);
windowResized();
}
function draw() {
background(slider.value());
}
function windowResized() {
_renderer.position((windowWidth - width) / 2, (windowHeight - height) / 2);
const sliderX = (width - slider.width) / 2 + _renderer.x;
const sliderY = (height - slider.height) / 2 + _curElement.y;
slider.position(sliderX, sliderY);
}