//setcolor.function
function setcolor (hexstring) {
feldcolor.setRGB(hexstring);
RTemp = parseInt("0x"+(hexstring.slice(2, 4)));
GTemp = parseInt("0x"+(hexstring.slice(4, 6)));
BTemp = parseInt("0x"+(hexstring.slice(6, 8)));
decalc(RTemp, GTemp, BTemp);
rtext = RTemp;
gtext = GTemp;
btext = BTemp;
}
//decalc.function
function decalc (deR, deG, deB) {
trace("Ausgabe decalc: R: "+deR+" G: "+deG+" B: "+deB);
trace(" ");
//case1
tempbri = deG / 255;
tempsat = deR / (255 * tempbri);
tempkreisB = (255 * bri * sat - deB) / (bri * (sat - 1));
tempwinkel = 0 - 4 * tempkreisB / 17;
if (tempwinkel >= 0 && tempwinkel < 60) {
trace("----- Winkel in 0 - 60 -----");
trace("sat: "+tempsat);
trace("bri: "+tempbri);
trace("winkel: "+tempwinkel);
trace("kreisB: "+tempkreisB);
trace(" ");
//break
}
//case2
tempbri = deG / 255;
tempsat = deB / (255 * tempbri);
tempkreisR = (255 * bri * sat - deR) / (bri * (sat - 1));
tempwinkel = (60 * tempkreisR) / 255 + 60;
if (tempwinkel >= 60 && tempwinkel < 120) {
trace("----- Winkel in 60 - 120 ---");
trace("sat: "+tempsat);
trace("bri: "+tempbri);
trace("winkel: "+tempwinkel);
trace("kreisR: "+tempkreisR);
trace(" ");
//break
}
//case3
tempbri = deR / 255;
tempsat = deB / (255 * tempbri);
tempkreisG = (255 * bri * sat - deG) / (bri * (sat - 1));
tempwinkel = 180 - (4 * tempkreisG) / 17;
if (tempwinkel >= 120 && tempwinkel < 180) {
trace("----- Winkel in 120 - 180 --");
trace("sat: "+tempsat);
trace("bri: "+tempbri);
trace("winkel: "+tempwinkel);
trace("kreisG: "+tempkreisG);
trace(" ");
//break
}
//case4
tempbri = deR / 255;
tempsat = deG / (255 * tempbri);
tempkreisB = (255 * bri * sat - deB) / (bri * (sat - 1));
tempwinkel = (4 * tempkreisB) / 17 + 180;
if (tempwinkel >= 180 && tempwinkel < 240) {
trace("----- Winkel in 180 - 240 --");
trace("sat: "+tempsat);
trace("bri: "+tempbri);
trace("winkel: "+tempwinkel);
trace("kreisB: "+tempkreisB);
trace(" ");
//break
}
//case5
tempbri = deB / 255;
tempsat = deG / (255 * tempbri);
tempkreisR = (255 * bri * sat - deR) / (bri * (sat - 1));
tempwinkel = 300 - (4 * tempkreisR) / 17;
if (tempwinkel >= 240 && tempwinkel < 300) {
trace("----- Winkel in 240 - 300 --");
trace("sat: "+tempsat);
trace("bri: "+tempbri);
trace("winkel: "+tempwinkel);
trace("kreisR: "+tempkreisR);
trace(" ");
//break
}
//case6
tempbri = deB / 255;
tempsat = deR / (255 * tempbri);
tempkreisG = (255 * bri * sat - deG) / (bri * (sat - 1));
tempwinkel = (4 * tempkreisG) / 17 + 300;
if (tempwinkel >= 300 && tempwinkel <= 360) {
trace("----- Winkel in 300 - 360 --");
trace("sat: "+tempsat);
trace("bri: "+tempbri);
trace("winkel: "+tempwinkel);
trace("kreisG: "+tempkreisG);
trace(" ");
//break
}
}