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_
   Teaching
   Theory and Practice
(Moderators: REAS, arielm)
   Quick Bits : STATIC FORM - 2
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: Quick Bits : STATIC FORM - 2  (Read 2440 times)
arielm


WWW
Quick Bits : STATIC FORM - 2
« on: Mar 2nd, 2004, 10:58pm »

SF2_001
 
Code:
// drawing 2 lines, using one variable
 
int y = 50;
line(0, y, 100, y);  // this line is drawn in black (the default stroke color)
 
stroke(255, 0, 0);   // stroke color is set to red
line(0, y + 10, 100, y + 10);
 

Ariel Malka | www.chronotext.org
arielm


WWW
Re: Quick Bits : STATIC FORM - 2
« Reply #1 on: Mar 2nd, 2004, 10:59pm »

SF2_002
 
Code:
// drawing 2 lines, using one variable
// result is similar to the previous example, but the technique used is different
// (the value of the variable is changing at some point)
 
int y = 50;
line(0, y, 100, y);  // this line is drawn in black (the default stroke color)
 
stroke(255, 0, 0);   // stroke color is set to red
y = y + 10;
line(0, y, 100, y);
 

Ariel Malka | www.chronotext.org
arielm


WWW
Re: Quick Bits : STATIC FORM - 2
« Reply #2 on: Mar 2nd, 2004, 11:03pm »

SF2_003
 
Code:
// creating concentric circles using one variable and multiplication
 
ellipseMode(CENTER_RADIUS);
noFill();
 
int radius = 10;
ellipse(50, 50, radius, radius);  // the radius variable holds 10
 
radius = radius * 2;
ellipse(50, 50, radius, radius);  // the radius variable holds 20
 
radius = radius * 2;
ellipse(50, 50, radius, radius);  // the radius variable holds 40
« Last Edit: Mar 2nd, 2004, 11:07pm by arielm »  

Ariel Malka | www.chronotext.org
arielm


WWW
Re: Quick Bits : STATIC FORM - 2
« Reply #3 on: Mar 2nd, 2004, 11:06pm »

SF2_004
 
Code:
// creating concentric circles using one variable
// result is similar to the previous example, but the technique used is different
// (the value of the variable is not changing)
 
ellipseMode(CENTER_RADIUS);
noFill();
 
int radius = 10;
ellipse(50, 50, radius, radius);     // circle radius is 10
       // the radius variable holds 10
 
ellipse(50, 50, radius * 2, radius * 2);  // circle radius is 20
       // the radius variable holds 10
 
ellipse(50, 50, radius * 4, radius * 4);  // circle radius is 40
       // the radius variable holds 10
 

Ariel Malka | www.chronotext.org
arielm


WWW
Re: Quick Bits : STATIC FORM - 2
« Reply #4 on: Mar 2nd, 2004, 11:08pm »

SF2_005
 
Code:
// using variables to control colors
 
// Creating (Homage to Albers)
// by REAS <http://www.groupc.net>
 
noStroke();
 
color inside = color(204, 102, 0);
color middle = color(204, 153, 0);
color outside = color(153, 51, 0);
 
// These statements are equivalent to the statements above.  
// Programmers may use the format they prefer.  
// color inside = #CC6600;  
// color middle = #CC9900;  
// color outside = #993300;  
 
fill(outside);
rect(0, 0, 100, 100);
 
fill(middle);
rect(20, 30, 60, 60);
 
fill(inside);
rect(30, 45, 40, 40);
 

Ariel Malka | www.chronotext.org
arielm


WWW
Re: Quick Bits : STATIC FORM - 2
« Reply #5 on: Mar 2nd, 2004, 11:10pm »

SF2_006
 
Code:
// using float variables and demonstrating why they're useful
 
float x = 20;
line(x, 0, x, 100);  // x is 20
 
x = x * 1.5;
line(x, 0, x, 100);  // x is 30
 
x = x * 1.5;
line(x, 0, x, 100);  // x is 45
 
x = x * 1.5;
line(x, 0, x, 100);  // x is 67.5
 

Ariel Malka | www.chronotext.org
arielm


WWW
Re: Quick Bits : STATIC FORM - 2
« Reply #6 on: Mar 2nd, 2004, 11:12pm »

SF2_007
 
Code:
// some more arithmetics: drawing a disc that is filling almost all of the upper-right corner of the screen
 
float screen_size = 100;
 
float x = (screen_size / 4) * 3;
float y = screen_size / 4;
float radius = (screen_size / 4) - 5;
 
ellipseMode(CENTER_RADIUS);
ellipse(x, y, radius, radius);
 

Ariel Malka | www.chronotext.org
arielm


WWW
Re: Quick Bits : STATIC FORM - 2
« Reply #7 on: Mar 2nd, 2004, 11:14pm »

SF2_008
 
Code:
// using predefined variables ("width" and "height"), and doing some more arithmetics...
 
ellipseMode(CENTER_RADIUS);
ellipse(width / 2, height / 2, (width / 2) - 10, (height / 2) - 10);
 
line(width / 2, height / 2, width, height);
 

Ariel Malka | www.chronotext.org
arielm


WWW
Re: Quick Bits : STATIC FORM - 2
« Reply #8 on: Mar 2nd, 2004, 11:16pm »

SF2_009
 
Code:
// drawing in a "grid-like" fashion, using one variable...
 
background(0);
noFill();
fill(255, 0, 0);
 
int gs = 20;  // this variable is holding the grid-size
 
ellipse(1 * gs, 1 * gs, 16, 16);
ellipse(2 * gs, 1 * gs, 16, 16);
ellipse(2 * gs, 2 * gs, 16, 16);
ellipse(2 * gs, 3 * gs, 16, 16);
ellipse(1 * gs, 4 * gs, 16, 16);
ellipse(2 * gs, 4 * gs, 16, 16);
ellipse(3 * gs, 4 * gs, 16, 16);
 

Ariel Malka | www.chronotext.org
Pages: 1 

« Previous topic | Next topic »