Category Archives: Programming

Computer-generated wall pieces

Part of my studio research has involved making wall-based pieces and writing computer programs to guide me in the generation of the shapes. I based this on a simple grid format; screws set into the wall had lengths of coloured wool wrapped around and I used the program to plot the path the wool would take from one point to another. By making changes to the computer code I was able to vary how the paths were generated, sometimes only allowing vertical and horizontal lines and sometimes diagonals. I was also able to make the program favour a particular side or corner of the grid. Below is an example of one of the programs running.

//Info: http://processingjs.org/reference
// draw 18 x 14 grid, when key pressed draws a random line from
// one nail to another, alternating between horizontal and vertical

int nailx =40;
int naily =40;
int count = 1;

void setup() { // draw nails on wall 18 * 14 grid
frameRate(2);
size (680, 520);
background(32, 16, 16);
smooth();
drawgrid();
}

void draw() {

drawgrid(); // red circle first, then blue
rolldiceX();
dicey=0;
linewalk();
fill (200, 0, 0);
noStroke();
ellipse(x2, y2, 6, 6);

rolldiceY();
dicex=0;
linewalk();
fill (0, 0, 200);
noStroke();
ellipse(x2, y2, 6, 6);

if (count == 100) {
background(32, 16, 16);
count=1;
}
count = count+1;
}

void keyPressed() {
}
void drawgrid() {
smooth();
noStroke();
fill (160, 220, 230);
for (nailx=40; nailx<width;nailx = nailx+ 40) {
for (naily=40; naily=width){ // keeps line inside box
x2 = x2-((int)random(3,4)*40);
}
if (x2=height){
y2 = y2 -((int)random(3,4)*40);
}
if (y2<=0){
y2 = y2 +((int)random(3,4)*40);
}

line (x1,y1,x2,y2);

x1=x2;
y1=y2;
}

These are some examples of the imagery generated by the programs, along with the wall pieces based on them. I found this a useful way of exploring the issues of artistic labour and authorship.




Rothko Simulator

Mark Rothko, (1903-1970) was associated with the Abstract Expressionist movement, and his signature style featured large fields of diffuse, often complimentary colour, painted on canvasses that were often very large in scale.


This program allows you to create your own Rothko painting.

Here’s what to do;

Press the left mouse button anywhere on the canvas to create a large colour field

Press the right mouse button to make a thinner stripe

Press any key to erase and start over

 

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

// draws simulated Rothko. press left mouse to draw colour fields
// press right mouse for narrow band

void setup() {
size (350, 460);
background (random(107, 229), random(107, 229), random(107, 229));
smooth();
frameRate(4000);
}

void draw() {
}

void mousePressed() {

if (mousePressed &&(mouseButton == LEFT)) {

int xx1 = (mouseX);
int yy1 = (mouseY);

int wwidth = (width – (int)random(30, 40)); // adjust rectangle size
int xright = width-wwidth;
int xleft = (-10)+wwidth;
int hheight = ((int)random(70, 100)); // adjust rectangle size
int ydown = yy1+hheight;
int yup = yy1-hheight;

colourpick(); // pick random colour for lines

loop=60000;

for (int count = 0; count =xright) { // keeps line inside box
xx2 = xx2-((int)random(10, 20));
}
if (xx2=ydown) {
yy2 = yy2 -((int)random(10, 20));
}
if (yy2<=yup) {
yy2 = yy2 +((int)random(10, 20));
}

line (xx1, yy1, xx2, yy2);
xx1=xx2;
yy1=yy2;
}
}

if (mousePressed &&(mouseButton == RIGHT)) {

int xx1 = (mouseX);
int yy1 = (mouseY);

int wwidth = (width – (int)random(45, 50)); // adjust rectangle size
int xright = width-wwidth;
int xleft = (-10)+wwidth;
int hheight = ((int)random(20, 30)); // adjust rectangle size
int ydown = yy1+hheight;
int yup = yy1-hheight;

colourpick(); // pick random colour for lines
loop=15000;

for (int count = 0; count =xright) { // keeps line inside box
xx2 = xx2-((int)random(10, 20));
}
if (xx2=ydown) {
yy2 = yy2 -((int)random(10, 20));
}
if (yy2<=yup) {
yy2 = yy2 +((int)random(10, 20));
}

line (xx1, yy1, xx2, yy2);
xx1=xx2;
yy1=yy2;
}
}
}

void keyPressed() {
background (random(107, 229), random(107, 229), random(107, 229));
}

void colourpick(){ // picks one of 5 colours for line

int c;
c = (int) random(5); // picks one of 5 colours
if (c == 0) stroke (223 +(random(20)), 110+(random(20)), 4+(random(20)), 30); // orange
if (c == 1) stroke (175+(random(20)), 9+(random(20)), 2+(random(20)), 20); // red
if (c == 2) stroke (21+(random(20)), 40+(random(20)), 93+(random(20)), 20); // blue
if (c == 3) stroke (66+(random(20)), 111+(random(20)), 48+(random(20)), 25); // green
if (c == 4) stroke (240+(random(20)), 230+(random(20)), 115+(random(20)), random(15)); // dark

}

void rolldiceX() { // pick random number

dicex=((int)random(-20, 20));
if (dicex == 0) { // if result is 0 go again
rolldiceX();
}
}

void rolldiceY() { // pick random number
dicey=((int)random(-20, 20));
if (dicey == 0) { // if result is 0 go again
rolldiceY();
}
}

int dicex;
int dicey;
int xx1;
int yy1;
int wwidth;
int hheight;
int xright;
int xleft;
int yup;
int ydown;
int xx2;
int yy2;
int scale;
int loop;

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.

Suprematist Composition 1916
Suprematist Composition 1916

 

 

 

 

 

 

 

 

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);

rotate(radians(random(360)));
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);

rotate(radians(random(140, 200)));
rect(0, 0, random(40, 150), random(13, 65));
}

Mondrian Simulator

In 1917, before he introduced the grid into his work, Piet Mondrian painted Composition with Line, consisting of a series of horizontal and vertical elements arranged on the canvas. He was trying to intuitively express a sense of harmony and beauty through the use of basic purely geometric forms.

This computer program allows you to create your own version of Composition with Line 1917,

Composition With Lines (1917)
Composition With Lines (1917)

 

 

 

 

 

 

 

 

Here’s what to do;

Hold down the left mouse button and move around the canvas.

Press any key to erase and start again

// <![CDATA[
//Info: http://processingjs.org/reference

void setup() {
size (500, 500);
background (235, 240, 230);
stroke (15, 35, 20, 200);
// ellipse(300,300,600,600);
frameRate (5);
strokeWeight(5);
smooth();
}

void draw() {

float shiftx=random(16);
float shifty=random(20);

if (mousePressed) {
stroke (15, 35, 20, 200); //draw if mouse button pressed
}
else {
noStroke(); //don't draw if mouse button not pressed
}
int x=mouseX;
int y=mouseY;
line(x, y, x+random(10, 30), y); // horizontal line
line(x+shiftx, y-shifty, x+shiftx, y+shifty); //vertical line
}

void keyPressed() {
background (235, 240, 230);
}

Albers Simulator

Josef Albers (1888-1976) is probably best known for his series, begun in 1949, of Homage to the Square, where he explored the chromatic interactions between nested squares. He explored this theme through hundreds of paintings and prints, typically featuring three or four nested squares.


This is a program to simulate the work of Josef Albers

Here’s what to do;

Click left mouse button to change all colours

Click right mouse button on a segment to change its colour

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

void setup() {
smooth();
size(600, 600);
noStroke();
background(255);
rectMode(CORNERS);

draw1(); // draw initial image
draw2();
draw3();
draw4();
}

void draw() {
}

void mousePressed() {

if (mousePressed &&(mouseButton == LEFT)) { // redraw whole image mith mouse LEFT
draw1();
draw2();
draw3();
draw4();
}

if (mousePressed &&(mouseButton == RIGHT)) { // redraw only the square clicked with mouse RIGHT

if (((mouseX >= 190) && (mouseX = 280) && (mouseY = 130) && (mouseX = 190) && (mouseY = 70) && (mouseX = 100) && (mouseY <= 560))) {
colour3();
draw3();
}
else {
colour4();
draw4();
}
}
}

void draw4() {
colour4(); // random colour
rect(10, 10, 590, 100);// largest square 4
rect(10, 560, 590, 590);
rect(10, 100, 70, 560);
rect(530, 100, 590, 560);
}

void draw3() {
colour3();
rect(70, 100, 530, 190);// next largest square 3
rect(70, 530, 530, 560);
rect(70, 190, 130, 530);
rect(470, 190, 530, 530);
}

void draw2() {
colour2();
rect(130, 190, 470, 280); // next largest square 2
rect (130, 500, 470, 530);
rect (130, 280, 190, 500);
rect (410, 280, 470, 500);
}

void draw1() {
colour1();
rect(190, 280, 410, 500); // smallest square 1
}

void colour1 () {
fill (random(20, 230), random(20, 230), random(20, 230));
}

void colour2 () {
fill (random(35, 215), random(35, 215), random(35, 215));
}

void colour3 () {
fill (random(45, 200), random(45, 200), random(45, 200));
}

void colour4 () {
fill (random(60, 180), random(60, 180), random(60, 180));
}

Embedding Processing sketches

This is my first attempt at embedding a processing sketch into a webpage (many thanks to Paul Green for showing me how)

Here’s what to do;

PressĀ left mouse button to generate a shape

Press right mouse button to darken the image

Press any key to start over

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

void setup() {
size (600, 440);
background(10, 15, 15);
smooth();
frameRate(2000);
}

void draw() {
}

void mousePressed() {
if (mousePressed &&(mouseButton == RIGHT)) { // subtle eraser
stroke (random(10,20),random(10,20),random(10,20),(random(17,23)));
int x1 = ((int)random(1, width));
int y1 = ((int)random(1, height));
for (int count = 0; count < 30000; count ++) {

linewalk();
}
}
if (mousePressed &&(mouseButton == LEFT)) {

int xx1 = (mouseX);
int yy1 = (mouseY);

int wwidth = ((int)random(10, 110)); // adjust rectangle size
int xright = xx1+wwidth;
int xleft = xx1-wwidth;
int hheight = ((int)random(10, 70)); // adjust rectangle size
int ydown = yy1+hheight;
int yup = yy1-hheight;

colourpick(); // pick random colour for lines
scale = (hheight*wwidth); // makes larger rectangles denser
if(scale 7000) {loop=30000;}

for (int count = 0; count =xright) { // keeps line inside box
xx2 = xx2-((int)random(15, 20));
}
if (xx2=ydown) {
yy2 = yy2 -((int)random(15, 20));
}
if (yy2=width) { // keeps line inside box
x2 = x2-((int)random(15, 20));
}
if (x2=height) {
y2 = y2 -((int)random(15, 20));
}
if (y2<=0) {
y2 = y2 +((int)random(15, 20));
}

line (x1, y1, x2, y2);

x1=x2;
y1=y2;
}