-
Notifications
You must be signed in to change notification settings - Fork 5
/
Axes.mxml
81 lines (69 loc) · 2.07 KB
/
Axes.mxml
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
70
71
72
73
74
75
76
77
78
79
80
81
<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="50" height="50" backgroundColor="0x808080" backgroundAlpha="0.5">
<mx:Script>
<![CDATA[
public var labels:String;
public var axisrate:Number=0.8;
protected function DrawX(x:Number,y:Number):void {
graphics.moveTo(x-2.5,y-2);
graphics.lineTo(x+2.5,y+2);
graphics.moveTo(x-2.5,y+2);
graphics.lineTo(x+2.5,y-2);
}
protected function DrawY(x:Number,y:Number):void {
graphics.moveTo(x-2,y-2);
graphics.lineTo(x,y+0.5);
graphics.moveTo(x-2,y+3);
graphics.lineTo(x+2,y-2);
}
protected function DrawZ(x:Number,y:Number):void {
graphics.moveTo(x-2.5,y-2);
graphics.lineTo(x+2.5,y-2);
graphics.lineTo(x-2.5,y+2);
graphics.lineTo(x+2.5,y+2);
}
override protected function commitProperties():void {
super.commitProperties();
const size:Number=10;
const arrow:Number=2;
const circle:Number=4;
const xx:Number=size/2;
const xy:Number=height-1-size/2;
const yx:Number=width-1-xx;
const yy:Number=height-1-xy;
const zx:Number=width-1-5*size/4;
const zy:Number=height-1-5*size/4;
graphics.clear();
graphics.lineStyle(1,0xFF00);
switch(labels.charAt(0)) {
case "x":DrawX(xx,xy);break;
case "y":DrawY(xx,xy);break;
case "z":DrawZ(xx,xy);break;
}
switch(labels.charAt(1)) {
case "x":DrawX(yx,yy);break;
case "y":DrawY(yx,yy);break;
case "z":DrawZ(yx,yy);break;
}
switch(labels.charAt(2)) {
case "x":DrawX(zx,zy);break;
case "y":DrawY(zx,zy);break;
case "z":DrawZ(zx,zy);break;
}
const u:Number=size;
const v:Number=size;
graphics.moveTo(yx,v);
graphics.lineTo(yx+arrow,v+arrow);
graphics.moveTo(yx-arrow,v+arrow);
graphics.lineTo(yx,v);
graphics.lineTo(yx,xy);
graphics.lineTo(u,xy);
graphics.lineTo(u+arrow,xy-arrow);
graphics.moveTo(u+arrow,xy+arrow);
graphics.lineTo(u,xy);
graphics.drawCircle(yx,xy,circle);
graphics.drawCircle(yx,xy,1);
}
]]>
</mx:Script>
</mx:Canvas>