1 | package charts.series.bars {
|
---|
2 |
|
---|
3 | import flash.filters.DropShadowFilter;
|
---|
4 | import flash.geom.Matrix;
|
---|
5 | import charts.series.bars.Base;
|
---|
6 |
|
---|
7 | public class Glass extends Base
|
---|
8 | {
|
---|
9 |
|
---|
10 | public function Glass( index:Number, props:Properties, group:Number ) {
|
---|
11 |
|
---|
12 | super(index, props, group);
|
---|
13 | //super(index, {'top':props.get('top')}, props.get_colour('colour'), props.get('tip'), props.get('alpha'), group);
|
---|
14 | //super(index, style, style.colour, style.tip, style.alpha, group);
|
---|
15 |
|
---|
16 | var dropShadow:DropShadowFilter = new flash.filters.DropShadowFilter();
|
---|
17 | dropShadow.blurX = 5;
|
---|
18 | dropShadow.blurY = 5;
|
---|
19 | dropShadow.distance = 3;
|
---|
20 | dropShadow.angle = 45;
|
---|
21 | dropShadow.quality = 2;
|
---|
22 | dropShadow.alpha = 0.4;
|
---|
23 | // apply shadow filter
|
---|
24 | this.filters = [dropShadow];
|
---|
25 | }
|
---|
26 |
|
---|
27 | public override function resize( sc:ScreenCoordsBase ):void {
|
---|
28 |
|
---|
29 | this.graphics.clear();
|
---|
30 | var h:Object = this.resize_helper( sc as ScreenCoords );
|
---|
31 | if (h.height == 0)
|
---|
32 | return;
|
---|
33 |
|
---|
34 | this.bg( h.width, h.height, h.upside_down );
|
---|
35 | this.glass( h.width, h.height, h.upside_down );
|
---|
36 | }
|
---|
37 |
|
---|
38 | private function bg( w:Number, h:Number, upside_down:Boolean ):void {
|
---|
39 | //
|
---|
40 | var rad:Number = 7;
|
---|
41 | if ( rad > ( w / 2 ) )
|
---|
42 | rad = w / 2;
|
---|
43 |
|
---|
44 | this.graphics.lineStyle(0, 0, 0);// this.outline_colour, 100);
|
---|
45 | this.graphics.beginFill(this.colour, 1);
|
---|
46 |
|
---|
47 | if( !upside_down )
|
---|
48 | {
|
---|
49 | // bar goes up
|
---|
50 | this.graphics.moveTo(0+rad, 0);
|
---|
51 | this.graphics.lineTo(w-rad, 0);
|
---|
52 | this.graphics.curveTo(w, 0, w, rad);
|
---|
53 | this.graphics.lineTo(w, h);
|
---|
54 | this.graphics.lineTo(0, h);
|
---|
55 | this.graphics.lineTo(0, 0+rad);
|
---|
56 | this.graphics.curveTo(0, 0, 0+rad, 0);
|
---|
57 | }
|
---|
58 | else
|
---|
59 | {
|
---|
60 | // bar goes down
|
---|
61 | this.graphics.moveTo(0, 0);
|
---|
62 | this.graphics.lineTo(w, 0);
|
---|
63 | this.graphics.lineTo(w, h-rad);
|
---|
64 | this.graphics.curveTo(w,h,w-rad, h);
|
---|
65 | this.graphics.lineTo(rad, h);
|
---|
66 | this.graphics.curveTo(0,h,0, h-rad);
|
---|
67 | this.graphics.lineTo(0, 0);
|
---|
68 | }
|
---|
69 | this.graphics.endFill();
|
---|
70 | }
|
---|
71 |
|
---|
72 | private function glass( w:Number, h:Number, upside_down:Boolean ): void {
|
---|
73 | var x:Number = 2;
|
---|
74 | var y:Number = x;
|
---|
75 | var width:Number = (w/2)-x;
|
---|
76 |
|
---|
77 | if( upside_down )
|
---|
78 | y -= x;
|
---|
79 |
|
---|
80 | h -= x;
|
---|
81 |
|
---|
82 | this.graphics.lineStyle(0, 0, 0);
|
---|
83 | //set gradient fill
|
---|
84 | var colors:Array = [0xFFFFFF,0xFFFFFF];
|
---|
85 | var alphas:Array = [0.3, 0.7];
|
---|
86 | var ratios:Array = [0,255];
|
---|
87 | //var matrix:Object = { matrixType:"box", x:x, y:y, w:width, h:height, r:(180/180)*Math.PI };
|
---|
88 | //mc.beginGradientFill("linear", colors, alphas, ratios, matrix);
|
---|
89 | var matrix:Matrix = new Matrix();
|
---|
90 | matrix.createGradientBox(width, height, (180 / 180) * Math.PI );
|
---|
91 | this.graphics.beginGradientFill('linear' /*GradientType.Linear*/, colors, alphas, ratios, matrix, 'pad'/*SpreadMethod.PAD*/ );
|
---|
92 |
|
---|
93 | var rad:Number = 4;
|
---|
94 | var w:Number = width;
|
---|
95 |
|
---|
96 | if( !upside_down )
|
---|
97 | {
|
---|
98 | this.graphics.moveTo(x+rad, y); // <-- top
|
---|
99 | this.graphics.lineTo(x+w, y);
|
---|
100 | this.graphics.lineTo(x+w, y+h);
|
---|
101 | this.graphics.lineTo(x, y+h);
|
---|
102 | this.graphics.lineTo(x, y+rad);
|
---|
103 | this.graphics.curveTo(x, y, x+rad, y);
|
---|
104 | }
|
---|
105 | else
|
---|
106 | {
|
---|
107 | this.graphics.moveTo(x, y);
|
---|
108 | this.graphics.lineTo(x+w, y);
|
---|
109 | this.graphics.lineTo(x+w, y+h);
|
---|
110 | this.graphics.lineTo(x + rad, y + h);
|
---|
111 | this.graphics.curveTo(x, y+h, x, y+h-rad);
|
---|
112 | }
|
---|
113 | this.graphics.endFill();
|
---|
114 | }
|
---|
115 | }
|
---|
116 | }
|
---|