summaryrefslogtreecommitdiff
path: root/js/dojo/dojox/gfx/demos/circles2.html
blob: 67afacb30eb8dca6660681b61c6cfcfea99227cc (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
59
60
61
62
63
64
65
66
67
68
69
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office">
<head>
<title>dojox.gfx: 2 draggable circles</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
	@import "../../../dojo/resources/dojo.css";
	@import "../../../dijit/tests/css/dijitTests.css";
</style>
<script type="text/javascript" src="../../../dojo/dojo.js"></script>
<script type="text/javascript">

dojo.require("dojox.gfx");
dojo.require("dojox.gfx.move");

var container = null,
	surface = null,
	surface_size = null;

function makeCircles(){
	// our geometry
	var x1 = 100, y1 = 100, x2 = 400, y2 = 400, r = 50;
	
	// our shapes
	var line = surface.createLine({x1: x1, y1: y1, x2: x2, y2: y2}).setStroke("red"),
		circle1 = surface.createCircle({cx: x1, cy: y1, r: r}).setStroke("red").setFill("white"),
		circle2 = surface.createCircle({cx: x2, cy: y2, r: r}).setStroke("red").setFill("white");
	
	// circle movers
	var m1 = new dojox.gfx.Moveable(circle1),
		m2 = new dojox.gfx.Moveable(circle2);
		
	// custom event processing
	dojo.connect(m1, "onMoved", function(mover, shift){
		var o = line.getShape();
		line.setShape({x1: o.x1 + shift.dx, y1: o.y1 + shift.dy, x2: o.x2, y2: o.y2});
	});
	dojo.connect(m2, "onMoved", function(mover, shift){
		var o = line.getShape();
		line.setShape({x1: o.x1, y1: o.y1, x2: o.x2 + shift.dx, y2: o.y2 + shift.dy});
	});
}

function initGfx(){
	container = dojo.byId("gfx_holder");
	surface = dojox.gfx.createSurface(container, 500, 500);
	surface_size = {width: 500, height: 500};

	makeCircles();

	// cancel text selection and text dragging
	dojo.connect(container, "ondragstart",   dojo, "stopEvent");
	dojo.connect(container, "onselectstart", dojo, "stopEvent");
}

dojo.addOnLoad(initGfx);

</script>

<style type="text/css">
.movable { cursor: pointer; }
</style>

</head>
<body>
<h1>dojox.gfx: 2 draggable circles</h1>
<p>Warning: Canvas renderer doesn't implement event handling.</p>
<div id="gfx_holder" style="width: 500px; height: 500px;"></div>
</body>
</html>