better flashy mandelbrot set

This commit is contained in:
tTh 2022-12-30 02:06:00 +01:00
parent e099b398f3
commit 77ea714b19
2 changed files with 29 additions and 38 deletions

View File

@ -5,6 +5,11 @@ module fraktals
implicit none implicit none
contains contains
!===============================================================
!-
! Enfin un debut de Mandelbrot :)
!-
!=============================================================== !===============================================================
! nouveau 28 mai 2022 (again) ! nouveau 28 mai 2022 (again)
! source: ! source:
@ -12,18 +17,13 @@ module fraktals
! !
subroutine parasites_0(pic, cx, cy, maxiter) subroutine parasites_0(pic, cx, cy, maxiter)
implicit none implicit none
! here is the wtf
integer, intent(inout), dimension (:,:) :: pic integer, intent(inout), dimension (:,:) :: pic
real, intent(in) :: cx, cy real, intent(in) :: cx, cy
integer, intent(in) :: maxiter integer, intent(in) :: maxiter
integer :: ix, iy, width, height integer :: ix, iy, width, height
real :: fx, fy, coef real :: fx, fy, coef
logical :: burps logical :: burps
! write(0, *) "subroutine parasites_0" , maxiter
! write(0, *) "constantes", cx, cy
width = ubound(pic, 1) ; height = ubound(pic, 2) width = ubound(pic, 1) ; height = ubound(pic, 2)
coef = float(maxiter) / 12.3456789 coef = float(maxiter) / 12.3456789
@ -33,20 +33,19 @@ subroutine parasites_0(pic, cx, cy, maxiter)
burps = (RAND() .lt. 0.01) burps = (RAND() .lt. 0.01)
do iy = 1, height do iy = 1, height
fy = cy + (float(iy) / (float(height)/4.0) - 2.0) fy = cy + (float(iy) / (float(height)/4.0) - 2.0)
if (burps) then if (burps) then
pic(ix, iy) = mod(int(fx * fy * coef * 1.005), 250) pic(ix, iy) = mod(int(fx * fy * coef * 1.005), 250)
else else
pic(ix, iy) = mod(int(fx * fy * coef), 250) pic(ix, iy) = mod(int(fx * fy * coef), 250)
endif endif
enddo enddo
enddo enddo
end subroutine parasites_0 end subroutine parasites_0
!=============================================================== !===============================================================
!-
! some problems with color mapping, need more work
!-
subroutine simple_julia(pic, cx, cy, maxiter) subroutine simple_julia(pic, cx, cy, maxiter)
implicit none implicit none
integer, intent(inout), dimension (:,:) :: pic integer, intent(inout), dimension (:,:) :: pic
@ -72,22 +71,17 @@ subroutine simple_julia(pic, cx, cy, maxiter)
fx = (float(ix) / (float(width)/4.0) - 2.0) fx = (float(ix) / (float(width)/4.0) - 2.0)
do iy = 1, height do iy = 1, height
fy = (float(iy) / (float(height)/4.0) - 2.0) fy = (float(iy) / (float(height)/4.0) - 2.0)
! ------ traitement du pixel ! ------ traitement du pixel
iter = 0 ; over_iter = .FALSE. iter = 0 ; over_iter = .FALSE.
Z = complex(fx, fy) Z = complex(fx, fy)
do while (modulus2(Z) .LT. 4.0) do while (modulus2(Z) .LT. 4.0)
Z = (Z * Z) + C Z = (Z * Z) + C
iter = iter + 1 iter = iter + 1
if (iter .GE. maxiter) then if (iter .GE. maxiter) then
over_iter = .TRUE. over_iter = .TRUE.
exit exit
endif endif
end do end do
if (over_iter) then if (over_iter) then
pic(ix, iy) = 0 pic(ix, iy) = 0
else else
@ -98,22 +92,18 @@ subroutine simple_julia(pic, cx, cy, maxiter)
end subroutine simple_julia end subroutine simple_julia
!=============================================================== !===============================================================
!-
! d'après les pages 91/92 du livre de Roger T Stevens ! d'après les pages 91/92 du livre de Roger T Stevens
! "Fractal programming in C" ! "Fractal programming in C"
! !-
subroutine compute_pickover(array, coefs) subroutine compute_pickover(array, coefs)
type(t_point3d), dimension(:) :: array type(t_point3d), dimension(:) :: array
double precision, dimension(4) :: coefs double precision, dimension(4) :: coefs
double precision :: xa, ya, za, xb, yb, zb double precision :: xa, ya, za, xb, yb, zb
integer :: i integer :: i
! print *, "coefs ", coefs
! write(0, '(1X, A18, I9)') "compute pickover ", ubound(array, 1)
xa = 1.0 ; ya = 1.0 ; za = 1.0 xa = 1.0 ; ya = 1.0 ; za = 1.0
do i=1, ubound(array, 1) do i=1, ubound(array, 1)
xb = sin(coefs(1)*ya) - za*cos(coefs(2)*xa) xb = sin(coefs(1)*ya) - za*cos(coefs(2)*xa)
yb = za*sin(coefs(3)*xa) - cos(coefs(4)*ya) yb = za*sin(coefs(3)*xa) - cos(coefs(4)*ya)
@ -126,7 +116,6 @@ subroutine compute_pickover(array, coefs)
enddo enddo
end subroutine end subroutine
!----------------------------------------------------- !-----------------------------------------------------
! !
! d'après les pages 91/92 du livre de Roger T Stevens ! d'après les pages 91/92 du livre de Roger T Stevens
@ -190,7 +179,8 @@ end subroutine lorentz_0
!=============================================================== !===============================================================
! -- some support functions -- ! -- some support functions --
!----------------------------------------------------------- !-----------------------------------------------------------
! usage : evolvopick & voxelize ! usage in : evolvopick & voxelize
!-
subroutine interp4dp (ina, inb, out, dpk) subroutine interp4dp (ina, inb, out, dpk)
double precision, dimension(4), intent(in) :: ina, inb double precision, dimension(4), intent(in) :: ina, inb
double precision, dimension(4), intent(out) :: out double precision, dimension(4), intent(out) :: out

View File

@ -1,5 +1,8 @@
!----------------------------------------------------- !-----------------------------------------------------
! IMAGE PROCESSING ! MANDELBROT SET
!-
! refactored Thu 29 Dec 2022 03:21:16 PM CET
!-
!----------------------------------------------------- !-----------------------------------------------------
!- !-
subroutine plotsomething(pic, start) subroutine plotsomething(pic, start)
@ -14,7 +17,7 @@ subroutine plotsomething(pic, start)
! type (CenterMag), intent(in) :: cz ! type (CenterMag), intent(in) :: cz
integer :: ix, iy, width, height integer :: ix, iy, width, height
real :: fx, fy, mod2 real :: fx, fy, mod2, rval
complex :: za, zb, cste complex :: za, zb, cste
integer :: iter, maxiter integer :: iter, maxiter
logical :: escape logical :: escape
@ -28,7 +31,7 @@ subroutine plotsomething(pic, start)
! initialise constants ! initialise constants
! !
maxiter = 2500; maxiter = 1984
! enter megaloop ! enter megaloop
! !
@ -37,8 +40,6 @@ subroutine plotsomething(pic, start)
!! print *, "line ", iy, fy !! print *, "line ", iy, fy
do ix = 1, width do ix = 1, width
fx = (float(ix) / float(width/3)) - 2.0 fx = (float(ix) / float(width/3)) - 2.0
!! print *, "pixel ", ix, iy, " at ", fx, fy
!------------------------------------- !-------------------------------------
! working on the current pixel ! working on the current pixel
za = start za = start
@ -47,7 +48,6 @@ subroutine plotsomething(pic, start)
escape = .FALSE. escape = .FALSE.
do while (iter .lt. maxiter) do while (iter .lt. maxiter)
zb = (za * za) + cste zb = (za * za) + cste
! if (modulus2(zb) .gt. 4.0) then
mod2 = real(zb)*real(zb) + aimag(zb)*aimag(zb) mod2 = real(zb)*real(zb) + aimag(zb)*aimag(zb)
!! print *, "mod2 ", mod2 !! print *, "mod2 ", mod2
if (mod2 .GT. 4.0) then if (mod2 .GT. 4.0) then
@ -59,10 +59,11 @@ subroutine plotsomething(pic, start)
!! print *, "ZA ITER ESCAPE", za, iter, escape !! print *, "ZA ITER ESCAPE", za, iter, escape
enddo enddo
if (escape) then if (escape) then
pic(ix, iy)%r = mod(iter*22, 255) pic(ix, iy)%r = mod(iter*12, 255)
pic(ix, iy)%b = mod(iter*7, 255) pic(ix, iy)%b = mod(iter*8, 255)
else else
pic(ix, iy)%g = mod(int(mod2 * 555), 200) 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)%g = mod(iter, 255)
! pic(ix, iy)%b = mod(iter*11, 255) ! pic(ix, iy)%b = mod(iter*11, 255)
endif endif
@ -95,21 +96,21 @@ program mkmandel
real :: stx, sty real :: stx, sty
character (len=80) :: filename character (len=80) :: filename
print *, "-------- making some mandelbrot -------" write(0, *) "-------- making some mandelbrot -------"
allocate(pic(800, 600)) allocate(pic(1152, 900))
do angle = 0, 1200 do angle = 0, 1500
call rgbpix_set_to_zero(pic) call rgbpix_set_to_zero(pic)
radangle = float(angle) * 0.017453292522222 radangle = float(angle) * 0.01664
radius = float(angle) / 2000.0 radius = float(angle) / 1500.0
write (filename, "(a, i5.5, a)") "frames/mandel/", angle, ".pnm" write (filename, "(a, i5.5, a)") "frames/mandel/", angle, ".pnm"
! filename = trim(filename) ! filename = trim(filename)
print *, "#### passe ", angle, radangle, trim(filename) print *, "#### passe ", angle, radangle, trim(filename)
stx = radius * sin(radangle*3.9) stx = radius * (sin(radangle*3.9) + sin(radangle*5.36))
sty = radius * cos(radangle*3.3) sty = radius * cos(radangle*3.3)
call plotsomething (pic, complex(stx, sty)) call plotsomething (pic, complex(stx, sty))