Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-32431

Add a new renderTarget enum to Canvas to avoid rasterisation through use of the new QSG* classes

    XMLWordPrintable

    Details

      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);
      

        Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

            Assignee:
            sletta Gunnar Sletta
            Reporter:
            mitch_curtis Mitch Curtis
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Gerrit Reviews

                There are no open Gerrit changes