Loading...
Processing Forum
Recent Topics
All Forums
Screen name:
ww1way
About Me:
about.me/ww1way
Blog:
http://www.ccttours.com/blog
Website:
http://about.me/ww1way
Twitter Link:
http://twitter.com/ww1way
Facebook Link:
http://www.facebook.com/ww1way
Linkedin Link:
http://www.linkedin.com/profile/view?id=112224112
ww1way's Profile
3
Posts
10
Responses
0
Followers
Activity Trend
Last 30 days
Last 30 days
Date Interval
From Date :
To Date :
Go
Loading Chart...
Posts
Responses
PM
Show:
All
Discussions
Questions
Expanded view
List view
Private Message
One interesting bug found...
[2 Replies]
08-Nov-2011 01:34 AM
Forum:
Programming Questions
In the code below (just a copy of Windows' Starfield screensaver)
int num = 4500;
Star stars[] = new Star[num];
void setup() {
size(800, 600, P3D);
smooth();
for (int i=0; i< num; i++) {
stars[i] = new Star();
}
frameRate(25);
}
void draw() {
background(0);
for (int i=0; i< num; i++) {
stars[i].display();
}
}
class Star {
float x = random(width);
float y = random(height);
float z = random(600);
int a = 0;
void display() {
pushMatrix();
translate(0, 0, z-100);
stroke(0);
box(0);
stroke(255, a);
line(x, y, z, x, y, z+45);
popMatrix();
z+=random(10.0, 25.0);
//change alpha with z position
a+=z/20;
if (z>600) {
z=0;
a=0;
x = random(width);
y = random(height);
}
}
}
if you comment out
box(0);
(theoretically, it's useless) in the code, the effect will go wrong...
can anyone make the code shorter?
[2 Replies]
23-Jun-2011 08:39 AM
Forum:
Programming Questions
just a newbie practice of translation and rotation with bad expandability...
i believe there're better ways...
void setup() {
size(400, 400);
}
void draw() {
rect2();
translate(200, 0);
rect2();
translate(0, 200);
rect2();
translate(-200, 0);
rect2();
}
void rect1() {
// make two rects
rect(0, 0, 100, 100);
line(0, 50, 100, 50);
line(50, 0, 50, 100);
rect(25, 25, 50, 50);
rect(100, 0, 100, 100);
for (int b=100; b<167;b+=33) {
line(b, 0, b, 100);
}
}
void rect2() {
// make 2 pairs of rects
pushMatrix();
rect1();
translate(200, 200);
rotate(PI);
rect1();
popMatrix();
}
how to use for() to do this?
[14 Replies]
22-Jun-2011 07:24 AM
Forum:
Programming Questions
also I wonder if it's possible or not.
as you saw, I wrote the rect one by one, I know it's stupid, and it does have some clear patterns, but every time I try to put it into a for(), the image go weired...
help...
«Prev
Next »
Moderate user : ww1way
Forum