# Malevich Simulator

Kasimir Malevich was an early pioneer of geometric abstraction in Russia in the early 20th century, and was the founder of the Suprematist movement. Around 1916, shortly after he completed his iconic Black Square on a White Ground, he painted Suprematist Composition, part of a series of works composed of simple geometric elements.

This computer program allows you to create your own Suprematist Composition.

Here’s what to do;

Click the left mouse button anywhere on the canvas to place a shape there.

Click the right mouse button to place a line

Press any key to erase and start over

//Info: http://processingjs.org/reference

void setup() {
smooth();
size (400, 480);
background(229, 217, 176);
noStroke();
}

void draw () {
{
if (mousePressed && (mouseButton == LEFT)) {
translate(mouseX, mouseY);
rectangle();
noLoop();
}

if (mousePressed && (mouseButton == RIGHT)) {
translate(mouseX, mouseY); // move origin from top left to mouse position
line();
noLoop();
}
}
}

void mousePressed() {
loop();
}

void keyPressed () {
loop();
background(229, 217, 176);
}

void line() {

int c;
c = (int) random(5); // picks one of 5 colours
if (c == 0) fill (233, 110, 4); // orange
if (c == 1) fill (175, 9, 2); // red
if (c == 2) fill (21, 40, 93); // blue
if (c == 3) fill (66, 111, 48); // green
if (c == 4) fill (28, 24, 15); // dark

rectMode(CENTER);

rect(0, 0, random(70, 250), random(4,5));
}

void rectangle() {

int c;
c = (int) random(5); // picks one of 5 colours
if (c == 0) fill (233, 110, 4); // orange
if (c == 1) fill (175, 9, 2); // red
if (c == 2) fill (21, 40, 93); // blue
if (c == 3) fill (66, 111, 48); // green
if (c == 4) fill (28, 24, 15); // dark

rectMode(CENTER);