Left click to generate a new random shape Right click to fill the shape faster Drag the dots on the right to modify the shape Press 'c' to generate a new color palette
xxxxxxxxxx
final int BG_COLOR = 0;
MyColor myColor;
int nbColors = 700;
color[] tabColors = new color[nbColors];
float maxValue;//used for mapping the colors
public Boolean hasToInitColors = false;//allows to refresh colors at the beginning of the loop
Cursors myCursors;
public Boolean dragging = false;
public int currentBox = 0;
final int NB_SPREADERS = 8000;
Spreader[] spreaders = new Spreader[NB_SPREADERS];
int[][] tabPixels;
public final float[] AA = {
-1.48, -.07, 2.01, 0.7403555
};
public final float[] BB = {
1.48, 2.44, 2.53, 0.8053889
};
public final float[] CC = {
1.52, -.72, 1.61, -2.2596846
};
public final float[] DD = {
1.56, 2.56, .33, 2.3320065
};
int r = (int)random(AA.length);
public float aa = AA[r];
public float bb = BB[r];
public float cc = CC[r];
public float dd = DD[r];
public final float ZOOM_VALUE = 4.2;
void setup()
{
size(750, 450, P2D);
myCursors = new Cursors();
tabPixels = new int[width][height];
initColors();
for (int k = 0; k < NB_SPREADERS; k++)
{
spreaders[k] = new Spreader();
}
}
void initColors()//creates a new shader used for the coloring
{
background(BG_COLOR);
myColor = new MyColor();
for (int i = 0; i < nbColors; i++)
{
tabColors[i] = color(myColor.R, myColor.G, myColor.B);
myColor.update();
}
tabColors[0] = BG_COLOR;//the first color is BG_COLOR
}
public void cleanPixels()
{
for (int i = 0; i < width; i++)
{
for (int j = 0; j < height; j++)
{
tabPixels[i][j] = 0;
}
}
}
void draw()
{
if (hasToInitColors)
{
initColors();
hasToInitColors = false;
}
maxValue = 0;//used to choose the appropriate color
for (int k = 0; k < NB_SPREADERS; k++)
{
spreaders[k].update();
}
for (int i = 0; i < width; i++)
{
for (int j = 0; j < height; j++)
{
maxValue = max(maxValue, tabPixels[i][j]);
}
}
maxValue = log(1+maxValue);
color c;//color
float a;//alpha
loadPixels();
for (int i = 0; i < width; i++)
{
for (int j = 0; j < height; j++)
{
c = tabColors[int(map(log(1+tabPixels[i][j]), 0, maxValue, 0, nbColors-1))];
pixels[j * width + i] = c;
}
}
updatePixels();
myCursors.update();
}
void keyPressed()
{
myCursors.transmitKey(key);//the myCursors instance deals with the keys
}
void mousePressed()
{
if (mouseButton == LEFT)
{
int curBox = myCursors.isAboveCursors();
if (curBox == 0)
{
cleanPixels();
myCursors.randomize();
} else
{
currentBox = curBox;
dragging = true;
}
} else
{
for (int k = 0; k < NB_SPREADERS; k++)
{
spreaders[k].rebirth();//increase the drawing rate
}
}
}
void mouseReleased()
{
dragging = false;
}