|
Author |
Topic: 4 new toys (Read 619 times) |
|
mKoser
|
Re: 4 new toys
« Reply #2 on: Sep 19th, 2003, 1:20am » |
|
indeed, very nice work Regarding the TRIPLETS! i just spent a few minutes playing with your code... my initial idea was to change the color of the stroke (yellow would be nice!) but for some reason the blur() method only blurs in grey-tones?... would you care to explain why this is? (or would it be possible with a minor hack to make it blur RGB colors?) GREAT! Mikkel
|
« Last Edit: Sep 19th, 2003, 1:21am by mKoser » |
|
mikkel crone koser | www.beyondthree.com | http://processing.beyondthree.com
|
|
|
seb
|
Re: 4 new toys
« Reply #3 on: Sep 19th, 2003, 3:39am » |
|
Yes the blur code only reads the blue value of the pixels, computes the new intensity, and repacks the same value on R,G and B. It saves a few calculations. You can modify the blur() routine as follow (it will be noticably slower): Code: void blur() { int index,R,G,B,left,right,top,bottom; for(int j=0;j<WIDTH;j++) { for(int i=0;i<HEIGHT;i++) { index=i*WIDTH+j; // Wraparound offsets if(j>0) left=-1; else left=WIDTH-1; if(j==(WIDTH-1)) right=-WIDTH+1; else right=1; if(i>0) top=-WIDTH; else top=(HEIGHT-1)*WIDTH; if(i==(HEIGHT-1)) bottom=-(HEIGHT-1)*WIDTH; else bottom=WIDTH; // Calculate the sum of n neighbors R=(pixels[left+index]>>16) & 255; // left middle R+=(pixels[right+index]>>16) & 255; // right middle R+=(pixels[index]>>16) & 255; // middle middle R+=(pixels[index+top]>>16) & 255; // middle top R+=(pixels[index+bottom]>>16) & 255; // middle bottom R=(R/5); G=(pixels[left+index]>>8) & 255; // left middle G+=(pixels[right+index]>>8) & 255; // right middle G+=(pixels[index]>>8) & 255; // middle middle G+=(pixels[index+top]>>8) & 255; // middle top G+=(pixels[index+bottom]>>8) & 255; // middle bottom G=(G/5); B=pixels[left+index] & 255; // left middle B+=pixels[right+index] & 255; // right middle B+=(pixels[index] & 255); // middle middle B+=pixels[index+top] & 255; // middle top B+=pixels[index+bottom] & 255; // middle bottom B=(B/5); pixels[index]=(R<<16)+(G<<8)+B; } } } |
|
|
« Last Edit: Sep 19th, 2003, 3:44am by seb » |
|
|
|
|
elout
|
Re: 4 new toys
« Reply #4 on: Sep 19th, 2003, 3:20pm » |
|
nice work seb. btw. how did you find out about the lightning/lamps?
|
|
|
|
elout
|
Re: 4 new toys
« Reply #6 on: Sep 19th, 2003, 5:55pm » |
|
thx seb, I started to play with a little lightning today, although you have to click in the screen first to get different coloured lights floating around; http://www.xs4all.nl/~elout/proce55ing/loise/
|
|
|
|
|