Removing a few examples for 2.0

This commit is contained in:
Casey Reas
2011-09-16 00:02:20 +00:00
parent 93b887ee24
commit c3b8b312a0
31 changed files with 318 additions and 417 deletions
@@ -1,41 +1,37 @@
/**
* Coordinates.
*
* All shapes drawn to the screen have a position that is specified as a coordinate.
* All coordinates are measured as the distance from the origin in units of pixels.
* The origin [0, 0] is the coordinate is in the upper left of the window
* and the coordinate in the lower right is [width-1, height-1].
* All shapes drawn to the screen have a position that is
* specified as a coordinate. All coordinates are measured
* as the distance from the origin in units of pixels.
* The origin [0, 0] is the coordinate is in the upper left
* of the window and the coordinate in the lower right is
* [width-1, height-1].
*/
// Sets the screen to be 200, 200, so the width of the window is 200 pixels
// and the height of the window is 200 pixels
size(200, 200);
size(640, 360);
background(0);
noFill();
stroke(255);
// The two parameters of the point() method each specify coordinates.
// This call to point() draws at the position [100, 100]
point(width/2, height/2);
// Draws to the position [100, 50]
point(width/2, height/4);
// It is also possible to specify a point with any parameter,
// but only coordinates on the screen are visible
point(60, 30);
point(60, 134);
point(160, 50);
point(280, -800);
point(201, 100);
// The first parameter is the x-coordinate and the second is the Y
stroke(255);
point(width * 0.5, height * 0.5);
point(width * 0.5, height * 0.25);
// Coordinates are used for drawing all shapes, not just points.
// Parameters for different methods are used for different purposes.
// For example, the first two parameters to line() specify the coordinates of the
// first point and the second two parameters specify the second point
stroke(204);
line(0, 73, width, 73);
// Parameters for different functions are used for different purposes.
// For example, the first two parameters to line() specify
// the coordinates of the first point and the second two parameters
// specify the second point
stroke(0, 153, 255);
line(0, height*0.33, width, height*0.33);
// The first two parameters to rect() are coordinates
// and the second two are the width and height
rect(110, 55, 40, 36);
// By defaulty, the first two parameters to rect() are the
// coordinates of the upper-left corner and the second pair
// is the width and height
stroke(255, 153, 0);
rect(width*0.25, height*0.1, width * 0.5, height * 0.8);
@@ -6,8 +6,7 @@
* rings for each target.
*/
void setup()
{
void setup() {
size(640, 360);
background(51);
noStroke();
@@ -15,19 +14,17 @@ void setup()
noLoop();
}
void draw()
{
void draw() {
drawTarget(width*0.25, height*0.4, 200, 4);
drawTarget(width*0.5, height*0.5, 300, 10);
drawTarget(width*0.75, height*0.3, 120, 6);
}
void drawTarget(float xloc, float yloc, int size, int num)
{
void drawTarget(float xloc, float yloc, int size, int num) {
float grayvalues = 255/num;
float steps = size/num;
for(int i=0; i<num; i++) {
for (int i = 0; i < num; i++) {
fill(i*grayvalues);
ellipse(xloc, yloc, size-i*steps, size-i*steps);
ellipse(xloc, yloc, size - i*steps, size - i*steps);
}
}
@@ -1,30 +0,0 @@
/**
* Recursion.
*
* A demonstration of recursion, which means functions call themselves.
* Notice how the drawCircle() function calls itself at the end of its block.
* It continues to do this until the variable "level" is equal to 1.
*/
void setup() {
size(640, 360);
noStroke();
smooth();
drawCircle(width*0.5, height*0.5, 160, 8);
}
void drawCircle(float x, float y, int radius, int level) {
float tt = 126 * level/6.0;
fill(tt, 153);
ellipse(x, y, radius*2, radius*2);
if(level > 1) {
level = level - 1;
int num = int(random(2, 6));
for(int i=0; i<num; i++) {
float a = random(0, TWO_PI);
float nx = x + cos(a) * 6.0 * level;
float ny = y + sin(a) * 6.0 * level;
drawCircle(nx, ny, radius/2, level);
}
}
}
@@ -1,8 +1,8 @@
/**
* Setup and Draw.
*
* The draw() function creates a structure in which
* to write programs that change with time.
* The code inside the draw() function runs continuously
* from top to bottom until the program is stopped.
*/
float y = 100;
@@ -12,8 +12,8 @@ void setup() {
void draw() {
background(127);
noStroke();
for (int i=0; i<height; i+=20) {
fill(0);
for (int i = 0; i < height; i += 20) {
fill(129, 206, 15);
rect(0, i, width, 10);
fill(255);
rect(i, 0, 10, height);