https://qmlbook.github.io/ch07/index.html#transformation
I’m running exact same code from the qml book and only the green rectangle is being drawn!
import QtQuick 2.0
Canvas {
id: root
width: 240; height: 120
onPaint: {
var ctx = getContext(“2d”)
ctx.strokeStyle = “blue”
ctx.lineWidth = 4
ctx.beginPath()
ctx.rect(-20, -20, 40, 40)
ctx.translate(120,60)
ctx.stroke()
// draw path now rotated
ctx.strokeStyle = “green”
ctx.rotate(Math.PI/4)
ctx.stroke()
}
}
What am I missing here? is the code wrong or is this a bug in canvas?!