diff options
Diffstat (limited to 'src/main.js')
-rw-r--r-- | src/main.js | 39 |
1 files changed, 0 insertions, 39 deletions
diff --git a/src/main.js b/src/main.js deleted file mode 100644 index f73a17b..0000000 --- a/src/main.js +++ /dev/null @@ -1,39 +0,0 @@ -import Terrain from './Terrain.js'; -import Canvas from './Canvas.js'; -import Brush from './Brush.js'; -import BrushSelector from './BrushSelector.js'; - -const $ = id => document.getElementById(id) - -window.onload = () => { - const canvas = new Canvas('root'); - const terrain = new Terrain(); - const selector = new BrushSelector('root', canvas, terrain); - - let brushing = false; - - canvas.onMouseDown = e => { - if (e.button == 0) brushing = true; - }; - canvas.onMouseUp = e => { - if (e.button == 0) brushing = false; - }; - - const pos = canvas.mouse.drawingPos; - canvas.onMouseMove = () => { - if (brushing) selector.apply(); - canvas.draw(); - }; - - canvas.onDraw = ct => { - terrain.render(ct); - - ct.strokeStyle = '#fff'; - ct.lineWidth = canvas.pixelsToUnits(1); - ct.beginPath(); - ct.arc(pos.x, pos.y, canvas.pixelsToUnits(selector.radiusSlider.value), 0, 2*Math.PI); - ct.closePath(); - ct.stroke(); - }; - canvas.draw(); -} |