From 1b3f93ecfeb454381568420e96fdae59742ce7f5 Mon Sep 17 00:00:00 2001 From: tTh Date: Sat, 31 Dec 2022 13:25:02 +0100 Subject: [PATCH] split mkmandel --- Fraktalism/.gitignore | 2 + Fraktalism/Makefile | 10 +++- Fraktalism/mandelbrots.f90 | 83 ++++++++++++++++++++++++++++++++ Fraktalism/mkmandel.f90 | 97 ++++---------------------------------- 4 files changed, 103 insertions(+), 89 deletions(-) create mode 100644 Fraktalism/mandelbrots.f90 diff --git a/Fraktalism/.gitignore b/Fraktalism/.gitignore index 597b4b3..7122cf5 100644 --- a/Fraktalism/.gitignore +++ b/Fraktalism/.gitignore @@ -14,6 +14,8 @@ WS/*.dat WS/*.txt WS/*.inc +toto + *.pgm *.gif *.asc diff --git a/Fraktalism/Makefile b/Fraktalism/Makefile index 64c4f63..c9f8177 100644 --- a/Fraktalism/Makefile +++ b/Fraktalism/Makefile @@ -1,5 +1,6 @@ -all: voxelize evolvopick pickover julia lorentz essai +all: voxelize evolvopick pickover julia lorentz essai \ + mkmandel GFOPT = -Wall -Wextra -time -g -Imods/ -I../Modules @@ -16,7 +17,12 @@ mods/xperiment.o: mods/xperiment.f90 Makefile fraktals.o: fraktals.f90 Makefile gfortran $(GFOPT) -c $< -OBJDEP = mods/points3d.o mods/xperiment.o fraktals.o mods/fractcolmap.o +mandelbrots.o: mandelbrots.f90 Makefile + gfortran $(GFOPT) -c $< + +OBJDEP = mods/points3d.o mods/xperiment.o mods/fractcolmap.o \ + fraktals.o mandelbrots.o + OBJS = $(OBJDEP) ../Modules/pixrgb.o ../Modules/spitpgm.o # --------------------------------------------- diff --git a/Fraktalism/mandelbrots.f90 b/Fraktalism/mandelbrots.f90 new file mode 100644 index 0000000..32afaa0 --- /dev/null +++ b/Fraktalism/mandelbrots.f90 @@ -0,0 +1,83 @@ +!----------------------------------------------------- +! MANDELBROT SET +!- +! refactored Thu 29 Dec 2022 03:21:16 PM CET +! refactored Sat 31 Dec 2022 12:37:03 PM CET +!- +!----------------------------------------------------- +!- +module mandelbrots + implicit none +contains +!----------------------------------------------------------------------- + +subroutine mandelbrot_one(pic, start) + ! use cmplxmath + ! use imagetools + use pixrgb + + implicit none + + type(t_pixrgb), intent(inout), dimension (:,:) :: pic + complex, intent(in) :: start + ! type (CenterMag), intent(in) :: cz + + integer :: ix, iy, width, height + real :: fx, fy, mod2, rval + complex :: za, zb, cste + integer :: iter, maxiter + logical :: escape + + write(0,*) "> plotsomething" + + width = ubound(pic, 1) + height = ubound(pic, 2) + ! print *, " pic size ", width, height + print *, real(start), aimag(start) + + ! initialise constants + ! + maxiter = 1984 + + ! enter megaloop + ! + do iy = 1, height + fy = (float(iy) / float(height/3)) - 1.5 + !! print *, "line ", iy, fy + do ix = 1, width + fx = (float(ix) / float(width/3)) - 2.0 + !------------------------------------- + ! working on the current pixel + za = start + cste = complex ( fx, fy ) + iter = 0 + escape = .FALSE. + do while (iter .lt. maxiter) + zb = (za * za) + cste + mod2 = real(zb)*real(zb) + aimag(zb)*aimag(zb) + !! print *, "mod2 ", mod2 + if (mod2 .GT. 4.0) then + escape = .TRUE. + exit + endif + za = zb + iter = iter + 1 + !! print *, "ZA ITER ESCAPE", za, iter, escape + enddo + if (escape) then + pic(ix, iy)%r = mod(iter*12, 255) + pic(ix, iy)%b = mod(iter*7, 255) + else + rval = (sqrt(mod2) + abs(real(start)*aimag(start))) * 9e2 + pic(ix, iy)%g = mod(int(rval), 210) + ! pic(ix, iy)%g = mod(iter, 255) + ! pic(ix, iy)%b = mod(iter*11, 255) + endif + !------------------------------------- + end do ! fin boucle sur X + end do + +end subroutine +!----------------------------------------------------- +end module +!----------------------------------------------------- diff --git a/Fraktalism/mkmandel.f90 b/Fraktalism/mkmandel.f90 index 5e4b711..7c45aeb 100644 --- a/Fraktalism/mkmandel.f90 +++ b/Fraktalism/mkmandel.f90 @@ -2,94 +2,19 @@ ! MANDELBROT SET !- ! refactored Thu 29 Dec 2022 03:21:16 PM CET +! refactored Sat 31 Dec 2022 12:37:03 PM CET +! all generative parts are now in 'mandelbrots.f90' module !- -!----------------------------------------------------- -!- -subroutine plotsomething(pic, start) - ! use cmplxmath - ! use imagetools - use pixrgb - - implicit none - - type(t_pixrgb), intent(inout), dimension (:,:) :: pic - complex, intent(in) :: start - ! type (CenterMag), intent(in) :: cz - - integer :: ix, iy, width, height - real :: fx, fy, mod2, rval - complex :: za, zb, cste - integer :: iter, maxiter - logical :: escape - - print *, "> plotsomething" - - width = ubound(pic, 1) - height = ubound(pic, 2) - ! print *, " pic size ", width, height - print *, " start ", start - - ! initialise constants - ! - maxiter = 1984 - - ! enter megaloop - ! - do iy = 1, height - fy = (float(iy) / float(height/3)) - 1.5 - !! print *, "line ", iy, fy - do ix = 1, width - fx = (float(ix) / float(width/3)) - 2.0 - !------------------------------------- - ! working on the current pixel - za = start - cste = complex ( fx, fy ) - iter = 0 - escape = .FALSE. - do while (iter .lt. maxiter) - zb = (za * za) + cste - mod2 = real(zb)*real(zb) + aimag(zb)*aimag(zb) - !! print *, "mod2 ", mod2 - if (mod2 .GT. 4.0) then - escape = .TRUE. - exit - endif - za = zb - iter = iter + 1 - !! print *, "ZA ITER ESCAPE", za, iter, escape - enddo - if (escape) then - pic(ix, iy)%r = mod(iter*12, 255) - pic(ix, iy)%b = mod(iter*8, 255) - else - rval = (mod2 + abs(real(start)*aimag(start))) * 666.666 - pic(ix, iy)%g = mod(int(rval), 180) - ! pic(ix, iy)%g = mod(iter, 255) - ! pic(ix, iy)%b = mod(iter*11, 255) - endif - !------------------------------------- - end do ! fin boucle sur X - end do - -end - !----------------------------------------------------- ! ! this is the main programm ! program mkmandel use pixrgb + use mandelbrots implicit none - interface - subroutine plotsomething (pic, start) - use pixrgb - type(t_pixrgb), intent(inout), dimension (:,:) :: pic - complex, intent(in) :: start - end subroutine plotsomething - end interface - type(t_pixrgb), allocatable :: pic(:,:) integer :: angle real :: radangle, radius @@ -98,27 +23,25 @@ program mkmandel write(0, *) "-------- making some mandelbrot -------" - allocate(pic(1152, 900)) + allocate(pic(1024, 768)) do angle = 0, 1500 call rgbpix_set_to_zero(pic) radangle = float(angle) * 0.01664 - radius = float(angle) / 1500.0 + radius = float(angle) / 2000.0 write (filename, "(a, i5.5, a)") "frames/mandel/", angle, ".pnm" ! filename = trim(filename) - print *, "#### passe ", angle, radangle, trim(filename) + write(0,*) "#### passe ", angle, radangle, trim(filename) - stx = radius * (sin(radangle*3.9) + sin(radangle*5.36)) - sty = radius * cos(radangle*3.3) + stx = radius * (sin(radangle*2.07) + 0.2131*sin(radangle*7.36)) + sty = radius * (cos(radangle*3.21) + 0.2725*cos(radangle*9.99)) - call plotsomething (pic, complex(stx, sty)) + call mandelbrot_one(pic, complex(stx, sty)) call rgbpix_spit_as_pnm_8 (pic, trim(filename)) - print * - enddo - print *, " [DONE]" + enddo end