So i worked on the code a little bit more and reached this point
import controlP5.*;
ControlP5 gui;
float Size = 15 ;
float Rotate = 45;
float Alpha1 = 50;
float Alpha2 = 50;
float Multiplier = 1;
int RotateScr = 1;
float col;
float boost;
color Color1;
color Color2;
int w = 600;
int h = 600;
int scl = 50;
int saveP ;
int cols = w/scl;
int rows = h/scl;
int index = cols;
int index2 =rows;
boolean toggleValue = false;
Object[][] thing;
int[] rastgele = new int[100];
void setup()
{
size(800, 600);
colorMode(RGB, 50);
gui= new ControlP5(this);
gui.addToggle("toggle")
.setPosition(600, 560)
.setSize(180, 20)
.setValue(false)
.setMode(ControlP5.SWITCH)
;
gui.addButton("SaveJpeg")
.setValue(1)
.setPosition(600, 530)
.setSize(150, 20)
.activateBy(ControlP5.RELEASE);
;
gui.addSlider("Size")
.setPosition(600, 20)
.setSize(150, 20)
.setRange(15, 40)
;
gui.addSlider("Rotate")
.setPosition(600, 60)
.setSize(150, 20)
.setRange(1, 90)
;
gui.addSlider("Alpha1")
.setPosition(600, 140)
.setSize(150, 20)
.setRange(1, 50)
;
gui.addSlider("Alpha2")
.setPosition(600, 180)
.setSize(150, 20)
.setRange(1, 50)
;
gui.addSlider("Multiplier")
.setPosition(600, 100)
.setSize(150, 20)
.setRange(0.5, 2)
;
gui.addSlider("RotateScr")
.setPosition(600, 500)
.setSize(150, 20)
.setNumberOfTickMarks(4)
.setRange(1, 4)
;
gui.addColorWheel("Color1", 620, 200, 120).setRGB(color(255, 255, 0));
gui.addColorWheel("Color2", 620, 340, 120).setRGB(color(0, 45, 90));
thing = new Object[index][index2];
}
void draw() {
background(0);
for (int y = 0; y<rows; y++)
{
for (int x = 0; x<cols; x++)
{
thing[x][y] = new Object((scl/2)+(x*scl), (scl/2)+(y*scl), (y)*(Alpha1/5), ((30/(600/(Size)))*((x+y)*(Multiplier))), (Rotate), x*(Alpha2/5));
}
}
for (int k = 0; k < index; k++)
{
for (int z = 0; z < index2; z++)
{
if (k%3==0 || z%2 ==0)
{
fill(Color1, boost);
} else
{
fill (Color2, col);
}
if (RotateScr==1)
{
// pushMatrix();
//translate(600,0);
//rotate(PI/2);
thing[k][z].showObject();
//popMatrix();
}
if (RotateScr==2)
{
pushMatrix();
translate(600, 0);
rotate(PI/2);
thing[k][z].showObject();
popMatrix();
}
if (RotateScr==3)
{
pushMatrix();
translate(600, 600);
rotate(PI);
thing[k][z].showObject();
popMatrix();
}
if (RotateScr==4)
{
pushMatrix();
translate(0, 600);
rotate((3*PI)/2);
thing[k][z].showObject();
popMatrix();
}
}
}
}
void SaveJpeg()
{
PImage temp = get(0, 0, 600, 600);
temp.save("image "+nf(saveP, 4)+".jpeg");
saveP++;
println("Jpeg Saved");
}
void toggle(boolean theFlag)
{
if (theFlag==true) {
fill(0, 0, 0);
rect(300, 300, 600, 600);
noLoop();
println("Shut Down.");
} else {
loop();
println("Open Again.");
}
}
class Object {
float x;
float y;
float size;
float rot = 1;
Object(float _x, float _y, float _col, float _size, float _rot,float _boost) {
rot = _rot;
x = _x;
y = _y;
size = _size;
col = _col;
boost=_boost;
}
void showObject() {
rectMode(CENTER);
noStroke();
pushMatrix();
translate(x,y);
rotate(rot);
rect(0, 0, size, size);
popMatrix();
}
}
Only two things that can be considered as missing now .
1)Assigning one of the two set colors to random objects in the array
2) then sorting the randomly colored objects in the array either horizontally or vertically.
Thanks in advance.