QtQuick 2.0 Canvas2D: Clip redrawing bug



  • 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.



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

    Cheers,
    Chris.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.