36 lines
919 B
Java
36 lines
919 B
Java
package com.bernard.kholloscopinator;
|
|
|
|
import java.awt.Color;
|
|
import java.util.List;
|
|
import java.util.Random;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.IntStream;
|
|
|
|
public class Util {
|
|
|
|
public static List<Color> colors(int count) {
|
|
return colors(count,new Random());
|
|
}
|
|
|
|
public static List<Color> colors(int count,Random r) {
|
|
float startAngle = r.nextFloat();
|
|
return IntStream.range(0, count)
|
|
.mapToDouble(i->startAngle+i/((float)count))
|
|
.mapToObj(h->Color.getHSBColor((float)h, 1.f, 1.f))
|
|
.collect(Collectors.toList());
|
|
}
|
|
|
|
public static Color complementaire(Color c) {
|
|
return new Color(0xFFFFFF - c.getRGB()&0xFFFFFF);
|
|
}
|
|
|
|
public static Integer toInt(Color c) {
|
|
int value = 0xFF0000 & c.getBlue()*0x010000
|
|
+ 0xFF00 & c.getGreen()*0x0100
|
|
+ 0xFF & c.getRed()*0x01;
|
|
System.out.println(Integer.toHexString(value));
|
|
return Integer.valueOf(value^0xFFFFFF);
|
|
}
|
|
|
|
}
|