trying to make a gif89a...

This commit is contained in:
tth 2022-02-12 23:27:59 +01:00
parent a41a630889
commit 123c87b126
5 changed files with 58 additions and 14 deletions

View File

@ -2,3 +2,4 @@
julia
*.pgm
*.gif

View File

@ -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)

View File

@ -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

18
Fraktalism/mkjuliagif.sh Executable file
View File

@ -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

View File

@ -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