[GastForen Programmierung/Entwicklung JavaScript jQuery - color cycle animation with hsv colorspace?

  • Suche
  • Hilfe
  • Lesezeichen
  • Benutzerliste
Themen
Beiträge
Moderatoren
Letzter Beitrag

jQuery - color cycle animation with hsv colorspace?

sgtfloydpepper
Beiträge gesamt: 8

4. Okt 2010, 15:37
Beitrag # 1 von 2
Bewertung:
(2046 mal gelesen)
URL zum Beitrag
Beitrag als Lesezeichen
Hi there, I am working on a project, which I need a special body-background for. The background-color should cycle through the color spectrum. So I found this:

http://buildinternet.com/2009/09/its-a-rainbow-color-changing-text-and-backgrounds/

"But" this snippet is working with the RGB colorspace which has some very light and dark colors in it. Getting just bright colors will only work with the HSV colorspace (e.g. having S and V static at 100 and letting H cycle). I don’t know how to convert and in fact how to pimp this snippet for my needs.

Does anyone has an idea??

Thanks in advance. Best, Floyd
X

jQuery - color cycle animation with hsv colorspace?

crisies
  
Beiträge gesamt: 136

21. Okt 2010, 21:13
Beitrag # 2 von 2
Beitrag ID: #454808
Bewertung:
(1960 mal gelesen)
URL zum Beitrag
Beitrag als Lesezeichen
hi floyd

use the conversion function from here:
http://mjijackson.com/...rithms-in-javascript

The adapted spectrum function would be something like this:

Code
function spectrum(){ 
var h = Math.random();
var s = 1;
var v = 1;
var r, g, b;

var i = Math.floor(h * 6);
var f = h * 6 - i;
var p = v * (1 - s);
var q = v * (1 - f * s);
var t = v * (1 - (1 - f) * s);

switch(i % 6){
case 0: r = v, g = t, b = p; break;
case 1: r = q, g = v, b = p; break;
case 2: r = p, g = v, b = t; break;
case 3: r = p, g = q, b = v; break;
case 4: r = t, g = p, b = v; break;
case 5: r = v, g = p, b = q; break;
}

var hue = 'rgb(' + Math.floor(r * 255) + ',' + Math.floor(g * 255) + ',' + Math.floor(b * 255) + ')';
$('#welcome').animate( { backgroundColor: hue }, 1000, function() { spectrum(); });
}


cheers


als Antwort auf: [#453151]

Neuste Foreneinträge


DokumentAufsplitten: neue Versionen des JavaScripts

Cookie-Overload??

Adobe InDesign CC - Windows (x64) GPU-Unterst�tzung �ber NVIDIA Control Panel

Kein Grep auf Satzzeichen am Ende einer URL

Text und QR Code in PDF einf�gen per PitStop Aktion statt InDesign

Bildschirmflackern beim Markieren von Texten

N�chstes Treffen der IDUG Stuttgart

Automatische Sicherung

PDF �ffnen via Script UI?

Affinity Publisher � schwarz wird in CMYK separiert