diff --git a/Fraktalism/.gitignore b/Fraktalism/.gitignore index a521500..2da08a4 100644 --- a/Fraktalism/.gitignore +++ b/Fraktalism/.gitignore @@ -2,3 +2,4 @@ julia *.pgm +*.gif diff --git a/Fraktalism/fraktals.f90 b/Fraktalism/fraktals.f90 index b70dd92..4efcac6 100644 --- a/Fraktalism/fraktals.f90 +++ b/Fraktalism/fraktals.f90 @@ -3,24 +3,24 @@ module fraktals contains !----------------------------------------------------- -subroutine simple_julia(pic, cx, cy) +subroutine simple_julia(pic, cx, cy, maxiter) implicit none integer, intent(inout), dimension (:,:) :: pic real, intent(in) :: cx, cy + integer, intent(in) :: maxiter integer :: ix, iy, width, height real :: fx, fy complex :: Z, C - integer :: iter, maxiter + integer :: iter width = ubound(pic, 1) height = ubound(pic, 2) - print *, "image size : ", width, height + ! print *, "image size : ", width, height ! print *, "constante : ", cx, cy - maxiter = 500 C = complex(cx, cy) - print *, "C = ", C + ! print *, "C = ", C do ix = 1, width fx = (float(ix) / (float(width)/4.0) - 2.0) diff --git a/Fraktalism/julia.f90 b/Fraktalism/julia.f90 index dc20e2b..1843e58 100644 --- a/Fraktalism/julia.f90 +++ b/Fraktalism/julia.f90 @@ -12,18 +12,20 @@ program julia integer, dimension(640, 480) :: picz integer :: argc - character(200) :: filename + character(200) :: filename, string + real :: cx, cy argc = IARGC() - - if (1 .NE. argc) then - STOP ": JULIA PROGGY NEED A FILENAME" + if (3 .NE. argc) then + STOP ": JULIA PROGGY NEED PARAMETERS" endif call getarg(1, filename) + call getarg(2, string) ; read (string, *) cx + call getarg(3, string) ; read (string, *) cy - call simple_julia(picz, 0.3, 0.6) - call spit_as_pgm(picz, trim(filename)) + call simple_julia(picz, cx, cy, 120) + call spit_as_pgm_8(picz, trim(filename)) end program diff --git a/Fraktalism/mkjuliagif.sh b/Fraktalism/mkjuliagif.sh new file mode 100755 index 0000000..67db28f --- /dev/null +++ b/Fraktalism/mkjuliagif.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +for foo in $(seq 0 39) +do + + img=$(printf "frames/%05d.pgm" $foo) + bar=$(echo "$foo / 147.0" | bc -l) + cx=$(echo "0.4 * c($foo)" | bc -l) + cy=$(echo "0.4 * s($foo*2)" | bc -l) + + ./julia $img $cx $cy + +done + +echo ; echo "Encoding, please wait..." + +convert -delay 10 frames/*.pgm foo.gif + diff --git a/Fraktalism/spitpgm.f90 b/Fraktalism/spitpgm.f90 index 8163c1d..f162992 100644 --- a/Fraktalism/spitpgm.f90 +++ b/Fraktalism/spitpgm.f90 @@ -8,8 +8,6 @@ module spitpgm subroutine spit_as_pgm(pic, fname) - ! implicit none - integer, intent(in), dimension (:,:) :: pic character (len=*), intent(in) :: fname @@ -25,7 +23,6 @@ subroutine spit_as_pgm(pic, fname) write (io, '(i0)') 65535 foo = MAXVAL(pic) - if (foo .EQ. 0) then print *, " IS SOMETHING WRONG GOING TO HAPPEN ?" do ix = 1, size(pic) @@ -41,7 +38,33 @@ subroutine spit_as_pgm(pic, fname) end do end do endif + close(io) +end subroutine +!----------------------------------------------------- +subroutine spit_as_pgm_8(pic, fname) + + integer, intent(in), dimension (:,:) :: pic + character (len=*), intent(in) :: fname + + integer :: io, foo + integer :: ix, iy + + print *, "> spit_as_pgm_8 to ", fname + foo = MAXVAL(pic) + print *, " max = ", foo + open(newunit=io, file=fname) + write (io, '(a2)') "P2" + write (io, '(i0," ",i0)') size(pic, 1), size(pic, 2) + write (io, '(i0)') 255 + + do iy=1,ubound(pic, 2) + do ix=1, ubound(pic, 1) + foo = pic(ix, iy) + if (foo .GT. 255) foo = 255 + write(io, "(i3)") foo + enddo + enddo close(io) end subroutine