FAQ
Cover
This is the archive Discourse for the Processing (ALPHA) software.
Please visit the new Processing forum for current information.

   Processing 1.0 _ALPHA_
   Topics & Contributions
   Beyond Categories
(Moderator: REAS)
   a terribly inefficient drawing
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: a terribly inefficient drawing  (Read 1122 times)
Allen Goodman
Guest
Email
a terribly inefficient drawing
« on: Apr 3rd, 2003, 2:03am »

I have no clue what I'm doing - but I love it
 
// sketch - 03.02.2003 - 001
// allen goodman (allen@fksche.com)
 
// a terribly inefficient drawing
 
background(100);
stroke(200);
 
rect(10, 0, 30, 30);
rect(20, 0, 30, 30);
rect(30, 0, 30, 30);
rect(40, 0, 30, 30);
 
stroke(25);
 
rect(50, 0, 30, 30);
rect(60, 0, 30, 30);
rect(70, 0, 30, 30);
rect(80, 0, 30, 30);
rect(90, 0, 30, 30);
 
stroke(50);
 
rect(100, 0, 30, 30);
rect(10, 0, 30, 10);
rect(20, 0, 40, 20);
rect(30, 0, 30, 30);
 
stroke(25);
 
rect(40, 0, 40, 40);
rect(50, 0, 30, 50);
rect(60, 0, 40, 60);
rect(70, 0, 30, 70);
rect(80, 0, 40, 80);
rect(90, 0, 30, 90);
 
stroke(100);
 
rect(100, 0, 40, 100);
rect(10, 10, 90, 10);
rect(20, 20, 90, 20);
rect(30, 30, 90, 30);
rect(40, 40, 90, 40);
rect(50, 50, 90, 50);
rect(60, 60, 90, 60);
rect(70, 70, 90, 70);
rect(80, 80, 90, 80);
rect(90, 90, 90, 90);
 
stroke(150);
 
rect(100, 100, 90, 100);
rect(10, 10, 80, 10);
rect(20, 20, 70, 20);
rect(30, 30, 60, 30);
rect(40, 40, 50, 40);
rect(50, 50, 40, 50);
rect(60, 60, 30, 60);
rect(70, 70, 20, 70);
rect(80, 80, 10, 80);
rect(10, 10, 80, 10);
rect(20, 20, 70, 20);
rect(30, 30, 60, 30);
rect(40, 40, 50, 40);
rect(50, 50, 40, 50);
rect(60, 60, 30, 60);
rect(60, 60, 20, 70);
rect(70, 70, 10, 80);
 
rect(0, 10, 90, 10);
rect(0, 20, 90, 20);
rect(0, 30, 90, 30);
rect(0, 40, 90, 40);
rect(0, 50, 90, 50);
rect(0, 60, 90, 60);
rect(0, 70, 90, 70);
rect(0, 80, 90, 80);
 
Allen Goodman
Guest
Email
Re: a terribly inefficient drawing
« Reply #1 on: Apr 3rd, 2003, 2:39am »

Hm, a tad more efficient (50% smaller in fact), but it’s still not very pretty.  
 
I hope no one minds that I posted this, I’m just a new user looking for tips.
 
// sketch - 03.02.2003 - 002
// allen goodman (allen@fksche.com)
 
// a terribly inefficient drawing (part 2)
 
stroke(200);
 
rect(0, 0, 10, 10);
rect(10, 0, 10, 10);
rect(20, 0, 10, 10);
rect(30, 0, 10, 10);
rect(40, 0, 10, 10);
rect(50, 0, 10, 10);
rect(60, 0, 10, 10);
rect(70, 0, 10, 10);
rect(80, 0, 10, 10);
rect(90, 0, 10, 10);
 
rect(90, 10, 10, 10);
rect(90, 20, 10, 10);
rect(90, 30, 10, 10);
rect(90, 40, 10, 10);
rect(90, 50, 10, 10);
rect(90, 60, 10, 10);
rect(90, 70, 10, 10);
rect(90, 80, 10, 10);
rect(90, 90, 10, 10);
rect(90, 100, 10, 10);
 
rect(0, 10, 90, 10);
rect(0, 20, 90, 10);
rect(0, 30, 90, 10);
rect(0, 40, 90, 10);
rect(0, 50, 90, 10);
rect(0, 60, 90, 10);
rect(0, 70, 90, 10);
rect(0, 80, 90, 20);
 
Martin

122417302122417302martingomez_listsmg1ph WWW Email
Re: a terribly inefficient drawing
« Reply #2 on: Apr 3rd, 2003, 3:01am »

moments of genius come when you don't seem to know what you're doing. ... your work is very pretty.
 
hope this helps.
 
Code:
// sketch - 03.02.2003 - 002  
// allen goodman (allen@fksche.com)  
   
// a terribly inefficient drawing (part 2)  
 
// modified by martin - 04.03.2003
 
size(200,200); // define canvas size
background(255); // paper is 255/255 gray
stroke(200);  // pen is 200/255 gray
 
scale(2.0); // magnify everything x2
 
for(int i = 0; i <= 90; i+=10)
// repeat from i = 0 to i = 90, with i
// incrementing by 10 for each step
{
  rect(i, 0, 10, 10); // draw the first rect series
  rect(90, i+10, 10, 10); // draw the second rect series
  if(i<80) rect(0,i+10,90,10);
  // we don't want to reach 90
  // and we don't want to do another loop
  // removing the if(i<80) statment will
  // also render the same thing :)
}
 
REAS


WWW
Re: a terribly inefficient drawing
« Reply #3 on: Apr 3rd, 2003, 6:44pm »

"efficiency" is a matter of perception. writing programs line by line rather than in loops makes them run no slower and can give us an easier appreciation of the program's scope.  
 
Allen


Re: a terribly inefficient drawing
« Reply #4 on: Apr 3rd, 2003, 8:21pm »

Quote:

moments of genius come when you don't seem to know what you're doing. ... your work is very pretty.  
 
hope this helps.  

 
Thank you Martin! This is exactly the kind of help that I needed
 
Though I'm a tad confused by this line:
 
Code:
if(i<80) rect(0,i+10,90,10);

 
Could you explain it in a little more detail?
 
Quote:
"efficiency" is a matter of perception. writing programs line by line rather than in loops makes them run no slower and can give us an easier appreciation of the program's scope.

 
Thank you for the kind words!
 
...
 
I wrote my first 'loop' (I think that's what it's called, I even understand it).
 
Code:
// sketch - 04.03.2003 - 004  
// allen goodman (allen@fksche.com)  
    
// a terribly inefficient drawing (part 4)  
 
// modified by martin - 04.03.2003  
 
size(200,200); // define canvas size  
background(255); // paper is 255/255 gray  
stroke(200);  // pen is 200/255 gray  
 
scale(2.0); // magnify everything x2  
 
for(int i = 0; i <= 90; i+=10)  
// repeat from i = 0 to i = 90, with i  
// incrementing by 10 for each step  
{  
  rect(i, 0, 10, 10); // draw the first rect series  
  rect(90, i+10, 10, 10); // draw the second rect series  
  if(i<80) rect(0,i+10,90,10);  
  // we don't want to reach 90  
  // and we don't want to do another loop  
  // removing the if(i<80) statment will  
  // also render the same thing :)  
}
stroke(225);  
for(int x = 0; x <= 90; x+=5)  
{  
  line(10, 10, x, 90); // draw the first line series  
}
« Last Edit: Apr 3rd, 2003, 8:22pm by Allen »  
Martin

122417302122417302martingomez_listsmg1ph WWW Email
Re: a terribly inefficient drawing
« Reply #5 on: Apr 4th, 2003, 9:21am »

casey, humanizing programming? i guess it can be brought up here that it's easier for the human eye to read three lines of code (let's say a for loop with one statement inside) rather than let's say 100 lines of code. therefore, this puts the statement "easier appreciation of the program's scope" into jeopardy. however, it is very true that doing it line by line would help us appreciate the hard work required if we were to do this in the physical realm (i.e. carving it on bamboo with a small knife).
 
 
 
hi allen,
 
Code:
if(i<80) rect(0,i+10,90,10);

is actually a shortcut for
Code:
if(i<80)
{
  rect(0,i+10,90,10);
}

 
the braces aren't required if you only have a single statement for the condition.
 
the whole code block can be read as: if i is less than 80, perform rect(0,i+10,90,10), or anything inside the braces. if not, then do not do anything. sometimes, using a single character logical operator ( < or > ) causes confusion. therefore, using ==, >= or <= like what you did in your loop is good. something that's easy to spot and imagine right away.
 
now that i mentioned it, i just saw a typo on my part for the code. ... i didn't see that the last value for the last line is a 20. i thought it's a 10. here's the modified code.
 
Code:
// sketch - 04.03.2003 - 004    
// allen goodman (allen@fksche.com)    
     
// a terribly inefficient drawing (part 4)    
   
// modified by martin - 04.04.2003  
   
size(200,200); // define canvas size  
background(255); // paper is 255/255 gray  
stroke(200);  // pen is 200/255 gray  
   
scale(2.0); // magnify everything x2  
   
for(int i = 0; i <= 90; i+=10)  
// repeat from i = 0 to i = 90, with i  
// incrementing by 10 for each step  
{  
  rect(i, 0, 10, 10); // draw the first rect series  
  rect(90, i+10, 10, 10); // draw the second rect series  
  if(i<=60) rect(0,i+10,90,10);  
  // we don't want to reach 90  
  // and we don't want to do another loop  
  // removing the if(i<80) statment will  
  // also render the same thing :)  
  if(i==80) rect(0,i,90,20);  // for the last line
}  
stroke(225);  
for(int x = 0; x <= 90; x+=5)  
{  
  line(10, 10, x, 90); // draw the first line series  
}

 
and a slight modification to illustrate how conditions can affect the code's output...
 
Code:
// sketch - 04.03.2003 - 004    
// allen goodman (allen@fksche.com)    
     
// a terribly inefficient drawing (part 4)    
   
// modified by martin - 04.04.2003  
   
size(200,200); // define canvas size  
background(255); // paper is 255/255 gray  
stroke(200);  // pen is 200/255 gray  
   
scale(2.0); // magnify everything x2  
   
for(int i = 0; i <= 90; i+=10)  
// repeat from i = 0 to i = 90, with i  
// incrementing by 10 for each step  
{  
  rect(i, 0, 10, 10); // draw the first rect series  
  rect(90, i+10, 10, 10); // draw the second rect series  
  if(i<=60) rect(0,i+10,90,10);  
  // we don't want to reach 90  
  // and we don't want to do another loop  
  // removing the if(i<80) statment will  
  // also render the same thing :)  
  if(i==80) rect(0,i,90,20);  // for the last line
}  
// stroke(225);   // we'll use this inside the loop
for(int x = 0; x <= 90; x+=5)  
{  
  if( x % 2 == 0 ) // if x is even; % means modulo division
  {
    stroke(225);
    line(10, 10, x, 90); // draw the first line series
    // add more statements here as wanted
  }
  else // if not; if x is odd
  {
    stroke(200);
    line(80, 10, x, 90); // draw the second line series
    // add more statements here as wanted
  }
  // line(10, 10, x, 90); // draw the first line series  
  // we placed this on top
}

 
looking forward to see more of your drawings.
 
Allen


Re: a terribly inefficient drawing
« Reply #6 on: Apr 9th, 2003, 4:33am »

Martin, it takes me a while to comprehend your code - but it's much appreciated. Thanks again!
 
Here is a drawing from the P5 sketchbook I have been keeping for the last week or so ...
 

 
Code:

// p5 sketchbook
//
// 04.08.2003
// allen goodman (allen@fksche.com)
 
size(200,200);
background(255);
 
scale(2.0);
 
stroke(160);
for(int x = 1; x <= 23; x+=2)
{
  line(0,0,x,100);  
}
 
stroke(170);
for(int x = 25; x <= 49; x+=2)
{
  line(0,0,x,100);  
}
 
stroke(180);
for(int x = 51; x <= 73; x+=2)
{
  line(0,0,x,100);  
}
 
stroke(190);
for(int x = 75; x <= 99; x+=2)
{
  line(0,0,x,100);  
}
 
stroke(200);
for(int x = 75; x <= 99; x+=2)
{
  line(0,0,100,x);  
}
 
stroke(210);
for(int x = 51; x <= 73; x+=2)
{
  line(0,0,100,x);  
}
 
stroke(220);
for(int x = 25; x <= 49; x+=2)
{
  line(0,0,100,x);  
}
 
stroke(230);
for(int x = 1; x <= 23; x+=2)
{
  line(0,0,100,x);  
}
« Last Edit: Apr 9th, 2003, 7:58am by Allen »  
Martin

122417302122417302martingomez_listsmg1ph WWW Email
Re: a terribly inefficient drawing
« Reply #7 on: Apr 9th, 2003, 5:49pm »

slowly but surely allen. am glad to see your progress.
 
a very beautiful piece i should say. ... it reminds of the study of concentrics by professor maeda. hmm... try this as an exercise: try to get the origin to the center of the canvas. that way, you'll have a radiating effect from the center with the appropriate gradation.
 
Allen


Re: a terribly inefficient drawing
« Reply #8 on: Apr 9th, 2003, 11:23pm »

Thanks for the encouragement; I think it turned out well (besides the top right obviously).
 
Have another challenge for me? : )
 
Code:
// p5 sketchbook
//
// 04.09.2003
// allen goodman (allen@fksche.com)
 
size(200,200);
background(255);
 
scale(2.0);
 
// right
 
{
  stroke(219);
  for(int x = 1; x <= 23; x+=2)
    {
    line(100,x,50,50);
    }
    
  stroke(217);
  for(int x = 25; x <= 49; x+=2)
    {
    line(100,x,50,50);
    }
    
  stroke(215);
  for(int x = 51; x <= 73; x+=2)
    {
    line(100,x,50,50);
    }
    
  stroke(213);
  for(int x = 75; x <= 99; x+=2)
    {
    line(100,x,50,50);
    }
}
 
// bottom
 
{
  stroke(205);
  for(int x = 1; x <= 23; x+=2)
    {
    line(x,100,50,50);
    }
    
  stroke(207);
  for(int x = 25; x <= 49; x+=2)
    {
    line(x,100,50,50);
    }
    
  stroke(209);
  for(int x = 51; x <= 73; x+=2)
    {
    line(x,100,50,50);
    }
    
  stroke(211);
  for(int x = 75; x <= 99; x+=2)
    {
    line(x,100,50,50);
    }
}
 
// left
 
{
  stroke(197);
  for(int x = 1; x <= 23; x+=2)
    {
    line(50,50,0,x);
    }
    
  stroke(199);
  for(int x = 25; x <= 49; x+=2)
    {
    line(50,50,0,x);
    }
    
  stroke(201);
  for(int x = 51; x <= 73; x+=2)
    {
    line(50,50,0,x);
    }
    
  stroke(203);
  for(int x = 75; x <= 99; x+=2)
    {
    line(50,50,0,x);
    }
}
 
// top
 
{
  stroke(195);
  for(int x = 1; x <= 23; x+=2)
    {
    line(50,50,x,0);
    }
    
  stroke(193);
  for(int x = 25; x <= 49; x+=2)
    {
    line(50,50,x,0);
    }
    
  stroke(191);
  for(int x = 51; x <= 73; x+=2)
    {
    line(50,50,x,0);
    }
    
  stroke(189);
  for(int x = 75; x <= 99; x+=2)
    {
    line(50,50,x,0);
    }
}
« Last Edit: Apr 9th, 2003, 11:26pm by Allen »  
Allen


Re: a terribly inefficient drawing
« Reply #9 on: Apr 9th, 2003, 11:33pm »

Oh, and I just checked out the Concentrics page at madeastudio.com, he never ceases to amaze me ... great stuff.
« Last Edit: Apr 9th, 2003, 11:34pm by Allen »  
Martin

122417302122417302martingomez_listsmg1ph WWW Email
Re: a terribly inefficient drawing
« Reply #10 on: Apr 10th, 2003, 5:18am »

sorry, my bad. 'concentrics' should be 'space density'. ... i just realized that he had a different use of the word concentric and that he had another title for the pieces. sorry again. these are the pieces that i was originally referring to: http://www.cristinerose.com/maeda/maeda002.jpg and  http://www.cristinerose.com/maeda/maeda004.jpg
 
re: your composition, ah yes, good good, now move beyond the 101 number constraint and create something.
« Last Edit: Apr 10th, 2003, 5:21am by Martin »  
benelek

35160983516098 WWW Email
Re: a terribly inefficient drawing
« Reply #11 on: Apr 12th, 2003, 3:15am »

je-sus! that man knows his geometry
 
Pages: 1 

« Previous topic | Next topic »