I had some troubles with color setting via standard HTML encoding (turned out to be because the Qt format is AARRGGBB, was expecting RRGGBBAA). I used ‘rgba(…..)’ instead, but I am getting some weird behaviour. Have a sufficiently big canvas and the following onPaint function, then the problems are as listed in the comments:
onPaint: {
var context = getContext("2d")
context.clearRect(0, 0, width, height)
context.beginPath()
context.fillStyle = "green"
// should be red, assignment failed, is green
context.fillStyle = "rgba(1.0,0.0,0.0,1.0)"
context.fillRect(50, 50, 100, 50)
context.fill()
// Should be transparent and red, assignment failed, is green
context.fillStyle = "rgba(0.99,0.0,0.0,0.1)"
context.fillRect(200, 50, 100, 50)
context.fill()
// Should be transparent, has the right colour, but full opacity
context.fillStyle = "rgba(255,0,0,10)"
context.fillRect(350, 50, 100, 50)
context.fill()
// This works, which, frankly...
context.fillStyle = "rgba(255,0,0,0.1)"
context.fillRect(500, 50, 100, 50)
context.fill()
}
Tested with QT 5.4 on Ubuntu 14.04
↧








