tweaking the Julia's fractal

This commit is contained in:
tTh 2024-02-10 21:55:04 +01:00
parent 27635a0398
commit dd552abeda
4 changed files with 45 additions and 17 deletions

View File

@ -6,6 +6,15 @@ Voyons d'abord
[une vidéo](http://la.buvette.org/fractales/f90/video.html)
qui montre ma première expérience dans ce domaine.
## Trucs à voir
La fractale de Julia se porte plutôt bien.
* [mkjuliagif.sh](mkjuliagif.sh) : fabrication de la gif animée
* [julias.f90](julias.f90) : fonctions de dessin d'une Julia
* [mkjulia.f90](mkjulia.f90) : le programme principal
## La technique
Le gros des calculs de fractales est fait dans `mods/fraktals.f90`,
@ -34,7 +43,7 @@ Generally writen as a *sequencial unformated* file.
## TODO
- Voir de près le calcul du cadrage
- Voir de près le calcul du cadrage : [centermag](../Modules/centermag.f90)
- Rajouter des formules
- Ne pas procastiner sur le reste

View File

@ -1,4 +1,5 @@
module julias
implicit none
contains
@ -42,13 +43,14 @@ subroutine simple_julia(pic, cx, cy, maxiter)
if (over_iter) then
pic(ix, iy) = 0
else
pic(ix, iy) = iter*12
pic(ix, iy) = mod(iter*13, 256)
endif
enddo ! iy
enddo ! ix
end subroutine simple_julia
!===============================================================
subroutine julia_colormapped(pic, cx, cy, maxiter)
use pixrgb
type(t_pixrgb), intent(inout), dimension (:,:) :: pic
@ -64,11 +66,11 @@ subroutine julia_colormapped(pic, cx, cy, maxiter)
width = ubound(pic, 1)
height = ubound(pic, 2)
C = complex(cx, cy)
print *, "Color julia, const = ", C
! print *, "Color julia, const = ", C
do ix = 1, width
fx = (float(ix) / (float(width*2)/4.0) - 1.0)
fx = (float(ix) / (float(width*2)/10.0) - 2.5)
do iy = 1, height
fy = (float(iy) / (float(height*2)/4.0) - 1.0)
fy = (float(iy) / (float(height*2)/10.0) - 2.5)
! ------ traitement du pixel
iter = 0 ; over_iter = .FALSE.
Z = complex(fx, fy)
@ -85,9 +87,9 @@ subroutine julia_colormapped(pic, cx, cy, maxiter)
pic(ix, iy)%g = mod(abs(int(real(Z) *140)), 255)
pic(ix, iy)%b = mod(abs(int(aimag(Z)*140)), 255)
else
pic(ix, iy)%r = mod(iter*33, 255)
pic(ix, iy)%r = mod(iter*22, 255)
pic(ix, iy)%g = mod(iter*59, 255)
pic(ix, iy)%b = mod(iter*41, 255)
pic(ix, iy)%b = mod(iter*21, 255)
endif
enddo ! iy
enddo ! ix

View File

@ -28,9 +28,13 @@ program julia
allocate(picz(512, 342))
call julia_colormapped(picz, cx, cy, 500)
call julia_colormapped(picz, cx, cy, 2500)
call rgbpix_spit_as_pnm_8(picz, trim(filename))
contains
!-----------------------------------------------------
end program
!-----------------------------------------------------

View File

@ -11,28 +11,41 @@ if [ $? -ne 0 ] ; then
exit 1
fi
cxa=" -1.5 "
cya=" -1.0 "
cxb=" 1.1 "
cyb=" 2.1 "
nbi=" 180 "
#
# run the prog
#
workdir="frames/julia/"
for foo in $(seq 0 179)
for foo in $( seq 0 $(( nbi - 1)) )
do
img=$(printf "%s/%05d.pnm" $workdir $foo)
bar=$(echo "$foo / 247.0" | bc -l)
cx=$(echo "0.5 * (1.52*c($foo/28.0))" | bc -l)
cy=$(echo "0.5 * (1.45*s($foo/17.0))" | bc -l)
Ka=$( echo "$foo / $nbi" | bc -l)
Kb=$( echo "1.0 - $Ka" | bc -l)
# echo $Ka $Kb
cx=$(echo "($cxa*$Ka) + ($cxb*$Kb)" | bc -l)
cy=$(echo "$cya*$Ka + $cyb*$Kb" | bc -l)
printf "%5d %4.6f %4.6f %4.6f %4.6f\n" \
$foo $Ka $Kb $cx $cy
./mkjulia $img $cx $cy
sleep 145
done
./tagpicz.sh $workdir
mogrify \
-gravity South-East \
-font Courier-Bold \
-pointsize 12 \
-fill Black \
-annotate +10+4 "Konrad+tTh 2024" \
"${workdir}/*.pnm"
echo ; echo "Encoding, please wait..."
convert -delay 10 $workdir/*.pnm color-julia.gif
# animate foo.gif &