FRAKTALY

ID
Nazov / Name:
Popis / Description:
Dlzka / Length:
Testovane pod / Tested under:

 

162
p162.html / p162.zip
Vykreslovanie fraktalov (mandelbrot).
4130b
NN 4.04, IE 4.0

UKAZKA / CLICK HERE

Zdrojovy tvar / Source code:

<HTML> <HEAD> <TITLE>JavaScript DESTINATION - P162</TITLE> <SCRIPT LANGUAGE="JavaScript"> <!-- function zoom(mode) { var x1 = parseFloat(document.forms[0].x_min.value); var y1 = parseFloat(document.forms[0].y_min.value); var x2 = parseFloat(document.forms[0].x_max.value); var y2 = parseFloat(document.forms[0].y_max.value); if (mode==0) { document.forms[0].x_min.value = -2.0; document.forms[0].y_min.value = -2.0; document.forms[0].x_max.value = -2.0; document.forms[0].y_max.value = -2.0; } else if (mode==1) { document.forms[0].x_max.value = (x1+x2)/2; document.forms[0].y_min.value = (y1+y2)/2; } else if (mode==2) { document.forms[0].x_min.value = (x1+x2)/2; document.forms[0].y_min.value = (y1+y2)/2; } else if (mode==3) { document.forms[0].x_min.value = x1+(x2-x1)/4; document.forms[0].y_min.value = y1+(y2-y1)/4; document.forms[0].x_max.value = x1+3*(x2-x1)/4; document.forms[0].y_max.value = y1+3*(y2-y1)/4; } else if (mode==4) { document.forms[0].x_max.value = (x1+x2)/2; document.forms[0].y_max.value = (y1+y2)/2; } else if (mode==5) { document.forms[0].x_min.value = (x1+x2)/2; document.forms[0].y_max.value = (y1+y2)/2; } history.go(0); } // --> </SCRIPT> </HEAD> <BODY BGCOLOR="#FFFFFF"> <SCRIPT language="JavaScript"> <!-- document.clear(); // --> </SCRIPT> <FORM> X_min:<INPUT type="text" name="x_min" value="-2.0"> X_max:<INPUT type="text" name="x_max" value="1.25"><BR> Y_min:<INPUT type="text" name="y_min" value="-1.5"> Y_max:<INPUT type="text" name="y_max" value="1.5"><BR> (stlacte 'reload' potom, ako zmenite hodnoty)<BR> <BR> Zvacsenie:<BR> <INPUT type="button" name = "zoom0" value="Default hodnoty" onClick="zoom(0)"> <INPUT type="button" name = "zoom1" value="Horny lavy" onClick="zoom(1)"> <INPUT type="button" name = "zoom2" value="Horny pravy" onClick="zoom(2)"> <INPUT type="button" name = "zoom3" value="Stred" onClick="zoom(3)"> <INPUT type="button" name = "zoom4" value="Dolny lavy" onClick="zoom(4)"> <INPUT type="button" name = "zoom5" value="Dolny pravy" onClick="zoom(5)"> <HR>Prosim pockaj, kym prepocitam udaje...<BR> </FORM> <SCRIPT language="JavaScript"> <!-- if ((document.forms[0].x_min.value!="") && (document.forms[0].y_min.value!="") && (document.forms[0].x_max.value!="") && (document.forms[0].y_max.value!="")) { var xmin=parseFloat(document.forms[0].x_min.value); var ymin=parseFloat(document.forms[0].y_min.value); var xmax=parseFloat(document.forms[0].x_max.value); var ymax=parseFloat(document.forms[0].y_max.value); var ant_x=40; var ant_y=32; var dx=(xmax-xmin)/ant_x; var dy=(ymax-ymin)/ant_y; var iter=0; var px=0.0; var py=0.0; var a=0.0; var b=0.0; var old_a=0.0; var y=0; for (var y=0; y<ant_y; y++) { for (var x=0; x<ant_x; x++) { iter=0; px=xmin+dx*x; py=ymax-dy*y; a=px; b=py; while (a*a+b*b<4.0 && iter<64) { old_a=a; a=a*a-b*b+px; b=2*old_a*b+py; iter++; } document.write("<img src=images/mndl"+iter%8+".gif>"); } document.writeln("<br>"); } } else { document.writeln("Prosim vlozte hodnoty!<br>"); } document.close(); // --> </SCRIPT> </BODY> </HTML>
[ Navrat / BACK ]