 |
Author |
Topic: Background color of Sketch/Present (Read 1481 times) |
|
JohnByrne
|
Background color of Sketch/Present
« on: Jul 2nd, 2003, 2:43am » |
|
The background color for Sketch/Present has been fixed to a shade of gray that on my reckoning is (102,102,102) on the RGB scale. In the attached program (SinuousRills_1.pde)I wanted to use the background color to overwrite the image outside a circle and to use it also for the 'sinuous rills' in the image itself. So far so good. My question is: Would it be feasible to have a programmable statement in Proce55ing to enable the user to set the background color for Sketch/Present? John. // 'SinuousRills_1' by John Byrne (j.byrne@mackillop.acu.edu.au), 2003. void setup() { size(440,440); } void loop() { // Red background, brightest at the centre of the picture. for(int i=0; i<(width); i++) { for(int j=0; j<(height); j++) { color r = color(200-0.5*sqrt(sq(i-width/2)+ sq(j-height/2)), 0, 0); setPixel(i, j, r); } } // Truchet/Smith pattern on an (11x11) pixel tile. Each tile is oriented 0 or 90 deg. by random allocation. for (int i=0; i<(width); i=i+11) { for(int j=0; j<(height); j=j+11) { color gy = color(102,102,102); float r=random(4); if (r <= 2) { // tile pattern setPixel(i+5,j,gy); setPixel(i+5,j+1,gy); setPixel(i+5,j+2,gy); setPixel(i+6,j+3,gy); setPixel(i+7,j+4,gy); setPixel(i+8,j+5,gy); setPixel(i+9,j+5,gy); setPixel(i+10,j+5,gy); setPixel(i,j+5,gy); setPixel(i+1,j+5,gy); setPixel(i+2,j+5,gy); setPixel(i+3,j+6,gy); setPixel(i+4,j+7,gy); setPixel(i+5,j+8,gy); setPixel(i+5,j+9,gy); setPixel(i+5,j+10,gy); } else { // tile pattern rotated 90 deg. setPixel(i+5,j,gy); setPixel(i+5,j+1,gy); setPixel(i+5,j+2,gy); setPixel(i+4,j+3,gy); setPixel(i+3,j+4,gy); setPixel(i+2,j+5,gy); setPixel(i+1,j+5,gy); setPixel(i,j+5,gy); setPixel(i+10,j+5,gy); setPixel(i+9,j+5,gy); setPixel(i+8,j+5,gy); setPixel(i+7,j+6,gy); setPixel(i+6,j+7,gy); setPixel(i+5,j+8,gy); setPixel(i+5,j+9,gy); setPixel(i+5,j+10,gy); } } } // Set gray pixels beyond a radius of half the picture to match the background gray of P5's Sketch/Present for(int i=0; i<(width); i++) { for(int j=0; j<(height); j++) { color gy=color(102,102,102); if (sqrt(sq(i-width/2)+ sq(j-height/2)) > width/2) { setPixel(i,j,gy); } } } // Refresh the picture periodically. delay(5000); }
|
« Last Edit: Jul 2nd, 2003, 2:45am by JohnByrne » |
|
|
|
|
|