Details
-
Suggestion
-
Resolution: Out of scope
-
P3: Somewhat important
-
None
-
5.1.0
Description
Currently, without using workarounds, rotating Canvas in aliasing that doesn't occur when drawing the elements rotated instead. It would be great to have a non-rasterised canvas.
import QtQuick 2.0 Rectangle { width: 400 height: 400 color: "black" Timer { id: timer running: true repeat: true interval: 1000 property real rotation: 0 property bool forward: false onTriggered: { forward = !forward; rotation += forward ? 10 : -10; } } Canvas { id: canvas anchors.centerIn: parent width: 100 height: 100 rotation: timer.rotation opacity: 0.75 onPaint: { var ctx = getContext("2d"); ctx.reset(); ctx.beginPath(); ctx.fillStyle = "steelblue"; ctx.moveTo(width / 2, height / 2); var size = Math.PI / 8; ctx.arc(width / 2, height / 2, 50, -(size) - Math.PI / 2, size - Math.PI / 2, false); ctx.fill(); } } }
There is a workaround, which is to add the following lines to onPaint before anything is drawn:
ctx.translate(1, 1); ctx.scale((width - 2) / width, (height - 2) / height);