import QtQuick 2.0 Item { Canvas { id: canvas smooth: true width: 800; height: 600 onPaint: { var ctx = canvas.getContext('2d'); ctx.clearRect(0, 0, canvas.width, canvas.height); ctx.rotate(canvas.rotate); ctx.lineWidth = 5; ctx.strokeStyle = ctx.createPattern("red", Qt.SolidPattern); ctx.beginPath() ctx.moveTo(10, 10) ctx.lineTo(30, 10) ctx.stroke() ctx.beginPath() ctx.moveTo(10, 20) ctx.lineTo(30, 20) ctx.lineTo(20, 20) ctx.stroke() ctx.restore() } //end of onPaint } }