Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- float[] position = new float[4];
- float[] temp = new float[4];
- float[] c = new float[4];
- int i,n;
- color colour;
- float aa,bb,cc,dd,twoab,twoac,twoad;
- float increment = 0.01;
- float xmin,xmax,ymin,ymax;
- float xsize,ysize,incrementx,incrementy;
- void setup(){
- position[3] = 0;
- position[2] = 0;
- size(750,750);
- background(255);
- xmin=-2;
- xmax=2;
- ymin=-2;
- ymax=2;
- xsize=abs(xmin-xmax);
- ysize=abs(ymin-ymax);
- incrementx=xsize/width;
- incrementy=ysize/height;
- textSize(20);
- textAlign(CENTER,CENTER);
- }
- void draw(){
- julia();
- text (c[0] + "\n" + c[1] +"\n" + c[2] + "\n" + c[3],375,75);
- move();
- stroke(255);
- line(0,375,750,375);
- line(375,0,375,750);
- }
- void julia(){
- loadPixels();
- position[1] = ymin;
- for (int j = 0; j < height; j ++) {
- position[0] = xmin;
- for (int i = 0; i < width; i ++) {
- funtion(position);
- if (n <= 10) {
- colour = color(map(n,0,10,0,255),0,0);
- }
- if (10< n && n<= 20){
- colour = color(255,map(n,10,20,0,255),0);
- }
- if (20<n && n<=30){
- colour = color(map(n,20,30,255,0),255,0);
- }
- if (30 < n && n<=40){
- colour = color(0,255,map(n,30,40,0,255));
- }
- if ( 40 < n && n<=50){
- colour = color(0,map(n,40,50,255,0),255);
- }
- if ( 50<n && n<=60){
- colour = color(map(n,50,60,0,255),0,255);
- }
- if ( n>60){
- colour = color(255,map(n,60,100,0,255),255);
- }
- pixels[i+j*width] = colour;
- position[0] += incrementx;
- }
- position[1]+= incrementy;
- }
- updatePixels();
- stroke(255);
- }
- int funtion(float[] a){
- temp[0] = a[0];
- temp[1] = a[1];
- temp[2] = a[2];
- temp[3] = a[3];
- n = 0;
- while (n < 100) {
- aa=temp[0]*temp[0];
- bb=temp[1]*temp[1];
- cc=temp[2]*temp[2];
- dd=temp[3]*temp[3];
- twoab=2*temp[0]*temp[1];
- twoac=2*temp[0]*temp[2];
- twoad=2*temp[0]*temp[3];
- temp[0] = aa - bb - cc - dd + c[0];
- temp[1] = twoab + c[1];
- temp[2] = twoac + c[2];
- temp[3] = twoad + c[3];
- if(aa + bb + cc + dd > 16.0) {
- break;
- }
- n ++;
- }
- return n;
- }
- void move(){
- if (mousePressed==true){
- if (mouseY<50){
- if (mouseX<375){
- c[0]+=map(mouseX,0,375,0.1,0);
- }
- if (mouseX>375){
- c[0]-=map(mouseX,750,375,0.1,0);;
- }
- }
- if (mouseY>700){
- if (mouseX<375){
- c[1]+=map(mouseX,0,375,0.1,0);;
- }
- if (mouseX>375){
- c[1]-=map(mouseX,750,375,0.1,0);;
- }
- }
- if (mouseX<50){
- if (mouseY<375){
- c[2]+=map(mouseY,0,375,0.1,0);;
- }
- if (mouseY>375){
- c[2]-=map(mouseY,750,375,0.1,0);;
- }
- }
- if (mouseX>700){
- if (mouseY<375){
- c[3]+=map(mouseY,0,375,0.1,0);;
- }
- if (mouseY>375){
- c[3]-=map(mouseY,750,375,0.1,0);;
- }
- }
- }
- if(keyPressed==true){
- if( key=='a'){
- position[2]+=0.01;
- }
- if (key=='d'){
- position[2]-=0.01;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement