Skip to content

Instantly share code, notes, and snippets.

@qingfeng
Created July 30, 2008 05:12
Show Gist options
  • Save qingfeng/3230 to your computer and use it in GitHub Desktop.
Save qingfeng/3230 to your computer and use it in GitHub Desktop.
My Processing code
float randShift=.2;
int quadW=15;
int quadH = quadW;
float[] q={-quadW/2,-quadH/2,quadW,quadH};
void setup() {
size(900,600);
background(255);
smooth();
noStroke();
colorMode(RGB, 255);
/*generateatablestructureof
quadsprogressivleyaddingmore
randomizationto eachquad*/
for(int i=0,k=1;i<height-quadH; i+=quadH, k++){
/* resetting the transformation matrix
keeps the translations from continually
accumulating. Try commenting out the
resetMatrix() call to see the effect. */
resetMatrix();
translate(0,quadH*k);
for (int j=0; j<width-quadW; j+=quadW){
translate(quadW, 0);
println(quadW);
fill(random(0,255),random(0,255),random(0,255));
//r(k)isafunctioncall
quad(q[0]+r(k), q[1]+r(k),
q[0]+q[2]+r(k), q[1]+r(k),
q[0]+q[2]+r(k),q[1]+q[3]+r(k),
q[0]+r(k), q[1]+q[3]+r(k));
}
}
}
float r(int i){
return random(-i*randShift, i*randShift);
}
//http://f.hatena.ne.jp/yanxu/20081104190832
void setup(){
size(700,500);
background(0);
//strokeWeight(.1);
int cols=20;
int rows=20;
for(int i=0;i<cols;i++){
for(int j=0;j<rows;j++){
int x=i*30+30;
int y=j*20+30;
drawRect(x,y);
}
}
}
void drawRect(int x,int y){
stroke(random(100,255),random(100,255),random(100,255));
strokeWeight(random(.1,3));
int w=20;
int h=10;
/*
line(x,y,x+w,y);
line(x+w,y,x+w,y+h);
line(x,y+h,x+w,y+h);
line(x,y+h,x,y);
*/
line(x+random(-4,4),y+random(-4,4),x+w+random(-4,4),y+random(-4,4));
line(x+w+random(-4,4),y+random(-4,4),x+w+random(-4,4),y+h+random(-4,4));
line(x+random(-4,4),y+h+random(-4,4),x+w+random(-4,4),y+h+random(-4,4));
line(x+random(-4,4),y+h+random(-4,4),x+random(-4,4),y+random(-4,4));
}
void setup() {
int w = 20;
int h = 20;
int skip = w+10;
int cols = 30;
int rows = 20;
size(skip*cols,skip*rows);
background(255);
colorMode(RGB,255);
smooth();
for(int i=1;i<cols;i++){
for(int j=1;j<rows;j++){
color c = color(random(0,255),random(0,255),random(0,255));
fill(c);
rect(i*skip,j*skip,w,h);
}
}
}
void setup() {
size(570,160);
background(255);
PImage model = loadImage("/Users/yanxu/Desktop/rousi.jpg");//190*239
image(model,-30,-45,180,220);
filter(BLUR,4);
/* for(int i=0;i<model.width-40;i+=5){
for(int j=0;j<model.height-65;j+=5){
color c= model.get(i,j);
fill(c);
rect(i+155,j,5,5);
}
}
*/
PImage ad1 = loadImage("/Users/yanxu/Desktop/ad1.jpg");//320*240
image(ad1,width-300,-30);
PImage ad_text = loadImage("/Users/yanxu/Desktop/ad_text.png");//113*110
image(ad_text,160,20,100,110);
save("/Users/yanxu/Desktop/wuxia_ad.tif");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment