|
(X)HTML, JavaScript, DHTML, XML, CSS Client scripting tehnologije, Dynamic HTML, Cascading Stylesheets, XML i standardi |
|
Alati teme | Način prikaza |
27. 01. 2006. | #11 |
Dejan Katašić
Wrote a book
Datum učlanjenja: 10.06.2005
Lokacija: Novi Sad
Poruke: 1.017
Hvala: 129
86 "Hvala" u 43 poruka
|
Ko zna gde mi su formule, evo malo koda, to je AS, lako je prepraviti u JS
Kôd:
mcPanel.rgb2hsb = function () : Void { // sets h, s and b values based on r, g and b var min : Number = Math.min (Math.min (this.rgb.r, this.rgb.g), this.rgb.b); var max : Number = Math.max (Math.max (this.rgb.r, this.rgb.g), this.rgb.b); var delta : Number = max - min; if (delta == 0) { this.hsb.h = 360; this.hsb.s = 0; this.hsb.b = max / 255 * 100; } else { if (this.rgb.r == max) this.hsb.h = (this.rgb.g - this.rgb.b) / delta; else if (this.rgb.g == max) this.hsb.h = 2 + (this.rgb.b - this.rgb.r) / delta; else this.hsb.h = 4 + (this.rgb.r - this.rgb.g) / delta; this.hsb.h *= 60; this.hsb.h += 360; this.hsb.h %= 360; this.hsb.s = (1 - min / max) * 100; this.hsb.b = max / 255 * 100; } } mcPanel.hsb2rgb = function () : Void { // sets r, g and b value on h, s and b info var max : Number = this.hsb.b * 255 / 100; var min : Number = (1 - this.hsb.s / 100) * max; this.hsb.h %= 360; var f : Number; if (this.hsb.h < 60) f = this.hsb.h; else if (this.hsb.h < 180) f = this.hsb.h - 120; else if (this.hsb.h < 300) f = this.hsb.h - 240; else f = this.hsb.h - 360; var mid : Number = min + Math.abs (f / 60) * (max - min); max = Math.round (max); mid = Math.round (mid); min = Math.round (min); switch (Math.floor (this.hsb.h / 60)) { case 0: this.rgb.r = max; this.rgb.g = mid; this.rgb.b = min; break; case 1: this.rgb.r = mid; this.rgb.g = max; this.rgb.b = min; break; case 2: this.rgb.r = min; this.rgb.g = max; this.rgb.b = mid; break; case 3: this.rgb.r = min; this.rgb.g = mid; this.rgb.b = max; break; case 4: this.rgb.r = mid; this.rgb.g = min; this.rgb.b = max; break; case 5: this.rgb.r = max; this.rgb.g = min; this.rgb.b = mid; break; } } |
27. 01. 2006. | #12 |
Ivan Dilber
Sir Write-a-Lot
|
e, super, jako korisno... 'fala lepo
__________________
Leadership is the art of getting people to want to do what you know must be done. |
|
|
Slične teme | ||||
Tema | Početna poruka teme | Forum | Odgovori | Poslednja poruka |
Javascript ORM | kodi | (X)HTML, JavaScript, DHTML, XML, CSS | 2 | 10. 07. 2007. 11:17 |
javascript 3D | ivanhoe | Opušteno | 2 | 03. 11. 2006. 12:25 |
UTF8 i JavaScript | krcko | (X)HTML, JavaScript, DHTML, XML, CSS | 1 | 04. 10. 2006. 11:14 |
komentar na raspored elemenata, boje... | oliver78 | Web site, dizajn i multimedia | 2 | 23. 12. 2005. 15:54 |