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
Sources de la même categorie
Commentaires et avis
|
Derniers Blogs
SESSION SILVERLIGHT 5 3D : SLIDES ET DEMOSSESSION SILVERLIGHT 5 3D : SLIDES ET DEMOS par Groc
Durant les techdays, j'ai eu le plaisir d'animer une session sur Silverlight 5 et la 3D avec Simon Ferquel. Comme promis, voici nos slides et mes démos (celles avec le viper BSG) ici et là. Pour mémoire, les démos utilisent toutes le viper BSG...
Cliquez pour lire la suite de l'article par Groc [TECHDAYS 2012] SESSION WEBMATRIX 2 : LE COUTEAU SUISSE GRATUIT POUR VOS DéVELOPPEMENTS WEB - SLIDES[TECHDAYS 2012] SESSION WEBMATRIX 2 : LE COUTEAU SUISSE GRATUIT POUR VOS DéVELOPPEMENTS WEB - SLIDES par gpommier
Suite à la session que j'ai présenté sur WebMatrix 2, vous pouvez trouver les slides ici, ainsi que les démos en packages nuget : démos1 et démos2 J'en profite pour remercier chaleureusement tous ceux qui sont venus très nombreux à cette sess...
Cliquez pour lire la suite de l'article par gpommier [SHAREPOINT] LES SESSIONS TECHDAYS 2012.[SHAREPOINT] LES SESSIONS TECHDAYS 2012. par Patrick Guimonet
Voici donc pour ceux qui n'ont pas pu venir, ou ceux qui n'ont pas pu toutes les suivre la liste des sessions SharePoint aux TechDays 2012, que je mettrais à jour dès que les liens des vidéo seront disponibles. Ou ici : http...
Cliquez pour lire la suite de l'article par Patrick Guimonet TECHDAYS PARIS 2012 : SESSION PLEINIèRE JOUR 3TECHDAYS PARIS 2012 : SESSION PLEINIèRE JOUR 3 par ROMELARD Fabrice
Speaker: Bernard Ourghanlian Cette session est comme chaque jour transmise en live par BrainSonic, et j'ai donc suivi cette troisième pleinière par ce moyen sur mon iPad . Elle est dédiée comme chaque année à la mise en perspective de l'é...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice MISHRA READER : UN LECTEUR RSS TRèS ZUNE STYLE EN OPEN SOURCE !MISHRA READER : UN LECTEUR RSS TRèS ZUNE STYLE EN OPEN SOURCE ! par Vko
Hier durant une session dédiée aux Techdays 2012, j'ai eu le plaisir d'annoncer la sortie de la Béta 2 de Mishra Reader. C'est quoi ? Pour les utilisateurs, c'est une vraie expérience de lecture de flux RSS sur Windows. Rien à voir avec les produit...
Cliquez pour lire la suite de l'article par Vko
Forum
RE : AIDERE : AIDE par Nico26000
Cliquez pour lire la suite par Nico26000 RE : AIDERE : AIDE par WorldDMT
Cliquez pour lire la suite par WorldDMT AIDEAIDE par Nico26000
Cliquez pour lire la suite par Nico26000
Logiciels
Tribler (2012)TRIBLER (2012)Tribler est un client pair à pair (P2P/Peer-to-Peer) open source avec la capacité de regarder des... Cliquez pour télécharger Tribler OneSwarm (2012)ONESWARM (2012)Le peer-to-peer qui protège votre vie privée, c'est OneSwarm.
Ce logiciel de peer-to-peer crypté... Cliquez pour télécharger OneSwarm PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V8.4)PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V8.4)PONAMEDIA TV DEVIENS HELLLOOO FLASH
LA TV SUR VOTRE ORDINATEUR.
Toute une plateforme Multi... Cliquez pour télécharger PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO Academy System (17.2.1.0)ACADEMY SYSTEM (17.2.1.0)Logiciel de gestion des établissements.
- élèves/étudiants (inscription, dossier, absence...)
-... Cliquez pour télécharger Academy System Easy-Planning (1.0.0.1)EASY-PLANNING (1.0.0.1)Basé sur les mêmes principes que MyPlanning, Easy-Planning permet de créer des plannings sous la ... Cliquez pour télécharger Easy-Planning
|