File: C:/xampp/htdocs/cieclock/daycolor.txt
package com.example.pbnspectro.service;
import static com.example.pbnspectro.utls.ColorTool.cieXYZtoSRGB;
import static com.example.pbnspectro.utls.ColorTool.lab2xyz;
import android.graphics.Color;
import java.util.Calendar;
public class DayColor {
/**
* Get the current time and convert it to a color hex code
* @return String[] Returns an array of Strings containing the hexadecimal and integer representations of the RGB color values for the hour, minute, and second.
* The first three elements are the hexadecimal values for the hour, minute, and second colors, respectively.
* The last three elements are the integer values for the hour, minute, and second colors, respectively.
*/
public static String[] getDayHex() {
Calendar calendar = Calendar.getInstance();
int cDay = calendar.get(Calendar.DAY_OF_YEAR);
//System.out.println("cDay : " + cDay);
double cDayi = (cDay / 365.00 )*360;
//System.out.println("cDayi : " + cDayi);
int chrome = 100;
int Ld = getLd(cDayi);
// Convert degrees to radians
double degreed = Math.toRadians(cDayi);
double ad, bd;
ad = Math.cos(degreed) * chrome;
bd = Math.sin(degreed) * chrome;
//System.out.println("Day L,a,b : " + Ld +"," + ad + "," + bd);
double xd = lab2xyz("x", Ld, ad, bd) * 0.01;
double yd = lab2xyz("y", Ld, ad, bd) * 0.01;
double zd = lab2xyz("z", Ld, ad, bd) * 0.01;
// System.out.println("xs : " + xd);
// System.out.println("ys : " + yd);
// System.out.println("zs : " + zd);
int[] dRGB = cieXYZtoSRGB(xd, yd, zd);
//System.out.println("sRGB : " + dRGB[0] + "," + dRGB[1] + "," + dRGB[2]);
return new String[] {
String.format("#%02x%02x%02x", dRGB[0], dRGB[1], dRGB[2]),
String.valueOf(Color.rgb(dRGB[0], dRGB[1], dRGB[2]))
};
}
private static int getLd(double cDayi) {
int Ld = 55;
if (cDayi > 53) {
Ld = 60;
}
if (cDayi > 59) {
Ld = 65;
}
if (cDayi > 65) {
Ld = 70;
}
if (cDayi > 71) {
Ld = 75;
}
if (cDayi > 77) {
Ld = 80;
}
if (cDayi > 83) {
Ld = 85;
// chrome = 87;
}
if (cDayi > 89) {
Ld = 93;
// chrome = 90;
}
if (cDayi > 101) {
Ld = 92;
}
if (cDayi > 107) {
Ld = 90;
}
if (cDayi > 113) {
Ld = 88;
}
if (cDayi > 119) {
Ld = 85;
}
if (cDayi > 125) {
Ld = 83;
}
if (cDayi > 131) {
Ld = 80;
}
if (cDayi > 137) {
Ld = 78;
}
if (cDayi > 143) {
Ld = 75;
}
if (cDayi > 149) {
Ld = 70;
// chrome = 80;
}
if (cDayi > 155) {
Ld = 68;
// chrome = 80;
}
if (cDayi > 161) {
Ld = 65;
// chrome = 80;
}
if (cDayi > 167) {
Ld = 63;
// chrome = 80;
}
if (cDayi > 173) {
Ld = 60;
// chrome = 80;
}
if (cDayi > 179) {
Ld = 58;
// chrome = 80;
}
if (cDayi > 185) {
Ld = 55;
// chrome = 80;
}
return Ld;
}
}