Permalink
Browse files

Refactor

  • Loading branch information...
jacobwinters committed Jun 30, 2018
1 parent 1093922 commit bee212e254572a68c45fdb1be6ab275f9be1dd40
Showing with 9 additions and 5 deletions.
  1. +9 −5 display.js
View
@@ -2,13 +2,17 @@
function grid(nodes) {
return (gl, compiler, display) => {
const clickListener = (event) => {
function eventCoordsToGrid(event) {
const x = event.offsetX / gl.canvas.clientWidth;
const y = 1 - event.offsetY / gl.canvas.clientHeight;
return [Math.floor(y * 5), Math.floor(x * 5)];
}
function clickListener(event) {
if (settings.operation === 'variations') {
const x = event.offsetX / gl.canvas.clientWidth;
const y = 1 - event.offsetY / gl.canvas.clientHeight;
display.setDisplay(grid(makeGrid(nodes[Math.floor(y * 5)][Math.floor(x * 5)])));
const [y, x] = eventCoordsToGrid(event);
display.setDisplay(grid(makeGrid(nodes[y][x])));
}
};
}
gl.canvas.addEventListener('click', clickListener);
const shaders = nodes.map((row) => row.map(compiler));
return {

0 comments on commit bee212e

Please sign in to comment.