[Android-development] Changing CanvasWindow coordinates

A. Savelov s_savelov at mail.ru
Fri Dec 26 13:59:12 CET 2014


 Hello!

It seems that canvasWindow doesn't change its position or I'm doing smth wrong.
This is my qml code, whick draws line from (0,0) position instead of (200,0)

import QtQuick 2.4
import QtQuick.Window 2.2

Window {
    visible: true

    Canvas {
        id: canvas
        canvasSize: "1000x1000"
        tileSize: "100x100"
        canvasWindow: Qt.rect(200,0,300,300);

        onPaint: {
            var ctx = getContext("2d");
            ctx.save();

            ctx.strokeStyle = "red";
            ctx.lineWidth = 20;

            // ![0]
            ctx.beginPath();
            ctx.moveTo(0,0);
            ctx.lineTo(1000,1000);
            ctx.closePath();
            ctx.stroke();
            // ![0]

            ctx.restore();
        }
    }
}

-----
With best regards, A. Savelov

P.S.: so sorry for my last post - I forgot to change theme(

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/android-development/attachments/20141226/f0154b36/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: line.png
Type: image/png
Size: 30369 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/android-development/attachments/20141226/f0154b36/attachment.png>


More information about the Android-development mailing list