kram1032
YaBB Newbies
Offline
Posts: 7
Re: Buddhabrot 2.0
Reply #2 - Jul 8th , 2009, 3:48pm
// MAIN ---------------------------------------------------------------- int sgn(float value) { //if signus is needed sgn(x)=x/abs(x) = 1, 0 or -1 if (value < 0) {return -1;} if (value > 0) {return 1;} return 0; } float cosh(float value1) { return 0.5*(exp(value1)+exp(-value1)); } float sinh(float value2) { return 0.5*(exp(value2)-exp(-value2)); } float arg(float axis1, float axis2) { if (axis2==0) {return PI;} else {return -atan(axis1/axis2)+PI*sgn(axis2)*0.5;} } float spharg(float axisa, float axisb, float axisc) { return acos(axisc/sqrt(sq(axisa)+sq(axisb)+sq(axisc))); } void setup() { // set up drawing area size(dimy,dimx,P3D); } void draw() { plotPlots(); time++; if (time%1==0) { //every second findMaxExposure(); renderBrot(); } } void plotPlots() { // iterate through some plots for (int n=0;n<plots;n++) { // Choose a random point in same range x = random(-2.0,1.0); y = random(-1.5,1.5); x0 = random(-2.0,2.0); y0 = random(-2.0,2.0); if (iterate(x,y,false)) { iterate(x,y,true); exposures++; } } } void renderBrot() { colorMode(RGB,1.0); // draw to screen for (int i=0;i<dimx;i++) { for (int j=0;j<dimy;j++) { float ramp = brt * exposure[i*dimy+j] / maxexposure; // blow out ultra bright regions if (ramp > 1) { ramp = 1; } //different shading formulae //color c = color(pow(ramp,0.45454545454545454545),pow(ramp,0.45454545454545454545),pow(ramp ,0.45454545454545454545)); //default greyscale color c = color(pow(ramp,0.413223140495867768595041322314049586776859504132231404958677685 950413223140495867769),pow(ramp,0.45454545454545454545),pow(ramp,0.3787878787878 78787878787878787878787878787878787878787878787878787878787878787878788)); //purple touch //color c = color(pow(sin(ramp*1.57079632679489661923132169163975144209858469968755291048747 2296153908203143104499314),0.4),pow(ramp,0.75),pow(ramp,2.5)); // sunset //color c = color(pow(sin(ramp*1.57079632679489661923132169163975144209858469968755291048747 2296153908203143104499314),0.45454545455),pow(ramp,17/11.0),pow(ramp,109/55.0)); // "love" set(j,i,c); } } }