mirror of
https://github.com/jneug/zeichenmaschine.git
synced 2026-10-12 09:56:33 +02:00
Viele weitere Beispielprojekt für verschiedene Anwendungen
This commit is contained in:
40
examples/zm_generative/GenColors.java
Normal file
40
examples/zm_generative/GenColors.java
Normal file
@@ -0,0 +1,40 @@
|
||||
import schule.ngb.zm.Color;
|
||||
import schule.ngb.zm.Zeichenmaschine;
|
||||
|
||||
public class GenColors extends Zeichenmaschine {
|
||||
|
||||
public static void main( String[] args ) {
|
||||
new GenColors();
|
||||
}
|
||||
|
||||
public GenColors() {
|
||||
super(800, 800, "Nice Colors");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setup() {
|
||||
genPattern();
|
||||
}
|
||||
|
||||
public void genPattern() {
|
||||
drawing.noStroke();
|
||||
|
||||
int SIZE = 40;
|
||||
for( int i = 0; i < width/SIZE; i++ ) {
|
||||
for( int j = 0; j < height/SIZE; j++ ) {
|
||||
Color c = randomNiceColor();
|
||||
float[] hsl = Color.RGBtoHSL(c.getRGBA(), null);
|
||||
System.out.printf("%f, %f, %f\n", hsl[0], hsl[1], hsl[2]);
|
||||
drawing.setFillColor(c);
|
||||
drawing.square(i*SIZE, j*SIZE, SIZE, NORTHWEST);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClicked() {
|
||||
genPattern();
|
||||
redraw();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user