Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import QtQuick 2.5
- import QtQuick.Window 2.2
- Window {
- visible: true
- width: 640
- height: 480
- title: qsTr("Hello World")
- Item {
- id: root
- anchors.fill: parent
- property string chirality: "left"
- Rectangle {
- id: rec
- anchors.fill: parent
- color: "red"
- }
- Canvas {
- id: painter
- anchors.fill: parent
- onPaint: {
- var ctx = getContext("2d");
- ctx.reset();
- ctx.lineJoin = "round";
- ctx.lineWidth = 4;
- ctx.strokeStyle = "black";
- var Ax, Ay, Bx, By, Cx, Cy;
- // NOTE: You might have to subtract half the line width.
- if (root.chirality === "left") {
- Ax = root.width - (ctx.lineWidth / 2);
- Ay = 0 + (ctx.lineWidth / 2);
- Bx = Ax;
- By = root.height - (ctx.lineWidth / 2);
- Cx = 0 + (ctx.lineWidth / 2);
- Cy = root.height / 2;
- }
- if (root.chirality === "right") {
- }
- ctx.beginPath();
- ctx.moveTo(Ax, Ay);
- ctx.lineTo(Bx, By);
- ctx.lineTo(Cx, Cy);
- ctx.lineTo(Ax, Ay);
- ctx.stroke();
- ctx.closePath();
- }
- }
- Timer{
- interval: 5000
- running: true
- repeat: NumberAnimation.Infinite
- onTriggered: {
- console.log("Paint ! ")
- painter.paint(rec)
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement