Wednesday, August 21, 2013

qml example: Draw something on Canvas

qml example: Draw something on Canvas
qml example: Draw something on Canvas


import QtQuick 2.0

Rectangle {
    width: 360
    height: 360

    Canvas {
        anchors.fill: parent

        onPaint: {
            var ctx = getContext('2d');

            ctx.fillStyle = "red"
            ctx.fillRect(150, 200, 120, 120)

            ctx.beginPath();
            ctx.lineWidth = 3
            ctx.strokeStyle = "blue"
            ctx.ellipse(10, 10, 200, 200)
            ctx.rect(50, 50, 200, 200)
            ctx.stroke();

        }

    }
}