bethadillon
YaBB Newbies
Offline
Posts: 15
Drawing (in a way)
Oct 14th , 2006, 9:09pm
Okay so now that this is all changed around and I'm trying to get the shape of the drawn brush (sort of like a paint brush) to be a medicine wheel (ellipse with four arcs of different hues--red, black, yellow, white), it's now broken. It runs but doesn't do anything when the mouse presses down. I'm sure I accidentally deleted something or I need to change the hue values but not sure how... int scn[]; void setup() { size(600, 600); background(#ffffff); scn = new int[width*height]; preserveScreen(); } void draw() { restoreScreen(); } void mouseDragged() { alphaFrame(mouseX, mouseY); } void keyReleased() { fill(#ffffff); noStroke(); ellipse(0, 0, width, height); preserveScreen(); } void preserveScreen() { loadPixels(); for (int i = 0; i < width*height; i++) { scn[i] = pixels[i]; } } void restoreScreen() { for (int i = 0; i < width*height; i++) { pixels[i] = scn[i]; } updatePixels(); } void alphaFrame(float xin, float yin) { int x = int(xin); int y = int(yin); int s = 200; s/=2; // the radius of the circle int radius = 50; for(int i=x-radius; i<x+radius; i++) { for(int j=y-radius; j<y+radius; j++) { // check if the pixel (i,j) is in the circle if (dist(i, j, x, y) < radius) { int rgb = scn[j*width + i]; int r = (rgb >> 16) & 0xff; int g = (rgb >> 8) & 0xff; int b = rgb & 0xff; // first quadrant (12-3 oclock) if (x < i && j < y){ if (r > 1) r--; if (g > 1) g--; // second quadrant (3-6 oclock) } else if(x < i && j > y){ if (r < 255) r++; if (g < 255) g++; // third quadrant (6-9 oclock) } else if(x > i && j < y){ if (g < 255) g--; // fourth quadrant (9-12 oclock) } else{ if (g < 255) g++; scn[j*width + i] = 0xff000000 | (r << 16) | (g << 8) | (b); } } } } }