-
Notifications
You must be signed in to change notification settings - Fork 0
/
ColorWheel.as
105 lines (83 loc) · 2.68 KB
/
ColorWheel.as
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
package
{
import flash.display.CapsStyle;
import flash.display.GradientType;
import flash.display.LineScaleMode;
import flash.display.Sprite;
import flash.geom.Matrix;
import flash.display.Shape;
public class ColorWheel extends Sprite
{
private static const DEFAULT_RADIUS:Number = 100;
public function ColorWheel(nRadius:Number = DEFAULT_RADIUS,brightness:uint=0xffffff)
{
init(nRadius,brightness);
}
public function reDraw(nRadius:Number ,brightness:uint)
{
var nRadians:Number;
var nR:Number;
var nG:Number;
var nB:Number;
var nColor:Number;
var objMatrix:Matrix;
var nX:Number;
var nY:Number;
var iThickness:int;
graphics.clear();
iThickness = 1 + int(nRadius / 50);
for (var i:int = 0; i < 360; i++)
{
nRadians = i * (Math.PI / 180);
nR = Math.cos(nRadians) * 127 + 128 << 16;
nG = Math.cos(nRadians + 2 * Math.PI / 3) * 127 + 128 << 8;
nB = Math.cos(nRadians + 4 * Math.PI / 3) * 127 + 128;
nColor = nR | nG | nB;
nX = nRadius * Math.cos(nRadians) + 120;
nY = nRadius * Math.sin(nRadians) + 120;
objMatrix = new Matrix();
objMatrix.tx = 120;
objMatrix.ty = 120;
objMatrix.createGradientBox(nRadius *2 , nRadius * 2 , nRadians, -nRadius + 120, -nRadius + 120);
graphics.lineStyle(iThickness,0,1, false, LineScaleMode.NONE, CapsStyle.NONE);
//trace(nColor);
graphics.lineGradientStyle(GradientType.LINEAR, [brightness, nColor], [100,100], [127, 255], objMatrix);
graphics.moveTo(120, 120);
graphics.lineTo(nX, nY);
}
}
public function init(nRadius:Number = DEFAULT_RADIUS,brightness:uint=0xffffff):void
{
var nRadians:Number;
var nR:Number;
var nG:Number;
var nB:Number;
var nColor:Number;
var objMatrix:Matrix;
var nX:Number;
var nY:Number;
var iThickness:int;
graphics.clear();
iThickness = 1 + int(nRadius / 50);
for (var i:int = 0; i < 360; i++)
{
nRadians = i * (Math.PI / 180);
nR = Math.cos(nRadians) * 127 + 128 << 16;
nG = Math.cos(nRadians + 2 * Math.PI / 3) * 127 + 128 << 8;
nB = Math.cos(nRadians + 4 * Math.PI / 3) * 127 + 128;
nColor = nR | nG | nB;
nX = nRadius * Math.cos(nRadians) + 120;
nY = nRadius * Math.sin(nRadians) + 120;
objMatrix = new Matrix();
objMatrix.tx = 120;
objMatrix.ty = 120;
objMatrix.createGradientBox(nRadius *2 , nRadius * 2 , nRadians, -nRadius + 120, -nRadius + 120);
graphics.lineStyle(iThickness,0,1, false, LineScaleMode.NONE, CapsStyle.NONE);
//trace(nColor);
graphics.lineGradientStyle(GradientType.LINEAR, [brightness, nColor], [100,100], [127, 255], objMatrix);
graphics.moveTo(120, 120);
graphics.lineTo(nX, nY);
}
}
}
}