Processing2
/*--Width and Height--*/
size(200,200);<br>
background(127);<br>
noStroke();<br>
for(int i=0; i<height; i+=20) <br>
/*--Setup and Draw--*/
void setup() <br]>
{
float y = 100;<br>
void draw() <br>
{ <br>
/*--No Loop--*/<br>
void setup() <br>
{<br>
float y = 100;<br>
void draw()<br>
{ <br>
/*--Loop--*/<br>
{<br>
float y = 100;<br>
void draw() <br>
{ <br>
void mousePressed() <br>
{
/*--Redraw--*/<br>
void setup() <br>
{
float y = 100;<br>
void draw() <br>
{
void mousePressed()<br>
{
/*--Functions--*/<br>
void setup() <br>
{
void draw()<br>
{
void draw_target(int xloc, int yloc, int size, int num)<br>
{
/*--Recursion--*/<br>
void setup() <br>
{
void draw() <br>
{
void drawCircle(int x, int radius, int level)<br>
{
/*--Recursion2--*/<br>
{
void drawCircle(float x, float y, int radius, int level) <br>
{
/*--Objects--*/<br>
MRect r1, r2, r3, r4;<br>
{
{
{
/*--PointsLines--*/<br>
int d = 40;<br>
int p1 = d;<br>
int p2 = p1+d;<br>
int p3 = p2+d;<br>
int p4 = p3+d;<br>
size(200, 200);<br>
background(0);<br>
stroke(153);<br>
line(p3, p3, p2, p3);<br>
line(p2, p3, p2, p2);<br>
line(p2, p2, p3, p2);<br>
line(p3, p2, p3, p3);<br>
stroke(255);<br>
point(p1, p1);<br>
point(p1, p3);<br>
point(p2, p4);<br>
point(p3, p1);<br>
point(p4, p2);<br>
point(p4, p4);<br>
size(200,200);<br>
background(127);<br>
noStroke();<br>
for(int i=0; i<height; i+=20) <br>
fill(0);<br> rect(0,i,width,10);<br> fill(255);<br> rect(i,0,10,height);<br>}<br>
/*--Setup and Draw--*/
void setup() <br]>
{
size(200, 200); // Size should be the first statement<br> stroke(255); // Set line drawing color to white<br> frameRate(30);<br>}<br>
float y = 100;<br>
void draw() <br>
{ <br>
background(0); // Set the background to black<br> y = y - 1;<br> if (y < 0) { y = height; }<br> line(0, y, width, y);<br>} <br>
/*--No Loop--*/<br>
void setup() <br>
{<br>
size(200, 200); // Size should be the first statement<br> stroke(255); // Set line drawing color to white<br> frameRate(30);<br> noLoop();<br>}<br>
float y = 100;<br>
void draw()<br>
{ <br>
background(0); // Set the background to black<br> y = y - 1; <br> if (y < 0) { y = height; }<br> line(0, y, width, y); <br>}<br>
/*--Loop--*/<br>
// The statements in the setup() function<br>void setup()<br>
{<br>
size(200, 200); // Size should be the first statement<br> stroke(255); // Set line drawing color to white<br> frameRate(30);<br> noLoop();<br>}<br>
float y = 100;<br>
void draw() <br>
{ <br>
background(0); // Set the background to black<br> y = y - 1; <br> if (y < 0) { y = height; }<br> line(0, y, width, y); <br>} <br>
void mousePressed() <br>
{
loop();<br>}
/*--Redraw--*/<br>
void setup() <br>
{
size(200, 200); // Size should be the first statement<br> stroke(255); // Set line drawing color to white<br> noLoop();<br>}<br>
float y = 100;<br>
void draw() <br>
{
background(0); // Set the background to black<br> y = y - 1; <br> if (y < 0) { y = height; }<br> line(0, y, width, y);<br>} <br>
void mousePressed()<br>
{
redraw();<br>}
/*--Functions--*/<br>
void setup() <br>
{
size(200, 200);<br> background(51);<br> noStroke();<br> smooth();<br> noLoop();<br>}
void draw()<br>
{
draw_target(68, 34, 200, 10);<br> draw_target(152, 16, 100, 3);<br> draw_target(100, 144, 80, 5);<br>}
void draw_target(int xloc, int yloc, int size, int num)<br>
{
float grayvalues = 255/num;<br> float steps = size/num;<br> for(int i=0; i<num; i++) {<br> fill(i*grayvalues);<br> ellipse(xloc, yloc, size-i*steps, size-i*steps);<br> }<br>}<br>
/*--Recursion--*/<br>
void setup() <br>
{
size(200, 200);<br> noStroke();<br> smooth();<br> noLoop();<br>}
void draw() <br>
{
drawCircle(126, 170, 6);<br>}
void drawCircle(int x, int radius, int level)<br>
{
float tt = 126 * level/4.0;<br> fill(tt);<br> ellipse(x, 100, radius*2, radius*2);<br> if(level > 1) {<br> level = level - 1;<br> drawCircle(x - radius/2, radius/2, level);<br> drawCircle(x + radius/2, radius/2, level);<br> }<br>}<br>
/*--Recursion2--*/<br>
void setup() <br>
{
size(200, 200);<br> noStroke();<br> smooth();<br> drawCircle(100, 100, 80, 8);<br>}
void drawCircle(float x, float y, int radius, int level) <br>
{
float tt = 126 * level/6.0;<br> fill(tt, 153);<br> ellipse(x, y, radius*2, radius*2);<br> if(level > 1) {<br> level = level - 1;<br> int num = int(random(2, 6));<br> for(int i=0; i<num; i++) {<br> float a = random(0, TWO_PI);<br> float nx = x + cos(a) * 6.0 * level;<br> float ny = y + sin(a) * 6.0 * level;<br> drawCircle(nx, ny, radius/2, level);<br> }<br> }<br>}<br>
/*--Objects--*/<br>
MRect r1, r2, r3, r4;<br>
void setup()<br>
{
size(200, 200);<br> fill(255);<br> noStroke();<br> r1 = new MRect(1, 134.0, 0.532, 0.083*height, 10.0, 60.0);<br> r2 = new MRect(2, 44.0, 0.166, 0.332*height, 5.0, 50.0);<br> r3 = new MRect(2, 58.0, 0.332, 0.4482*height, 10.0, 35.0);<br> r4 = new MRect(1, 120.0, 0.0498, 0.913*height, 15.0, 60.0);<br>}
void draw()<br>
{
background(0);<br> r1.display();<br> r2.display();<br> r3.display();<br> r4.display();<br> r1.moveToX(mouseX-(width/2), 30);<br> r2.moveToX((mouseX+(width*0.05))%width, 20);<br> r3.moveToX(mouseX/4, 40);<br> r4.moveToX(mouseX-(width/2), 50);<br> r1.moveToY(mouseY+(height*0.1), 30);<br> r2.moveToY(mouseY+(height*0.025), 20);<br> r3.moveToY(mouseY-(height*0.025), 40);<br> r4.moveToY((height-mouseY), 50);<br>}
class MRect<br>
{
int w; // single bar width<br> float xpos; // rect xposition<br> float h; // rect height<br> float ypos ; // rect yposition<br> float d; // single bar distance<br> float t; // number of bars<br> MRect(int iw, float ixp, float ih, float iyp, float id, float it) {<br> w = iw;<br> xpos = ixp;<br> h = ih;<br> ypos = iyp;<br> d = id;<br> t = it;M<br> } void moveToY (float posY, float damping) {<br> float dif = ypos - posY;<br> if (abs(dif) > 1) {<br> ypos -= dif/damping;<br> }<br> }<br> void moveToX (float posX, float damping) {<br> float dif = xpos - posX;<br> if (abs(dif) > 1) {<br> xpos -= dif/damping;<br> }<br> }<br> void display() {<br> for (int i=0; i<t; i++) {<br> rect(xpos+(i*(d+w)), ypos, w, height*h);<br> }<br> }<br>}<br>
/*--PointsLines--*/<br>
int d = 40;<br>
int p1 = d;<br>
int p2 = p1+d;<br>
int p3 = p2+d;<br>
int p4 = p3+d;<br>
size(200, 200);<br>
background(0);<br>
stroke(153);<br>
line(p3, p3, p2, p3);<br>
line(p2, p3, p2, p2);<br>
line(p2, p2, p3, p2);<br>
line(p3, p2, p3, p3);<br>
stroke(255);<br>
point(p1, p1);<br>
point(p1, p3);<br>
point(p2, p4);<br>
point(p3, p1);<br>
point(p4, p2);<br>
point(p4, p4);<br>
2006年11月15日(水) 20:25:25 Modified by notarejini06