mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
Two examples corrections
This commit is contained in:
@@ -9,13 +9,13 @@
|
||||
* [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
|
||||
// Sets the screen to be 640 pixels wide and 360 pixels high
|
||||
size(640, 360);
|
||||
|
||||
// Set the background to black and turn off the fill color
|
||||
background(0);
|
||||
noFill();
|
||||
|
||||
|
||||
// The two parameters of the point() method each specify coordinates.
|
||||
// The first parameter is the x-coordinate and the second is the Y
|
||||
stroke(255);
|
||||
@@ -25,12 +25,12 @@ point(width * 0.5, height * 0.25);
|
||||
// Coordinates are used for drawing all shapes, not just points.
|
||||
// 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
|
||||
// the coordinates of the first endpoint and the second two parameters
|
||||
// specify the second endpoint
|
||||
stroke(0, 153, 255);
|
||||
line(0, height*0.33, width, height*0.33);
|
||||
|
||||
// By defaulty, the first two parameters to rect() are the
|
||||
// By default, 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);
|
||||
|
||||
@@ -6,37 +6,32 @@
|
||||
* and pop() restores the prior coordinate system.
|
||||
*/
|
||||
|
||||
float a; // Angle of rotation
|
||||
float offset = PI/24.0; // Angle offset between boxes
|
||||
int num = 12; // Number of boxes
|
||||
color[] colors = new color[num]; // Colors of each box
|
||||
color safecolor;
|
||||
float a; // Angle of rotation
|
||||
float offset = PI/24.0; // Angle offset between boxes
|
||||
int num = 12; // Number of boxes
|
||||
|
||||
boolean pink = true;
|
||||
|
||||
void setup()
|
||||
{
|
||||
void setup() {
|
||||
size(640, 360, P3D);
|
||||
noStroke();
|
||||
for(int i=0; i<num; i++) {
|
||||
colors[i] = color(255 * (i+1)/num);
|
||||
}
|
||||
lights();
|
||||
}
|
||||
|
||||
|
||||
void draw()
|
||||
{
|
||||
void draw() {
|
||||
|
||||
lights();
|
||||
|
||||
background(0, 0, 26);
|
||||
translate(width/2, height/2);
|
||||
a += 0.01;
|
||||
translate(width/2, height/2);
|
||||
|
||||
for(int i = 0; i < num; i++) {
|
||||
float gray = map(i, 0, num-1, 0, 255);
|
||||
pushMatrix();
|
||||
fill(colors[i]);
|
||||
fill(gray);
|
||||
rotateY(a + offset*i);
|
||||
rotateX(a/2 + offset*i);
|
||||
box(200);
|
||||
popMatrix();
|
||||
}
|
||||
|
||||
a += 0.01;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user