7c70d073a638d68e2bac3f726c8404452ec3ef0c
1 // (c) Benoît PIN 2006-2007
5 function HSVColor(h
, s
, v
) {
11 HSVColor
.prototype.toRGBString = function() {
12 var rgb
= this.toRGB();
13 return "rgb(" + String(rgb
[0]) + ", " + String(rgb
[1]) + ", " + String(rgb
[2]) + ")";
16 HSVColor
.prototype.toRGB = function () {
17 var h
= this.h
; var s
= this.s
/100.0;
19 if( s
== 0 ) // achromatic (grey)
22 h
= h
/60; // sector
0 to
5
23 var i
= Math
.floor( h
);
24 var f
= h
- i
; // factorial part of h
25 var p
= v
* ( 1 - s
);
26 var q
= v
* ( 1 - s
* f
);
27 var t
= v
* ( 1 - s
* ( 1 - f
) );
61 r
= Math
.round(r
*255);
62 g
= Math
.round(g
*255);
63 b
= Math
.round(b
*255);
68 function ColorIterator(baseH
, baseS
, baseV
, step
) {
69 this.baseColor
= new HSVColor(baseH
, baseS
, baseV
);
70 this.currentH
= baseH
;
74 ColorIterator
.prototype.next = function() {
75 var c
= new HSVColor(this.currentH
, this.baseColor
.s
, this.baseColor
.v
);
76 this.currentH
+= this.step
;
78 if (this.currentH
>= 360)
84 function setBorderColor(ob
, colorString
) {
86 s
.borderBottomColor
= colorString
;
87 s
.borderLeftColor
= colorString
;
88 s
.borderRightColor
= colorString
;
89 s
.borderTopColor
= colorString
;
93 function setBorderStyle(ob
, borderStyle
) {
95 s
.borderBottomStyle
= borderStyle
;
96 s
.borderLeftStyle
= borderStyle
;
97 s
.borderRightStyle
= borderStyle
;
98 s
.borderTopStyle
= borderStyle
;
102 function setBorderWidth(ob
, borderWidth
) {
104 s
.borderBottomWidth
= borderWidth
;
105 s
.borderLeftWidth
= borderWidth
;
106 s
.borderRightWidth
= borderWidth
;
107 s
.borderTopWidth
= borderWidth
;
110 function zfill(number
, digits
) {
111 number
= Math
.floor(number
);
112 var nStr
= String(number
);
113 while (nStr
.length
< digits
)