Bonjour tout le monde,
J'aurais besoin d'aide pour faire un zoom par exemple un zoom de selection rectangulaire qui agrandit la zone voulue sur un programme que j'ai fais qui génére une fractale de Mandelbrot. Je ne sais vraiment pas du tout comment m'y prendre. J'aimerais savoir si quelqu'un peut me donner un coup de main ou des conseils pour faire ce genre d'artifice.
Merci d'avance.
Mon code source:
import java.awt.*;
import java.awt.event.*;
public class FractaleZoom {
static int maxSize = 600; // largeur fenetre en pixel
static int size = 100;
// globals:
static int squareWidth = maxSize / size;
static Graphics g;
static int frameTop, frameLeft;
public static void main(String[] args) {
int winx=600;
int winy=600;
double xbegin = -1.8;
double xend=1.1;
double ybegin = -1.2;
double yend=1.2;
// initialise fenetre et graphics:
Frame gWin = new Frame("Fractale Mandelbrot");
gWin.setLocation(50,50); // position fenetre gWin.setResizable(false);
gWin.setVisible(true); // affiche!
Insets theInsets = gWin.getInsets();
gWin.setSize(maxSize+theInsets.left+theInsets.right,maxSize+theInsets.top+theInsets.bottom);
frameTop = theInsets.top;
frameLeft = theInsets.left;
long resumeTime = System.currentTimeMillis() + 1000;
do {} while (System.currentTimeMillis() < resumeTime); // attente pour initialisation fenetre
g = gWin.getGraphics(); // met les objets graphiques
for(float i=0;i<winx;i+=0.999){
for(float j=0;j<winy;j+=0.999){
// define z_0
double zIm = j*(yend-ybegin)/(winy*1.0)+ybegin;
double zRe = i*(xend-xbegin)/(winx*1.0)+xbegin;
double cIm = zIm;
double cRe = zRe;
// res est le compteur d'iterations
double temp;
int res = 0;
// on prend 255 iterations comme max
while(res<255 && (zIm*zIm + zRe*zRe)<=4.0 ){
// z^2= (a+bj)*(a+bj)= a^2 - b^2 + j*(2*a*b)
// temp = zRe*zRe - zIm *zIm + i*(xend-xbegin)/(winx*1.0)+xbegin;
// zIm = 2*zRe * zIm + j*(yend-ybegin)/(winy*1.0)+ybegin;
temp = zRe*zRe - zIm *zIm + cRe;
zIm = 2*zRe * zIm + cIm;
zRe = temp;
res++;
}
g.setColor(new Color(0,0,(float)((res*1.0)/255.0)));
g.drawLine((int)(i), (int)(j),(int)(i),(int)(j));
}
}
}
}
Jarod_Delaware