Skip to content
Snippets Groups Projects
Commit 58329bfd authored by dragapsy's avatar dragapsy
Browse files

Tache 2

Maj: UniformColorGenerator
parent e40a3b2b
No related branches found
No related tags found
No related merge requests found
......@@ -2,9 +2,24 @@ package model;
import javafx.scene.paint.Color;
import java.util.Random;
public class UniformColorGenerator implements ColorGenerator{
//code of color generator found on stackOverFlow;
// link : https://stackoverflow.com/questions/4246351/creating-random-colour-in-java
// but the color constructor with 3 parameter is not public, so I checked in the documentation of Color, and
// I found that there is a constructor with 4 parameter that is public since java 8;
// Link of the doc : https://docs.oracle.com/javase/8/javafx/api/javafx/scene/paint/Color.html
@Override
public Color nextColor(Cell cell) {
return null;
Random rand = new Random();
double red = rand.nextFloat();
double green = rand.nextFloat();
double blue = rand.nextFloat();
double opacity=rand.nextFloat();
Color randomColor = new Color(red, green, blue,opacity);
cell.setColor(randomColor);
return randomColor;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment