Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. QtQuick 2.0 Canvas2D: Clip redrawing bug
Forum Updated to NodeBB v4.3 + New Features

QtQuick 2.0 Canvas2D: Clip redrawing bug

Scheduled Pinned Locked Moved QML and Qt Quick
2 Posts 2 Posters 1.5k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    Kildyt
    wrote on last edited by
    #1

    Hi,

    I'm using Qt5.0.0beta2. When I try to draw some shape (e.g. rect) using clip on negative coordinates it doesn't work (shape is visible only on x>0 and y>0).

    This is my code used to tests:
    @
    import QtQuick 2.0

    Item {
    function startUp() {

    function paint() {

    // don't call this function on every repaint
    canvas.onPaint.disconnect(paint);

    // get ctx
    

    var ctx = canvas.getContext('2d'),

    // some variables to animate
    i = 1,
    w = 150,
    h = 150,
    x=0, y=0,
    
    // new timer
    timer = Qt.createQmlObject('import QtQuick 2.0; Timer { interval: 17; repeat: true; }', window);
    

    timer.onTriggered.connect(function() {
    ctx.save();
    ctx.translate(200, 200);

    x && y && ctx.clearRect(x, y, w, h);
    
    // set new x and y
    x = Math.sin(i)*200;
    y = Math.cos(i)*200;
    i += 0.02;
    
    // draw gray rect
    ctx.fillStyle = "gray";
    ctx.fillRect(x, y, w, h);
    
    // clip
    ctx.beginPath();
    ctx.rect(x+10, y+10, w-20, h-20);
    ctx.closePath();
    ctx.clip();
    
    // draw red rect
    ctx.globalAlpha = 0.8;
    ctx.fillStyle = "red";
    ctx.fillRect(x, y, w, h);
    ctx.restore();
    
    // send repaint request
    canvas.markDirty(Qt.rect(x,y,w,h));
    

    });

    // start animate
    timer.start();

    }

    // get context and start animation
    canvas.onPaint.connect(paint);
    }

    id: window
    width: 600
    height: 600
    Component.onCompleted: startUp()

    Canvas {
    id: canvas
    anchors.fill: parent
    }
    }
    @

    Screenshot from qmlscene:
    !http://ubuntuone.com/0aweNF72SXb6OkuwtxbW4p(screenshot of testing)!

    Issue isn't conected with timer. I used this code only to easier debug.

    The same HTML code works fully on Chromium 22.0.

    If anyone have any idea?
    I will be very grateful to any respond.

    1 Reply Last reply
    0
    • C Offline
      C Offline
      chrisadams
      wrote on last edited by
      #2

      Sounds like a bug. Please file a bug report on JIRA.

      Cheers,
      Chris.

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved