Compare commits

...

10 Commits

Author SHA1 Message Date
tth
123c87b126 trying to make a gif89a... 2022-02-12 23:27:59 +01:00
tth
a41a630889 first Julia set plotted 2022-02-12 21:00:57 +01:00
tth
2578d3cd6b change prog name 2022-02-12 13:34:44 +01:00
tth
8b132496ea adding MOARE bloubs !!! 2022-02-11 15:26:52 +01:00
tth
dd3cbe5dff cosmetic changes 2022-02-11 10:23:13 +01:00
tth
8b1a45c1d9 not so ok, sorry 2022-02-10 19:41:42 +01:00
tth
71d360f9dc minor tweaks, ok 2022-02-10 19:38:44 +01:00
tth
a3fa600a4d %ld 2022-02-10 18:51:17 +01:00
tth
027bca066e minor changes 2022-02-09 19:51:42 +01:00
tth
5444956a72 frobnicates the knobs 2022-02-09 19:36:27 +01:00
12 changed files with 281 additions and 40 deletions

View File

@ -24,12 +24,12 @@ module bloubspace
type(t_bloubs), intent (inout) :: blb
blb%px = 1.3 * (rand() - 0.50)
blb%py = rand() * 0.50
blb%py = 0.50 + rand() * 0.50
blb%pz = 2.0 * (rand() - 0.50)
blb%vx = (rand() - 0.5) / 3.000
blb%vy = (rand() - 0.5) / 3.000
blb%vz = (rand() - 0.5) / 3.000
blb%vx = (rand() - 0.5) / 2.500
blb%vy = (rand() - 0.5) / 4.000
blb%vz = (rand() - 0.5) / 2.500
blb%alive = .TRUE.
@ -87,10 +87,10 @@ module bloubspace
blb%py = 0.0
blb%seq = blb%seq + 1
endif
if (3.0 .lt. blb%py) then
if (5.0 .lt. blb%py) then
blb%vy = -1.0 * blb%vy
blb%seq = blb%seq + 1
blb%py = 3.0
blb%py = 5.0
endif
if (5.0 .lt. blb%pz) then
@ -109,7 +109,7 @@ module bloubspace
! ----------------------------------------------------------------
subroutine green_soylent (blb)
type(t_bloubs), intent (inout) :: blb
if (blb%seq .gt. 4) then
if (blb%seq .gt. 6) then
blb%alive = .FALSE.
endif
end subroutine

View File

@ -75,16 +75,13 @@ program movebloubs
enddo
if (add_new_bloub) then
! and now, we inject a new bloub in the universe
bloub%nick = 'newbie '
bloub%alive = .TRUE.
call random_pv(bloub)
bloub%radius = 0.045
bloub%seq = 0
! ok, we have read all the bloubs in the input file
! insert some fancy conditional here
if (add_new_bloub) then
call add_more_bloubs(outu, 8, 0.095)
call display_bloub (bloub, "new bloub")
write(outu) bloub ! no error control ?
endif
close(inu) ; close(outu)
@ -98,5 +95,29 @@ program movebloubs
bz = bz / dble(compteur)
write (0, '(A,3(F12.6,3X))') "barycentre : ", bx, by, bz
! --------------------------------------------------------------
contains
end program
subroutine add_more_bloubs(un, nbre, wtf)
integer, intent(in) :: un, nbre
real, intent(in) :: wtf
type(t_bloubs) :: bloub
integer :: foo
do foo=1, nbre
bloub%nick = 'newbie '
bloub%alive = .TRUE.
call random_pv(bloub)
bloub%radius = wtf
bloub%seq = foo
call display_bloub (bloub, "new bloub")
write(un) bloub ! no error control ?
enddo
end subroutine
! --------------------------------------------------------------
end program movebloubs

View File

@ -7,16 +7,19 @@
INCFILE="bloubs.inc"
TMPPNG="/dev/shm/bloubs7.png"
POVOPT="+Q9 +a -v -d -W920 -H600"
POVOPT="+Q9 +a -v -d -W920 -H600 -WT2"
DDIR="frames"
LOGERR="log.error"
BLBS_IN="/dev/shm/in.blbs"
BLBS_OUT="/dev/shm/out.blbs"
NBIMG=4000
make all
err=$?
if [ $err -ne 0 ] ; then
echo 'make error = ' $err
echo 'make error code is = ' $err
exit 1
fi
@ -26,14 +29,14 @@ printf "\n#declare NbImg = %d;\n" $NBIMG > nbimg.inc
# first, we have to make a seminal buch of bloubs
# --> this function need to be paraletrizable
#
./genbloubs in.blbs 9000
./genbloubs ${BLBS_IN} 5000
for idx in $(seq 0 $NBIMG)
do
echo "======== run passe $idx ========="
./exportbloubs in.blbs | awk -f toinc.awk > $INCFILE
./exportbloubs ${BLBS_IN} | awk -f toinc.awk > $INCFILE
povray -Iscene.pov -K${idx} -O${TMPPNG} ${POVOPT} 2> $LOGERR
if [ 0 -ne $? ] ; then
@ -44,22 +47,23 @@ do
fi
td=$(date +'%F %R:%S')
txt=$(printf "%5d %s" $idx "${td}")
hi=$(printf "#%05d" $idx)
PNG=$(printf "%s/%05d.png" ${DDIR} $idx)
echo "$txt" | tee -a log.txt
convert ${TMPPNG} \
-font fixed \
-pointsize 20 \
-fill Orange \
-font Courier-Bold \
-pointsize 22 \
-fill CadetBlue \
-gravity south-east \
-annotate +15+10 "$txt" \
-annotate +15+10 "$td" \
-gravity south-west \
-annotate +15+10 "$hi" \
$PNG
echo $PNG '[done]'
./movebloubs in.blbs out.blbs
mv out.blbs in.blbs
./movebloubs ${BLBS_IN} ${BLBS_OUT}
mv ${BLBS_OUT} ${BLBS_IN}
echo
done

View File

@ -30,7 +30,7 @@ object {
plane {
<0, 1, 0>, 0
texture {
pigment { color Black }
pigment { color Gray05 }
finish { phong 0.18 metallic 0.45 }
}
}
@ -38,14 +38,14 @@ plane {
// ----------------------------------------------------------
#declare BH = 5;
#declare BV = 3;
#declare BV = 5;
#declare BR = 0.025;
#declare Une_Borne = object
{
union {
cylinder { <0, 0, 0>, <0, BV, 0>, BR }
cylinder { <0, 0, 0>, <0, 0.02, 0>, BR*7 }
cylinder { <0, 0, 0>, <0, 0.02, 0>, BR*6 }
}
}
@ -63,14 +63,18 @@ object { Les_Bornes }
// ----------------------------------------------------------
light_source { <4, 12, -11> color Gray80 }
light_source { <7, 19, 9> color Gray60 }
light_source { <9, 22, -17> color Gray80 }
light_source { <11, 19, 9> color Gray60 }
#declare HCAM = 5 + (7 * NormClock);
#declare HCAM = 5 + (11 * NormClock);
#fopen LC "log.camera" append
#write (LC, clock, " ", NormClock, " ", HCAM, "\n")
#fclose LC
camera {
location <6, HCAM, -16>
look_at <0, 0, 0>
location <7, HCAM, -16>
look_at <0, 1, 0>
right x*image_width/image_height
angle 48
angle 50
}

5
Fraktalism/.gitignore vendored Normal file
View File

@ -0,0 +1,5 @@
julia
*.pgm
*.gif

19
Fraktalism/Makefile Normal file
View File

@ -0,0 +1,19 @@
GFOPT = -Wall -Wextra -time -g
# ---------------------------------------------
spitpgm.o: spitpgm.f90 Makefile
gfortran $(GFOPT) -c $<
fraktals.o: fraktals.f90 Makefile
gfortran $(GFOPT) -c $<
OBJS = spitpgm.o fraktals.o
# ---------------------------------------------
julia: julia.f90 Makefile $(OBJS)
gfortran $(GFOPT) $< $(OBJS) -o $@
# ---------------------------------------------

65
Fraktalism/fraktals.f90 Normal file
View File

@ -0,0 +1,65 @@
module fraktals
implicit none
contains
!-----------------------------------------------------
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
width = ubound(pic, 1)
height = ubound(pic, 2)
! print *, "image size : ", width, height
! print *, "constante : ", cx, cy
C = complex(cx, cy)
! print *, "C = ", C
do ix = 1, width
fx = (float(ix) / (float(width)/4.0) - 2.0)
do iy = 1, height
fy = (float(iy) / (float(height)/4.0) - 2.0)
! ------ traitement du pixel
iter = 0
Z = complex(fx, fy)
do while ( (modulus2(Z) .LT. 4.0) .AND. &
(iter < maxiter) )
Z = (Z * Z) + C
iter = iter + 1
end do
pic(ix, iy) = iter
! print *, ix, iy, " ", fx, fy, " ", iter
enddo
enddo
end subroutine
!-----------------------------------------------------
function dist0 (x, y)
implicit none
real, intent(in) :: x, y
real :: dist0
dist0 = ( x*x + y*y )
end function
!-----------------------------------------------------
function modulus2(pt)
implicit none
complex, intent(in) :: pt
real :: modulus2
modulus2 = real(pt)*real(pt) + imag(pt)*imag(pt)
end
!-----------------------------------------------------
end module fraktals

32
Fraktalism/julia.f90 Normal file
View File

@ -0,0 +1,32 @@
!
! this is the main programm
!
!-----------------------------------------------------
program julia
use spitpgm
use fraktals
implicit none
integer, dimension(640, 480) :: picz
integer :: argc
character(200) :: filename, string
real :: cx, cy
argc = IARGC()
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, 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

@ -78,7 +78,7 @@ end
!
! this is the main programm
!
program image
program mkmandel
use imagetools

73
Fraktalism/spitpgm.f90 Normal file
View File

@ -0,0 +1,73 @@
module spitpgm
implicit none
contains
!-----------------------------------------------------
subroutine spit_as_pgm(pic, fname)
integer, intent(in), dimension (:,:) :: pic
character (len=*), intent(in) :: fname
integer :: io, foo
integer :: ix, iy
real :: fk, fpix
print *, "> spit_as_pgm to ", fname
open(newunit=io, file=fname)
write (io, '(a2)') "P2"
write (io, '(i0," ",i0)') size(pic, 1), size(pic, 2)
write (io, '(i0)') 65535
foo = MAXVAL(pic)
if (foo .EQ. 0) then
print *, " IS SOMETHING WRONG GOING TO HAPPEN ?"
do ix = 1, size(pic)
write (io, "(i0)") 0
enddo
else
fk = float(foo) / 65535.0
print *, " max pix value", foo, " fk = ", fk
do iy = 1, ubound(pic, 2)
do ix = 1, ubound(pic, 1)
fpix = float(pic(ix, iy)) / fk
write (io, "(i0)") int(fpix)
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
!-----------------------------------------------------
end module spitpgm

View File

@ -17,7 +17,7 @@ fprintf(stderr, " +-- sf info [%s] %p\n", text, psf);
fprintf(stderr, " | samplerate %d\n", psf->samplerate);
fprintf(stderr, " | channels %d\n", psf->channels);
fprintf(stderr, " | frames %d\n", psf->frames);
fprintf(stderr, " | frames %ld\n", psf->frames);
return 0;
}