summaryrefslogtreecommitdiff
path: root/src/main.js
diff options
context:
space:
mode:
authorsanine <sanine.not@pm.me>2023-03-31 17:17:27 -0500
committersanine <sanine.not@pm.me>2023-03-31 17:17:27 -0500
commit673e9c13aea6cd1b11f5ca3e1f6edd474bbb1a19 (patch)
tree5764ff2cfd6b8dea3b615a1bb2f1dc1c078b07e7 /src/main.js
parent8aa6645f2311de78f74b35f804cc45c7fcf38f57 (diff)
implement nice map grid
Diffstat (limited to 'src/main.js')
-rw-r--r--src/main.js50
1 files changed, 24 insertions, 26 deletions
diff --git a/src/main.js b/src/main.js
index f73a17b..a86a38e 100644
--- a/src/main.js
+++ b/src/main.js
@@ -1,39 +1,37 @@
-import Terrain from './Terrain.js';
import Canvas from './Canvas.js';
-import Brush from './Brush.js';
-import BrushSelector from './BrushSelector.js';
+import { Mat3, Vec3, Point, Shape } from './Geometry.js';
+import { MapGrid } from './MapView.js';
const $ = id => document.getElementById(id)
window.onload = () => {
- const canvas = new Canvas('root');
- const terrain = new Terrain();
- const selector = new BrushSelector('root', canvas, terrain);
+ const canvas = new Canvas($('root'));
- let brushing = false;
+ const xaxis = new Vec3(1, 0, 0);
+ const yaxis = new Vec3(0, 1, 0);
+ const zaxis = new Vec3(0, 0, 1);
- canvas.onMouseDown = e => {
- if (e.button == 0) brushing = true;
- };
- canvas.onMouseUp = e => {
- if (e.button == 0) brushing = false;
- };
+ const grid = new MapGrid(30, 90);
- const pos = canvas.mouse.drawingPos;
- canvas.onMouseMove = () => {
- if (brushing) selector.apply();
- canvas.draw();
- };
-
- canvas.onDraw = ct => {
- terrain.render(ct);
+ let view = new Mat3();
+ let angle = 0;
- 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();
+ canvas.onDraw = ct => {
+ ct.fillStyle = "#01162B"
+ ct.fillRect(-10,-10, 100, 100);
+ ct.lineWidth = 0.005;
+ ct.strokeStyle = "#E7305D";
+ ct.fillStyle = "blue";
+ ct.arc(0, 0, 1, 0, 2*Math.PI);
ct.stroke();
+
+ grid.render(ct, view);
};
canvas.draw();
+
+ setInterval(() => {
+ angle = angle + 0.01*Math.PI;
+ view.rotation(xaxis, angle);
+ canvas.draw();
+ }, 50);
}