summaryrefslogtreecommitdiffstats
path: root/examples/blob/blob.qml
blob: 53752c13503802ddc07468cb7cc4a78d7e919caf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import "../../Canvas"
import "blobsallad.js" as Blob
import Qt 4.7

Canvas {
    width:500
    height:500

    property color color: "#ffee00"

    Timer {
        id: heartbeat;
        interval: 25;
        repeat: true
        running:true
        triggeredOnStart: true;
        onTriggered: {
            var ctx = getContext();
            ctx.clearRect(0, 0, width, height);
            Blob.update();
            Blob.draw(ctx);
        }
    }
    MouseArea {
        id:mousearea
        hoverEnabled:true
        anchors.fill: parent
        onPressed: { Blob.mousePressed(mouseX, mouseY) }         
        onReleased: { Blob.mouseReleased(mouseX, mouseY) }         
        onPositionChanged: { Blob.mouseMoved(mouseX, mouseY) }         
    }

    Row {
        spacing:10
        anchors.top:parent.top
        anchors.left:parent.left
        anchors.margins:10
        Button {
            id:join
            text: "Split"
            onClicked: Blob.blobColl.split(); 
        }
        Button {
            anchors.margins:16
            text: "Join"
            onClicked: Blob.blobColl.join(); 
        }
        Button {
            anchors.margins:16
            text: "Gravity"
            onClicked: Blob.toggleGravity(); 
        }
    }

    Component.onCompleted: Blob.init()
}