Accueil > > > ENSEMBLES MANDELBROT-JULIA
ENSEMBLES MANDELBROT-JULIA
Information sur la source
Description
Bon dans la serie snippets totalement inutiles je voudrais celui-là ;-) Donc comme c'est ecrit dans le titre, ce snippet permet de tracer l'ensemble de mandelbrot (et celui de julia qui en resulte) Vous devez commencer a avoir l'habitude, les calculs sont longs a s'effectuer , et plus vous choisirez une taille de fenetre importante ou un nombre d'iterations elevé , plus ce sera longs (plusieurs minutes) En double-cliquant sur un point de mandel, le calcul de l'ensemble de julia va s'effectuer avec les meme propriétés que celles utilisées pour dessiner l'ensemble de mandel Vous pouvez faire un zoom (bon ça n'est pas tout a fait au point) : pour cela faites un rectangle de selection et appuyez sur entrée J'ai prevu de faire ce code sur d'autres language, mais j'ai voulu commencer a le faire avec mirc, pour le fun avis au amateurs, ça peut toujours servir ;o)
Source
- dialog mj {
- title "Mandel & Julia"
- size -1 -1 101 127
- option dbu
- box "Taille fenetre", 1, 5 2 88 39
- text "Largeur :", 2, 13 13 31 8
- edit "300", 3, 49 11 39 11,center
- text "Hauteur :", 4, 13 28 31 8
- edit "200", 5, 49 26 39 11,center
- text "Nombre d'iterations :", 6, 11 92 52 8
- edit "10", 7, 68 90 20 11,center
- button "Lancer !", 8, 33 110 37 13
- box "Options", 9, 6 45 88 61
- text "Couleurs :", 10, 11 57 25 8
- check "", 13, 11 72 9 10
- text "Rafraichir la fenetre en temps réel", 14, 23 71 58 15
- combo 11, 42 55 46 33, size drop
- }
-
- on *:dialog:mj:*:*:{
- if ($devent == init) { didtok mj 11 44 Dégradé gris ,Jaune-Rouge }
- elseif ($devent == sclick && $did == 8) {
- set %ma_width $did(3) | set %ma_height $did(5) | set %ma_iter $did(7) | set %ma_n $iif($did(13).state,-r,-nr)
- set %ma_color $iif(gris isin $did(11),$($rgb(%c,%c,%c),0),$($rgb(255,$calc(255 - %c),0),0))
- set %ma_xmax 2 | set %ma_xmin -2 | set %ma_ymax 1.5 | set %ma_ymin -1.5
- mandel
- }
- elseif ($devent == close) { if (window(@mandel)) close -@ @man* | if ($window(@julia)) close -@ @jul* | if ($hget(color)) hfree $v1 | unset %ma_* }
- }
-
- alias -l mandel {
- window -pd +L @mandel -1 -1 %ma_width $calc(%ma_height + 21) | window -o @mandel
- var %i 1 | while (%i <= %ma_iter) { hadd -m color %i $int($calc((%i - 1)*256 /(%ma_iter - 1))) | inc %i }
- var %ticks $ticks | echo -a Calcul en cours...
- var %dx $calc((%ma_xmax - %ma_xmin) / %ma_width) , %dy $calc((%ma_ymax - %ma_ymin) / %ma_height)
- var %y %ma_ymin , %x %ma_xmin
- var %py 0 | while (%py <= %ma_height) {
- ;dll WhileFix.dll WhileFix
- var %px 0 | while (%px <= %ma_width) {
- var %zr 0 , %zi 0 , %i 1
- while ($calc((%zr)^2 + (%zi)^2) < 4 && %i <= %ma_iter) {
- var %temp %zr
- var %zr $calc((%zr)^2 - (%zi)^2 + %x)
- var %zi $calc(2 * %temp * %zi + %y)
- inc %i
- }
- var %c $iif($hget(color,$calc(%i - 1)),$v1,0)
- drawdot %ma_n @mandel $(%ma_color,2) 1 %px %py
- inc %x %dx
- inc %px
- }
- inc %y %dy
- var %x %ma_xmin
- inc %py
- }
- window -ph @man1 | dc @mandel @man1
- echo -a Ensemble de Mandelbrot calculé en $duration($calc(($ticks - %ticks) / 1000)) , double-cliquez sur un point pour calculer l'ensemble de julia à ces coordonnées
- }
-
- alias -l julia {
- window -pd +L @julia -1 -1 %ma_width $calc(%ma_height + 21) | window -o @julia
- var %ticks $ticks | echo -a Calcul en cours...
- var %dx $calc((%ma_xmax - %ma_xmin) / %ma_width) , %dy $calc((%ma_ymax - %ma_ymin) / %ma_height)
- var %y %ma_ymin , %x %ma_xmin
- var %py 0 | while (%py <= %ma_height) {
- ;dll WhileFix.dll WhileFix
- var %px 0 | while (%px <= %ma_width) {
- var %zr %x , %zi %y , %i 1
- while ($calc((%zr)^2 + (%zi)^2) < 4 && %i <= %ma_iter) {
- var %temp %zr
- var %zr $calc((%zr)^2 - (%zi)^2 + %ma_cx)
- var %zi $calc(2 * %temp * %zi + %ma_cy)
- inc %i
- }
- var %c $iif($hget(color,$calc(%i - 1)),$v1,0)
- drawdot %ma_n @julia $(%ma_color,2) 1 %px %py
- inc %x %dx
- inc %px
- }
- inc %y %dy
- var %x %ma_xmin
- inc %py
- }
- window -ph @jul1 | dc @julia @jul1
- echo -a Ensemble de Julia aux coordonnées %ma_cx + i * %ma_cy calculé en $duration($calc(($ticks - %ticks) / 1000))
- }
-
- menu @mandel {
- sclick { set %ma_bool $mouse.x $mouse.y }
- mouse { if (%ma_bool) { dc @man1 @mandel | drawrect -c @mandel 14 1 %ma_bool $calc($mouse.x - $gettok(%ma_bool,1,32)) $calc($mouse.y - $gettok(%ma_bool,2,32)) } }
- drop {
- if (%ma_bool != $mouse.x $mouse.y) {
- tokenize 32 %ma_bool
- if ($1 < $mouse.x && $2 < $mouse.y) { set %ma_xywh $1-2 $mouse.x $mouse.y } | elseif ($mouse.x > $1 && $mouse.y < $2) { set %ma_xywh $1 $mouse.y $mouse.x $2 }
- elseif ($1 > $mouse.x && $2 < $mouse.y) { set %ma_xywh $mouse.x $2 $1 $mouse.y } | else { set %ma_xywh $mouse.x $mouse.y $1-2 }
- }
- unset %ma_bool
- }
- dclick { $cx($mouse.x,$mouse.y) | julia }
- Enregistrer l'image:{ dc @man1 @mandel | sav @mandel }
- }
-
- menu @julia {
- sclick set %ma_bool $mouse.x $mouse.y
- mouse {
- if (%ma_bool) { dc @jul1 @julia | drawrect -c @julia 14 1 %ma_bool $calc($mouse.x - $gettok(%ma_bool,1,32)) $calc($mouse.y - $gettok(%ma_bool,2,32)) } }
- drop {
- if (%ma_bool != $mouse.x $mouse.y) {
- tokenize 32 %ma_bool
- if ($1 < $mouse.x && $2 < $mouse.y) { set %ma_xywh $1-2 $mouse.x $mouse.y } | elseif ($mouse.x > $1 && $mouse.y < $2) { set %ma_xywh $1 $mouse.y $mouse.x $2 }
- elseif ($1 > $mouse.x && $2 < $mouse.y) { set %ma_xywh $mouse.x $2 $1 $mouse.y } | else { set %ma_xywh $mouse.x $mouse.y $1-2 }
- }
- unset %ma_bool
- }
- Enregistrer l'image:{ dc @jul1 @julia | sav @julia }
- }
-
- alias -l s2c {
- var %limx $calc($abs(%ma_xmin) + $abs(%ma_xmax)) , %limy $calc($abs(%ma_ymin) + $abs(%ma_ymax))
- tokenize 32 $1
- set %ma_xmin $calc(%ma_xmin + ((%limx * $1) / %ma_width))
- set %ma_xmax $calc(%ma_xmin + ((%limx * $3) / %ma_width))
- set %ma_ymin $calc(%ma_ymin + ((%limy * $2) / %ma_height))
- set %ma_ymax $calc(%ma_ymin + ((%limy * $4) / %ma_height))
- }
-
- alias -l cx {
- var %limx $calc($abs(%ma_xmin) + $abs(%ma_xmax)) , %limy $calc($abs(%ma_ymin) + $abs(%ma_ymax))
- set %ma_cx $calc(%ma_xmin + ((%limx * $1) / %ma_width))
- set %ma_cy $calc(%ma_ymin + ((%limy * $2) / %ma_height))
- }
-
- alias m&j dialog $iif($dialog(mj),-v,-m) mj mj
- alias -l sav { var %img $+(",$$sfile($+($scriptdir,\*.bmp),Choissiez le répertoire et le nom de l'image qui va être sauvegardée,&Sauvegarder),") | drawsave $1 %img }
- alias -l dc { drawcopy $1 0 0 $window($1).w $window($1).h $2 0 0 }
- on *:keydown:@mandel:13:{ $s2c(%ma_xywh) | mandel }
- on *:keydown:@julia:13:{ $s2c(%ma_xywh) | julia }
- on *:close:@mandel: { hfree color | unset %ma_* | window -c @man1 | if ($window(@julia)) close -@ @jul* }
- on *:close:@julia:window -c @jul1
dialog mj {
title "Mandel & Julia"
size -1 -1 101 127
option dbu
box "Taille fenetre", 1, 5 2 88 39
text "Largeur :", 2, 13 13 31 8
edit "300", 3, 49 11 39 11,center
text "Hauteur :", 4, 13 28 31 8
edit "200", 5, 49 26 39 11,center
text "Nombre d'iterations :", 6, 11 92 52 8
edit "10", 7, 68 90 20 11,center
button "Lancer !", 8, 33 110 37 13
box "Options", 9, 6 45 88 61
text "Couleurs :", 10, 11 57 25 8
check "", 13, 11 72 9 10
text "Rafraichir la fenetre en temps réel", 14, 23 71 58 15
combo 11, 42 55 46 33, size drop
}
on *:dialog:mj:*:*:{
if ($devent == init) { didtok mj 11 44 Dégradé gris ,Jaune-Rouge }
elseif ($devent == sclick && $did == 8) {
set %ma_width $did(3) | set %ma_height $did(5) | set %ma_iter $did(7) | set %ma_n $iif($did(13).state,-r,-nr)
set %ma_color $iif(gris isin $did(11),$($rgb(%c,%c,%c),0),$($rgb(255,$calc(255 - %c),0),0))
set %ma_xmax 2 | set %ma_xmin -2 | set %ma_ymax 1.5 | set %ma_ymin -1.5
mandel
}
elseif ($devent == close) { if (window(@mandel)) close -@ @man* | if ($window(@julia)) close -@ @jul* | if ($hget(color)) hfree $v1 | unset %ma_* }
}
alias -l mandel {
window -pd +L @mandel -1 -1 %ma_width $calc(%ma_height + 21) | window -o @mandel
var %i 1 | while (%i <= %ma_iter) { hadd -m color %i $int($calc((%i - 1)*256 /(%ma_iter - 1))) | inc %i }
var %ticks $ticks | echo -a Calcul en cours...
var %dx $calc((%ma_xmax - %ma_xmin) / %ma_width) , %dy $calc((%ma_ymax - %ma_ymin) / %ma_height)
var %y %ma_ymin , %x %ma_xmin
var %py 0 | while (%py <= %ma_height) {
;dll WhileFix.dll WhileFix
var %px 0 | while (%px <= %ma_width) {
var %zr 0 , %zi 0 , %i 1
while ($calc((%zr)^2 + (%zi)^2) < 4 && %i <= %ma_iter) {
var %temp %zr
var %zr $calc((%zr)^2 - (%zi)^2 + %x)
var %zi $calc(2 * %temp * %zi + %y)
inc %i
}
var %c $iif($hget(color,$calc(%i - 1)),$v1,0)
drawdot %ma_n @mandel $(%ma_color,2) 1 %px %py
inc %x %dx
inc %px
}
inc %y %dy
var %x %ma_xmin
inc %py
}
window -ph @man1 | dc @mandel @man1
echo -a Ensemble de Mandelbrot calculé en $duration($calc(($ticks - %ticks) / 1000)) , double-cliquez sur un point pour calculer l'ensemble de julia à ces coordonnées
}
alias -l julia {
window -pd +L @julia -1 -1 %ma_width $calc(%ma_height + 21) | window -o @julia
var %ticks $ticks | echo -a Calcul en cours...
var %dx $calc((%ma_xmax - %ma_xmin) / %ma_width) , %dy $calc((%ma_ymax - %ma_ymin) / %ma_height)
var %y %ma_ymin , %x %ma_xmin
var %py 0 | while (%py <= %ma_height) {
;dll WhileFix.dll WhileFix
var %px 0 | while (%px <= %ma_width) {
var %zr %x , %zi %y , %i 1
while ($calc((%zr)^2 + (%zi)^2) < 4 && %i <= %ma_iter) {
var %temp %zr
var %zr $calc((%zr)^2 - (%zi)^2 + %ma_cx)
var %zi $calc(2 * %temp * %zi + %ma_cy)
inc %i
}
var %c $iif($hget(color,$calc(%i - 1)),$v1,0)
drawdot %ma_n @julia $(%ma_color,2) 1 %px %py
inc %x %dx
inc %px
}
inc %y %dy
var %x %ma_xmin
inc %py
}
window -ph @jul1 | dc @julia @jul1
echo -a Ensemble de Julia aux coordonnées %ma_cx + i * %ma_cy calculé en $duration($calc(($ticks - %ticks) / 1000))
}
menu @mandel {
sclick { set %ma_bool $mouse.x $mouse.y }
mouse { if (%ma_bool) { dc @man1 @mandel | drawrect -c @mandel 14 1 %ma_bool $calc($mouse.x - $gettok(%ma_bool,1,32)) $calc($mouse.y - $gettok(%ma_bool,2,32)) } }
drop {
if (%ma_bool != $mouse.x $mouse.y) {
tokenize 32 %ma_bool
if ($1 < $mouse.x && $2 < $mouse.y) { set %ma_xywh $1-2 $mouse.x $mouse.y } | elseif ($mouse.x > $1 && $mouse.y < $2) { set %ma_xywh $1 $mouse.y $mouse.x $2 }
elseif ($1 > $mouse.x && $2 < $mouse.y) { set %ma_xywh $mouse.x $2 $1 $mouse.y } | else { set %ma_xywh $mouse.x $mouse.y $1-2 }
}
unset %ma_bool
}
dclick { $cx($mouse.x,$mouse.y) | julia }
Enregistrer l'image:{ dc @man1 @mandel | sav @mandel }
}
menu @julia {
sclick set %ma_bool $mouse.x $mouse.y
mouse {
if (%ma_bool) { dc @jul1 @julia | drawrect -c @julia 14 1 %ma_bool $calc($mouse.x - $gettok(%ma_bool,1,32)) $calc($mouse.y - $gettok(%ma_bool,2,32)) } }
drop {
if (%ma_bool != $mouse.x $mouse.y) {
tokenize 32 %ma_bool
if ($1 < $mouse.x && $2 < $mouse.y) { set %ma_xywh $1-2 $mouse.x $mouse.y } | elseif ($mouse.x > $1 && $mouse.y < $2) { set %ma_xywh $1 $mouse.y $mouse.x $2 }
elseif ($1 > $mouse.x && $2 < $mouse.y) { set %ma_xywh $mouse.x $2 $1 $mouse.y } | else { set %ma_xywh $mouse.x $mouse.y $1-2 }
}
unset %ma_bool
}
Enregistrer l'image:{ dc @jul1 @julia | sav @julia }
}
alias -l s2c {
var %limx $calc($abs(%ma_xmin) + $abs(%ma_xmax)) , %limy $calc($abs(%ma_ymin) + $abs(%ma_ymax))
tokenize 32 $1
set %ma_xmin $calc(%ma_xmin + ((%limx * $1) / %ma_width))
set %ma_xmax $calc(%ma_xmin + ((%limx * $3) / %ma_width))
set %ma_ymin $calc(%ma_ymin + ((%limy * $2) / %ma_height))
set %ma_ymax $calc(%ma_ymin + ((%limy * $4) / %ma_height))
}
alias -l cx {
var %limx $calc($abs(%ma_xmin) + $abs(%ma_xmax)) , %limy $calc($abs(%ma_ymin) + $abs(%ma_ymax))
set %ma_cx $calc(%ma_xmin + ((%limx * $1) / %ma_width))
set %ma_cy $calc(%ma_ymin + ((%limy * $2) / %ma_height))
}
alias m&j dialog $iif($dialog(mj),-v,-m) mj mj
alias -l sav { var %img $+(",$$sfile($+($scriptdir,\*.bmp),Choissiez le répertoire et le nom de l'image qui va être sauvegardée,&Sauvegarder),") | drawsave $1 %img }
alias -l dc { drawcopy $1 0 0 $window($1).w $window($1).h $2 0 0 }
on *:keydown:@mandel:13:{ $s2c(%ma_xywh) | mandel }
on *:keydown:@julia:13:{ $s2c(%ma_xywh) | julia }
on *:close:@mandel: { hfree color | unset %ma_* | window -c @man1 | if ($window(@julia)) close -@ @jul* }
on *:close:@julia:window -c @jul1
Conclusion
/m&j pour l'utiliser
(il est vrai que j'aurai plus ne faire qu'un seul alias regroupant mendel et julia, mais pour la compréhension, c'est plus clair ainsi)
Historique
- 29 août 2005 18:49:32 :
- trompé de catégorie
Sources du même auteur
Commentaires et avis
|
Derniers Blogs
[WF4] UN BINDING ACTIVITY/ACTIVITYDESIGNER QUI PASSE MAL?[WF4] UN BINDING ACTIVITY/ACTIVITYDESIGNER QUI PASSE MAL? par JeremyJeanson
Certain d'entre vous on peut être vécu cette situation embarrassante après quelques temps passer avec WF4 : Au début avec mon " ActivityDesigner" , tout allait bien. Et puis un jour j'ai au des problèmes de " Binding" . Alors nous sommes allé sur le site ...
Cliquez pour lire la suite de l'article par JeremyJeanson MYTIC - SHAREPOINT 2010 : DéJà UN MYTHE MICROSOFT ?MYTIC - SHAREPOINT 2010 : DéJà UN MYTHE MICROSOFT ? par junarnoalg
La prochaine session de MyTIC aura lieu à Namur, le 23 mars prochain. Pendant presque une heure, nous parlerons de SharePoint 2010. Voici un aperçu du programme.
Accueil : 17h30 Début de la session : 18h00 - Les nouvelles int...
Cliquez pour lire la suite de l'article par junarnoalg [MIX10] KEYNOTE DEUXIèME JOURNéE - INTERNET EXPLORER 9, HTML5, VISUAL STUDIO 2010, ODATA[MIX10] KEYNOTE DEUXIèME JOURNéE - INTERNET EXPLORER 9, HTML5, VISUAL STUDIO 2010, ODATA par cyril
Le deuxième keynote du mix fut très riche en contenu. Internet Explorer 9 Juste un après le lancement de Internet Explorer 8, Microsoft a dévoilé les nouveautés de Internet Explorer 9. Désormais, IE supportera HTML5, SVG et CSS3. L'élément ...
Cliquez pour lire la suite de l'article par cyril CERTIFICATIONS BETA .NET 4CERTIFICATIONS BETA .NET 4 par KooKiz
Les inscriptions pour les certifications beta .NET 4 ont commencé. L'inscription est offerte pour les examens suivants : - 71-511, TS: Windows Applications Development with Microsoft .NET Framework 4 - 71-515, TS: Web Applications Development with...
Cliquez pour lire la suite de l'article par KooKiz
Logiciels
Academy System (10.9.4.0)ACADEMY SYSTEM (10.9.4.0)Logiciel de gestion des établissements.
- élèves/étudiants (inscription, dossier, absence...)
-... Cliquez pour télécharger Academy System Xilisoft Convertisseur Vidéo Ultimate (5.1.39.0305)XILISOFT CONVERTISSEUR VIDéO ULTIMATE (5.1.39.0305)Xilisoft Convertisseur Vidéo Ultimate est un outil puissant de conversion vidéo, facile à utilise... Cliquez pour télécharger Xilisoft Convertisseur Vidéo Ultimate Xilisoft DVD Ripper Ultimate (5.0.64.0304)XILISOFT DVD RIPPER ULTIMATE (5.0.64.0304)Xilisoft DVD Ripper Ultimate est un logiciel excellent pour copier et convertir DVD vers presque ... Cliquez pour télécharger Xilisoft DVD Ripper Ultimate Rigs of Rods (63.3)RIGS OF RODS (63.3)c'est un jeu de multi-simulation camions,autobus voitures, avions, bateaux, hélicoptère avec défo... Cliquez pour télécharger Rigs of Rods
|