Created
May 11, 2020 21:22
-
-
Save amatiasq/398d60dd39b5ac998c9003e5096af6c8 to your computer and use it in GitHub Desktop.
composable cell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8" /> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | |
<title>Document</title> | |
<script type="module" src="run.js"></script> | |
<style> | |
html, | |
body, | |
canvas { | |
margin: 0; | |
padding: 0; | |
display: flex; | |
flex: 1; | |
} | |
body { | |
background-color: black; | |
} | |
</style> | |
</head> | |
<body> | |
<canvas></canvas> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const canvas = initialize(); | |
const cell = { | |
components: [], | |
addComponent(component) { | |
this.components.push(component); | |
}, | |
tick(map) { | |
this.components.forEach(x => x.tick(map, cell)); | |
}, | |
}; | |
const osmosis = { | |
tick() { | |
// for each elemento químico | |
// calcular diferencia | |
// transpasar la diferencia para equilibrar | |
// la velocidad depende de la distancia | |
} | |
} | |
function initialize() { | |
const canvas = document.querySelector('canvas'); | |
let width, height; | |
resize(); | |
addEventListener('resize', resize); | |
return canvas; | |
function resize() { | |
width = canvas.width = window.innerWidth; | |
height = canvas.height = window.innerHeight; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment