didn't look like a floor tiles. Some transformation / rotate / Angle was missing. How to do perspective view with html5 canvas
here is the code
function drawPattern(img, size, rectY) {
var roomImg = new Image();
roomImg.src = './assets/room2.png';
roomImg.onload = function() {
ctx.drawImage(roomImg, 0, 0, canvas.width, canvas.height);
ctx.restore();
}
var canvas = document.getElementById('canvas1');
canvas.width = 1350;
canvas.height = 600;
var tempFloorCanvas = document.createElement("canvas");
var tFloorCtx = tempFloorCanvas.getContext("2d");
tempFloorCanvas.width = size;
tempFloorCanvas.height = size;
tFloorCtx.drawImage(floorimg, 0, 0, floorimg.width, floorimg.height, 0, 0, size, size);
tFloorCtx.setTransform(1,1,-0.5,1,30,10);
tFloorCtx.rotate(50);
tFloorCtx.fill();
var ctx = canvas.getContext('2d');
ctx.clearRect(0, 0, canvas.width, canvas.height);
ctx.fillStyle = ctx.createPattern(tempFloorCanvas, 'repeat');
ctx.beginPath();
ctx.rect(0,400,canvas.width, 400);
ctx.closePath();
ctx.fill();
ctx.restore();
}
var floorimg = new Image();
floorimg.src = './assets/tile5.jpg';
floorimg.onload = function(){
drawPattern(floorimg, 70, 0);
}
If there is another solution to implement the feature or If there are third party plugins which can transform my canvas to some angle to be look like a floor of the room, then please let me know.