Drawing tile-image in canvas object
-
I am using a canvas like this,
Canvas { id: canvas x: 0 y: 0 height: 200 width: 400 onAvailableChanged: { if(canvas.available) { var ctx=canvas.getContext("2d") ctx.fillStyle="transparent" ctx.fillRect(base.x, base.y, base.width,base.height) if(bgimge) { ctx.fillStyle="white" ctx.fillRect(0,0,200,400) ctx.drawImage(bgimge,0,0,200,400) } } } onPaint: { var ctx=canvas.getContext("2d") ctx.beginPath() ctx.strokeStyle=penColour ctx.lineWidth=penWidth ctx.pixelSize="100px" ctx.moveTo(canvas.lastX,canvas.lastY) lastX=mouseArea.mouseX lastY=mouseArea.mouseY ctx.lineTo(canvas.lastX,canvas.lastY) ctx.stroke() } }
Here I am able to draw the background image, is there any way to fill the image in tile mode ?
-
I am using a canvas like this,
Canvas { id: canvas x: 0 y: 0 height: 200 width: 400 onAvailableChanged: { if(canvas.available) { var ctx=canvas.getContext("2d") ctx.fillStyle="transparent" ctx.fillRect(base.x, base.y, base.width,base.height) if(bgimge) { ctx.fillStyle="white" ctx.fillRect(0,0,200,400) ctx.drawImage(bgimge,0,0,200,400) } } } onPaint: { var ctx=canvas.getContext("2d") ctx.beginPath() ctx.strokeStyle=penColour ctx.lineWidth=penWidth ctx.pixelSize="100px" ctx.moveTo(canvas.lastX,canvas.lastY) lastX=mouseArea.mouseX lastY=mouseArea.mouseY ctx.lineTo(canvas.lastX,canvas.lastY) ctx.stroke() } }
Here I am able to draw the background image, is there any way to fill the image in tile mode ?