blob: b1e3ffdf967ad2e27117ef65d670ea7810f16beb (
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
58
|
import "../../Canvas"
import "blobsallad.js" as Blob
import Qt 4.7
Canvas {
width:500
height:500
property color color: "#ffeeaa"
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) }
}
Button {
anchors.bottom:parent.bottom
anchors.left:parent.left
anchors.margins:16
id:join
text: "Split"
onClicked: Blob.blobColl.split();
}
Button {
anchors.bottom:parent.bottom
anchors.horizontalCenter:parent.horizontalCenter
anchors.margins:16
text: "Join"
onClicked: Blob.blobColl.join();
}
Button {
anchors.bottom:parent.bottom
anchors.right:parent.right
anchors.margins:16
text: "Gravity"
onClicked: Blob.toggleGravity();
}
Component.onCompleted: Blob.init()
}
|