Art from Code: i’m bad at golf (and code)

Describe the object

“I suck at golf(and code)” is a piece coded using software called processing. Depicted is a never-ending and maddening scene as the golf balls swirl and dash across the screen never meeting the satisfaction of making their way into the golf hole. 

Describe your motivation in creating this object 

I created this piece in my earlier days of learning to code. The assignment was to create something demonstrating movement and use of several colors. When I thought of the word “movement” the image of golf popped into my head. I’m not entirely sure why this was the first thing to come to mind as I am definitely not a golf or sports person. Nevertheless this actually worked out perfect as ellipses were something I was becoming most comfortable in knowing how to code. Also I knew the repetition of coding shapes and colors to create a golf scene would give me good practice for my continued learning.  

Describe your process

I began by pulling from the internet several photographs of golf holes to use as reference. From that I started to match the colors to the best of my ability using an RGB color generator. To lay a base for my code I coded the background to have a bright green color to imitate turf. With this I began to start on the golf hole. I made sure to make the hole perfectly center to the canvas so that the viewer’s eyes would be drawn there. I coded ellipse over ellipse over ellipse and spent many hours changing their positions, sizes, and color to replicate depth and realism. When showing the code to my friends with only the hole, the pole, and the golf balls, they were not sure what it was, some even guessed an eyeball. I like to ask my friends for their view of my work to make sure a viewer is seeing what I am trying to represent. With this feedback I decided to add the laying golf club. Going back to my friends after this addition they were more easily able to guess it as a golf hole. 

What does the project mean to you?

This piece was the first ever piece of code I was proud of. Up till this point I was struggling with getting what ideas I had in my head to reflect onto my screen. With this code I felt I had finally succeeded. Even with the class coming to an end this early code of mine is still my favorite. I think I showed exactly what I wanted to portray. My concept was to demonstrate the maddening aspect of coding where you are sitting there at 3am flipping off a hundred lines of code because even with all this work it feels like it will never turn out how you want through the never ending image of golf balls never reaching their target. 

My code

int radius = 250;

float angle = 0.05;

int scalar = 100;

float speed = 0.05;

float yl = 0;

float xl = 0;

float xw = 0;

float yw = 0;

float yb = 0;

float d = 5;

float g = 166;

void keyPressed(){

  save(“check_in_05” + frameCount + “.png”);

 }

void setup() {

  size(500, 500);

  smooth();

}

void draw() {

  background(50, g, 52);

  float y = radius + cos(angle) * scalar;

  float x = radius + sin(angle) * scalar;

fill(219,214,211);

rect (-150,-150,50,50);

  //dark grass

  fill (30, 61, 33, 100);

  ellipse (250, 250, 260, 250);

  //brown trim

  stroke (105, 59, 32);

  strokeWeight (2);

  fill (110, 82, 33);

  ellipse(250, 250, 200, 200);

  //white trim

  stroke (135, 134, 131);

  strokeWeight (4);

  fill (222, 216, 206);

  ellipse(250, 250, 180, 180);

  //gray circle

  stroke (99, 98, 92);

  strokeWeight (9);

  fill (156, 151, 142);

  ellipse(250, 250, 120, 120);

  //bottom circle

  stroke (54, 53, 50);

  strokeWeight (6);

  fill (46, 45, 43);

  ellipse(250, 250, 40, 40);

  //ciruclar moving golf ball

  noStroke();

  fill (255, 255, 255);

  ellipse(x, y, 50, 50);

  //linear moving golf ball

  noStroke();

  fill (255, 255, 255);

  ellipse(xl, yl, 50, 50);

  xl = xl + 2;

  yl = yl + 1;

  //pole

  noStroke();

  fill (235, 231, 221);

  ellipse (250, 250, 30, 30);

  rect (235, -250, 30, 500);

  //wrapping golf ball

  noStroke();

  fill (255, 255, 255);

  ellipse(50, yw, 50, 50);

  yw = yw – 2;

  if (yw < 0) {

    yw = 600;

  }

  //bouncing golf ball

  noStroke();

  fill (255, 255, 255);

  ellipse(380, yb, 50, 50);

  yb = yb + d;

  if (yb > height || yb < 0) {

    d = d*-1;

    g = g-10;

  }

  if (g < 106) {

    g = 166;

  }

  //sink and source golf ball

  println (“g” + g);

  angle = angle + speed;

  fill(18,17,16);

rect (40,350,80,100);

rect (40,420,100,30);

fill (219,218,217);

rect (140,430,275,14);

fill (0,0,0,30);

rect (140,430,275,4);

rect (140,440,275,4);

fill (18,17,16);

rect (410,427,60,20);

Author: Megan Krug