我在画布上绘制了一个等距网格。它使用 30 度角偏移,我使用一些脚本来绘制基本网格。对于这个网格,我投影了一个具有 40x40 平铺尺寸的平面网格。
gridRows = 10;
gridCols = 10;
tileSize = 40;
gridWidth = gridCols * tileSize;
gridHeight = gridRows * tileSize;
canvasWidth = tileSize * (gridCols + gridRows) * Math.sqrt(3) / 2;
canvasHeight = tileSize * (gridRows + gridCols) / 2;
canvasOffset = tileSize * gridRows * Math.sqrt(3) / 2;
function carToIso(x, y) {
// Convert cartesian (x, y) to isometric coordinates
return [
Math.round((x - y) * Math.sqrt(3) / 2 + canvasOffset),
Math.round((x + y) / …Run Code Online (Sandbox Code Playgroud)