import factory from "./painting/factory.js"; import Canvas from "./painting/canvas.js"; import Shape from "./painting/shape.js"; import Button from "./ui/button.js"; document.body.innerHTML = ""; Shape.setBounding(window.innerWidth, window.innerHeight); let canvas = new Canvas(window.innerWidth, window.innerHeight); let repaint = new Button("paint"); repaint.addHandler(canvas.clear.bind(canvas)); repaint.addHandler(paint); repaint.setPosition(50, 50); window.addEventListener("resize", onWindowResize, false); document.body.appendChild(canvas.element); document.body.appendChild(repaint.element); function onWindowResize(e) { Shape.setBounding(window.innerWidth, window.innerHeight); canvas.resize(window.innerWidth, window.innerHeight); } function paint() { let amount = Math.floor(Math.random() * 100 + 50); for (let i = 0; i < amount; ++i) { let shape = factory.createRandomShape(); canvas.draw(shape); } }