Compare commits

..

8 Commits

Author SHA1 Message Date
tTh
2c187e01bc dernier commit avant le Gers 2024-03-10 06:56:29 +01:00
tTh
caec2e08fe added garbage 2024-02-27 05:39:19 +01:00
tTh
d76861a4e4 first run of readpicz 2024-02-27 01:22:18 +01:00
tTh
764d7343f2 add a Julia test image 2024-02-16 01:35:46 +01:00
tTh
dd552abeda tweaking the Julia's fractal 2024-02-10 21:55:04 +01:00
tTh
27635a0398 cosmetic 2024-02-10 09:12:10 +01:00
tTh
eef8e7db64 wavmetrics: add a test driver 2024-02-08 04:08:59 +01:00
tTh
09a4cb7cff wavmetrics: add a small test 2024-02-08 04:07:42 +01:00
23 changed files with 292 additions and 83 deletions

View File

@@ -6,6 +6,7 @@ mkmandel
voxelize
evolvopick
henon
mkhenon
essai
plotcolmap
@@ -17,6 +18,7 @@ WS/*.inc
toto
*.pgm
*.pnm
*.gif
*.asc
*.png

View File

@@ -38,12 +38,22 @@ plotcolmap: plotcolmap.f90 Makefile $(OBJDEP)
# ---------------------------------------------
mkjulia: mkjulia.f90 Makefile $(OBJDEP)
gfortran $(GFOPT) $< $(OBJS) -o $@
xjulia.pnm: mkjulia Makefile
./mkjulia $@ -0.204365 0.321463
# ---------------------------------------------
henon: henon.f90 Makefile $(OBJDEP)
gfortran $(GFOPT) $< $(OBJS) -o $@
mkjulia: mkjulia.f90 Makefile $(OBJDEP)
mkhenon: mkhenon.f90 Makefile $(OBJDEP)
gfortran $(GFOPT) $< $(OBJS) -o $@
# ---------------------------------------------
pickover: pickover.f90 Makefile $(OBJDEP)
gfortran $(GFOPT) $< $(OBJS) -o $@

View File

@@ -6,6 +6,20 @@ Voyons d'abord
[une vidéo](http://la.buvette.org/fractales/f90/video.html)
qui montre ma première expérience dans ce domaine.
## Trucs à voir
La fractale de Julia se porte plutôt bien, mais les travaux continuent.
* [mkjuliagif.sh](mkjuliagif.sh) : fabrication de la gif animée
* [julias.f90](julias.f90) : fonctions de dessin d'une Julia
* [mkjulia.f90](mkjulia.f90) : le programme principal
**Q:** pourquoi faire la boucle en shell plutôt qu'en Fortran ?
**A:** Parce que je peux recompiler le binaire `mkjulia` pendant le
déroulement de la boucle, une manière comme une autre de faire
du *livecoding*.
## La technique
Le gros des calculs de fractales est fait dans `mods/fraktals.f90`,
@@ -34,7 +48,7 @@ Generally writen as a *sequencial unformated* file.
## TODO
- Voir de près le calcul du cadrage
- Voir de près le calcul du cadrage : [centermag](../Modules/centermag.f90)
- Rajouter des formules
- Ne pas procastiner sur le reste

View File

@@ -36,7 +36,7 @@ TITLE='---{ experimental }---'
ffmpeg -nostdin \
-loglevel warning \
-y -r 30 -f image2 -i $SDIR/%05d.pnm \
-y -r 30 -f image2 -i $SDIR/%05d.png \
-metadata artist='---{ tTh }---' \
-metadata title="${TITLE}" \
-preset veryslow \

View File

@@ -137,6 +137,7 @@ subroutine interp4dp (ina, inb, out, dpk)
end subroutine
!-----------------------------------------------------------
!-
function dist0 (x, y)
implicit none
@@ -146,6 +147,8 @@ function dist0 (x, y)
end function
!-----------------------------------------------------------
!-
function modulus2(pt)
implicit none
complex, intent(in) :: pt

View File

@@ -1,31 +1,10 @@
program henon
module henon
implicit none
integer :: passe
double precision :: vx, vy
integer :: w, h
integer :: foo, bar
double precision :: px, py
w = 2000 ; h = 1600
write(0, *) "###### Mapping of Henon "
do foo=1, 16
px = dble(foo) / 16.0
do bar=1,16
py = dble(bar) / 16.0
call compute_pixel_henon(px, py, 1700, &
passe, dble(0.5), vx, vy)
write(0, fmt=*) "passe ", passe, vx, vy
enddo
end do
contains
!-----------------------------------------------------
contains
!-----------------------------------------------------
!-----------------------------------------------------
subroutine compute_pixel_henon(a, b, maxpasse, passe, limit, rx, ry)
implicit none
double precision, intent(in) :: a, b, limit
@@ -62,5 +41,5 @@ end subroutine
!-----------------------------------------------------
end program
end module

View File

@@ -1,4 +1,6 @@
module julias
use fraktals
implicit none
contains
@@ -42,37 +44,47 @@ subroutine simple_julia(pic, cx, cy, maxiter)
if (over_iter) then
pic(ix, iy) = 0
else
pic(ix, iy) = iter*12
pic(ix, iy) = mod(iter*13, 256)
endif
enddo ! iy
enddo ! ix
end subroutine simple_julia
!===============================================================
subroutine julia_colormapped(pic, cx, cy, maxiter)
!-
! this code is nor really finished
!-
subroutine julia_colormapped(pic, cx, cy, mag, maxiter)
use pixrgb
type(t_pixrgb), intent(inout), dimension (:,:) :: pic
real, intent(in) :: cx, cy
real, intent(in) :: cx, cy, mag
integer, intent(in) :: maxiter
integer :: ix, iy, width, height
real :: fx, fy
integer :: ix, iy, width, height, iter
real :: fx, fy, div, off
complex :: Z, C
integer :: iter
logical :: over_iter
integer :: under, over
pic = t_pixrgb(0, 0, 0)
width = ubound(pic, 1)
height = ubound(pic, 2)
C = complex(cx, cy)
print *, "Color julia, const = ", C
div = mag * 10.0 ; off = mag * 2.5
under = 0 ; over = 0
print *, "mag:", mag, " -> ", div, off
! print *, "Color julia, const = ", C
do ix = 1, width
fx = (float(ix) / (float(width*2)/4.0) - 1.0)
fx = (float(ix) / (float(width*2)/div) - off)
do iy = 1, height
fy = (float(iy) / (float(height*2)/4.0) - 1.0)
fy = (float(iy) / (float(height*2)/div) - off)
! ------ traitement du pixel
iter = 0 ; over_iter = .FALSE.
Z = complex(fx, fy)
do while ((real(Z)*real(Z) + imag(Z)*imag(Z)) .LT. 4.0)
do while ((real(Z)*real(Z) + (imag(Z)*imag(Z))) .LT. 4.0)
Z = (Z * Z) + C
iter = iter + 1
if (iter .GE. maxiter) then
@@ -81,17 +93,22 @@ subroutine julia_colormapped(pic, cx, cy, maxiter)
endif
end do
if (over_iter) then
pic(ix, iy)%r = 0
pic(ix, iy)%g = mod(abs(int(real(Z) *140)), 255)
pic(ix, iy)%b = mod(abs(int(aimag(Z)*140)), 255)
pic(ix, iy)%r = mod(int(modulus2(Z)*2000.0), 255)
pic(ix, iy)%g = mod(abs(int(real(Z) *11.0)), 255)
pic(ix, iy)%b = mod(abs(int(aimag(Z)*11.0)), 255)
print *, ix, iy, Z, modulus2(Z)
over = over + 1
else
pic(ix, iy)%r = mod(iter*33, 255)
pic(ix, iy)%g = mod(iter*59, 255)
pic(ix, iy)%b = mod(iter*41, 255)
pic(ix, iy)%r = mod(iter*11, 255)
pic(ix, iy)%g = mod(iter*14, 255)
pic(ix, iy)%b = mod(iter*17, 255)
under = under + 1
endif
enddo ! iy
enddo ! ix
print *, "under", under, "over", over
end subroutine
!===============================================================
end module

27
Fraktalism/mkhenon.f90 Normal file
View File

@@ -0,0 +1,27 @@
program henon
use PIXRGB
implicit none
type(t_pixrgb), allocatable :: picz(:,:)
integer :: argc
character(200) :: filename, string
real :: cx, cy
argc = IARGC()
if (3 .NE. argc) then
STOP ": MKHENON PROGGY NEED 3 PARAMETERS !"
endif
call getarg(1, filename)
call getarg(2, string) ; read (string, *) cx
call getarg(3, string) ; read (string, *) cy
allocate(picz(1280, 1024))
call rgbpix_spit_as_pnm_8(picz, trim(filename))
!-----------------------------------------------------
end program

View File

@@ -26,11 +26,15 @@ program julia
call getarg(2, string) ; read (string, *) cx
call getarg(3, string) ; read (string, *) cy
allocate(picz(512, 342))
allocate(picz(1280, 1024))
call julia_colormapped(picz, cx, cy, 500)
call julia_colormapped(picz, cx, cy, 0.600, 1000)
call rgbpix_spit_as_pnm_8(picz, trim(filename))
contains
!-----------------------------------------------------
end program
!-----------------------------------------------------

View File

@@ -3,7 +3,6 @@
#
# build the prog
#
make mkjulia
if [ $? -ne 0 ] ; then
echo
@@ -11,28 +10,52 @@ if [ $? -ne 0 ] ; then
exit 1
fi
cxa=" -1.5432 " ; cya=" -0.8999 "
cxb=" 1.0975 " ; cyb=" 1.5091 "
nbi=" 2000 "
tmpimg="/dev/shm/juliatmp.pnm"
rm frames/julia/*
#
# run the prog
#
workdir="frames/julia/"
for foo in $(seq 0 179)
for foo in $( seq 0 $(( nbi - 1)) )
do
Ka=$( echo "$foo / $nbi" | bc -l)
Kb=$( echo "1.0 - $Ka" | bc -l)
# echo $Ka $Kb
cx=$(echo "($cxa*$Ka) + ($cxb*$Kb)" | bc -l)
cy=$(echo "$cya*$Ka + $cyb*$Kb" | bc -l)
img=$(printf "%s/%05d.pnm" $workdir $foo)
bar=$(echo "$foo / 247.0" | bc -l)
cx=$(echo "0.5 * (1.52*c($foo/28.0))" | bc -l)
cy=$(echo "0.5 * (1.45*s($foo/17.0))" | bc -l)
# make mkjulia
./mkjulia $img $cx $cy
printf "%5d %4.6f %4.6f %4.6f %4.6f\n" \
$foo $Ka $Kb $cx $cy
./mkjulia $tmpimg $cx $cy
echo
sleep 145
img=$(printf "%s/%05d.png" $workdir $foo)
tcx=$(printf "%8.6f" $cx)
tcy=$(printf "%8.6f" $cy)
convert $tmpimg \
-gravity North-East \
-font Courier-Bold \
-pointsize 20 \
-fill Yellow \
-annotate +15+34 $tcx \
-annotate +15+58 $tcy \
-gravity South-East \
-font Courier \
-pointsize 14 \
-fill Yellow \
-annotate +10+6 "Konrad+tTh 2024" \
$img
done
./tagpicz.sh $workdir
echo ; echo "Encoding, please wait..."
convert -delay 10 $workdir/*.pnm color-julia.gif
# animate foo.gif &
./encode.sh frames/julia/ foo.mp4

View File

@@ -17,10 +17,10 @@ do
mogrify \
-gravity South-East \
-font Courier \
-font Courier-Bold \
-pointsize 12 \
-fill firebrick \
-annotate +10+10 "Konrad+tTh 2023" \
-fill Black \
-annotate +10+4 "Konrad+tTh 2024" \
$img
echo "tagging " $img

2
GrafAnim/.gitignore vendored
View File

@@ -6,6 +6,7 @@ trigofest
noisepic
geowaves
soundscope
readpicz
*.scratch
*.genplot
@@ -16,4 +17,5 @@ F/*.tga
*.pgm
*.data
*.png
log.txt

View File

@@ -32,6 +32,9 @@ wavmetrics.o: wavmetrics.f90 Makefile
soundscope: soundscope.f90 Makefile utils_ga.o
gfortran $(GFOPT) $< $(MYLIB) utils_ga.o -o $@
readpicz: readpicz.f90 Makefile utils_ga.o
gfortran $(GFOPT) $< $(MYLIB) utils_ga.o -o $@
# ---- modules locaux ----
usegenplot.o: usegenplot.f90 Makefile

59
GrafAnim/readpicz.f90 Normal file
View File

@@ -0,0 +1,59 @@
program readpicz
use pixrgb
implicit none
integer :: nbarg
integer :: param0 = 10
character(len=256) :: arg
! integer :: foo, bar
integer :: width = 640
integer :: height = 480
integer :: x, y, r, g, b
integer :: errcode
character (len=280) :: filename
type(t_pixrgb), allocatable :: pix(:,:)
filename = "out.pnm"
nbarg = IARGC()
if (nbarg .GT. 0) then
call GETARG(1, arg)
! write (0, '(A40, A5)') "argument = ", arg
read (arg, *) param0
endif
allocate(pix(width, height))
do
!----- get a pixel
read(5, *, iostat=errcode) x, y, r, g, b
! print *, x, y
if (0 .NE. errcode) then
write(0, *) "iostat", errcode
exit
endif
if (mod(y, 2) .EQ. 1) then
pix(x+1, y+1)%r = g * 200
pix(x+1, y+1)%g = b * 200
pix(x+1, y+1)%b = r * 200
else
pix(x+1, y+1)%r = g * 200
pix(x+1, y+1)%g = r * 200
pix(x+1, y+1)%b = b * 200
endif
enddo
call rgbpix_spit_as_pnm_16(pix, trim(filename))
contains
! ----------------------------------------------------------
! ----------------------------------------------------------
end program

7
GrafAnim/t_readpicz.sh Executable file
View File

@@ -0,0 +1,7 @@
#!/bin/bash
tga_mires mircol0 mire.tga "Fortran Moderne"
tga_to_text foo.tga | ./readpicz

3
Modules/.gitignore vendored
View File

@@ -2,6 +2,9 @@
chkpixels
twavm
trnd
t_centermag
datas/
*.pgm
*.pnm

View File

@@ -6,7 +6,7 @@
GFOPT = -Wall -Wextra -g -I.
all: chkpixels trnd
all: chkpixels trnd twavm
# ---------------------------------------------------------

View File

@@ -2,6 +2,11 @@
module centermag
implicit none
!-----------------------------------------------------------------------
!-
! By definition, the default centermax (0, 0, 1) give us a
! (-1,-1), (1, 1) box, who is mapped to the screen size.
!-
!-----------------------------------------------------------------------
! definition of structures
!-
type t_centermag
@@ -13,16 +18,30 @@ type t_centermag
end type
!-------------------------------------------------------------------
contains
!-------------------------------------------------------------------
subroutine init_centermag(cntmag, w, h, mag)
type(t_centermag),intent(out) :: cntmag
integer, intent(in) :: w, h ! screen size
real, intent(in) :: mag
write(0, *) ">>> init centermag:", w, h
cntmag%wscr = w ; cntmag%hscr = h
cntmag%mag = mag
end subroutine
!-------------------------------------------------------------------
subroutine print_centermag (cm)
type(t_centermag), intent(in) :: cm
print *, "Screen ", cm%wscr, cm%hscr
print *, "MagFactor ", cm%mag
print *, "Center ", cm%cx, cm%cy
! print *, "Center ", cm%cx, cm%cy
end subroutine
!-------------------------------------------------------------------
!-------------------------------------------------------------------
subroutine centermag_scr2real (sx, sy, rx, ry)
integer, intent(in) :: sx, sy
real, intent(out) :: rx, ry

6
Modules/farbfeld.f90 Normal file
View File

@@ -0,0 +1,6 @@
!-
!-
! https://linuxfr.org/users/devnewton/liens/farbfeld-le-format-d-image-le-plus-simple-du-monde
! http://tools.suckless.org/farbfeld/
!-

View File

@@ -1,15 +1,9 @@
program t
use centermag
implicit none
type(t_centermag) :: cmag
print *, '====== programme de test ======'
cmag%wscr = 800
cmag%hscr = 600
print *, '====== programme de test centermag ======'
call essai_centermag(cmag)
print *
@@ -19,15 +13,13 @@ program t
contains
! --------------
subroutine essai_centermag(cm)
type(t_centermag), intent(in) :: cm
real :: rx, ry
type(t_centermag), intent(inout) :: cm
real :: rx, ry
call init_centermag(cm, 800, 600, 1.0)
call print_centermag (cm)
print *
call centermag_scr2real(1, 1, rx, ry)
print *, 'to real :', rx, ry
rx = 0.45 ; ry = -1.098
end subroutine
! --------------

11
Modules/test-wavm.sh Executable file
View File

@@ -0,0 +1,11 @@
#!/bin/bash
WAVE="datas/wave.wav"
# sndfile-info ${WAVE}
echo
wav2text ${WAVE} | ./twavm
echo

View File

@@ -1,4 +1,4 @@
program essai
program twavm
! new: Wed Feb 7 01:27:48 UTC 2024
@@ -6,9 +6,9 @@ program essai
use wavmetrics
implicit none
write(0, *) "----------------- essai -------------------"
write(0, *) "----------------- twavm -------------------"
call run_first_test(44100/30)
call run_second_test(44100/30)
contains
!-----------------------------------------------------------------------
@@ -35,5 +35,33 @@ subroutine run_first_test(nbs)
end subroutine
!-----------------------------------------------------------------------
!-----------------------------------------------------------------------
!-
!- we read the datas from stdin
!-
subroutine run_second_test(nbs)
integer, intent(in) :: nbs ! nombre d'echantillons
type(intsample), allocatable :: samples(:)
type(wavmetric) :: metrics
integer :: foo, bar
integer :: vl, vr
write(0, '(1X, "second test on ", I0, " samples.")') nbs
! create the buffer, and fill it with stdin
allocate(samples(nbs))
do foo=1, nbs
read(5, *) vl, vr
! print '(1X, 2I16)', vl, vr
samples(foo)%left = vl
samples(foo)%right = vr
enddo
! compute and display the metrics (gi-go)
call compute_wavmetric(samples, nbs, metrics)
call display_wavmetrics(metrics)
end subroutine
!-----------------------------------------------------------------------
end program

View File

@@ -48,7 +48,7 @@ subroutine compute_wavmetric(samples, size, metrics)
if (idx .GT. 1) then
if (diff_sign(samples(idx-1)%left, Lval)) Lfreq = Lfreq + 1
if (diff_sign(samples(idx-1)%right, Lval)) Rfreq = Rfreq + 1
if (diff_sign(samples(idx-1)%right, Rval)) Rfreq = Rfreq + 1
endif
Lsum = Lsum + Lval
@@ -56,7 +56,7 @@ subroutine compute_wavmetric(samples, size, metrics)
enddo
metrics%num = size
metrics%nbre = size
metrics%maxl = Lmax ; metrics%maxr = Rmax
metrics%freql = 1.0 / (Lfreq / real(size))
metrics%freqr = 1.0 / (Rfreq / real(size))
@@ -72,7 +72,7 @@ subroutine display_wavmetrics(metrics)
! print '(1X, "metrics are :")'
print '(1X, " | num ", I0)', metrics%num
print '(1X, " | nbre ", I0)', metrics%nbre
print '(1X, " | freq ", 2F12.2)', metrics%freql, metrics%freqr
print '(1X, " | mean ", 2F12.2)', metrics%meanl, metrics%meanr
print '(1X, " | maxi ", 2I8)', metrics%maxl, metrics%maxr