I want to create an isometric map. The map exists of isometric rectangles like in the image:
I want to represent each rectangle as a 2d rectangle with a width and a height. So when for example you are creating the map in an editor, you could draw 2d rectangles and this creation can be converted to isometric planes. The width of an isometric plane is north to south-east (from the top of the diamond shape, to to the right.) And the height is from north to south-west. (From top to left)
Now I've got two problems.
First problem
I'm drawing this isometric map on a canvas, I am using offscreen canvases for drawing each plane seperately. I want to calculate the 2d width and height for the offscreen canvas. I used this math for doing this:
var canvasWidth = Math.cos(30) * planeWidth + Math.cos(30) * planeHeight;
var canvasHeight = Math.sin(30) * planeWidth + Math.cos(30) * planeHeight;
// still remember that planeWidth and planeHeight are isometric, so oblique sides
But this doesn't give me the right sizes for the canvas. Something else that I wonder is whether it is wise to calculate oblique sides with pixels.
Second problem
I want to use a 'texture' image for the planes. So, I've got images like:
My idea was to store the oblique sides of each image, so like the widths and the heights of the planes. When i want to draw a plane with a specific image, I can repeat that image.
The main goal is to create isometric planes with pixel-precise given width and heights. And the planes should have an image as texture. The images are already isometric, so they can be repeated and clipped like isometric tiles.
My questions: 1. I wonder wether it is wise to use the oblique sides as widths and heights, isn't it better to just find a way to keep using 2d sizes anyway, somehow?
Isn't it smarter to create a 2d rectangle on the offscreen canvases, and fill them with a not-isometric texture image, and then transform that canvas.
If I use the oblique sides to represent the width/heights of my planes and images, are that lengths true lengths? It's like a linear function: It are just pixels. Per 2 horizontal, 1 vertical. An odd number for going horizontal, will not give a whole number for going vertical. (And I assume this will give me unnecessary trouble later).