Compare commits

..

5 Commits

Author SHA1 Message Date
tTh
87ff3d8815 minor changes also here 2023-02-11 20:29:07 +01:00
tTh
c05d80a223 minor changes 2023-02-11 20:28:05 +01:00
tTh
18ec65d612 add gnu deps 2023-02-11 19:42:34 +01:00
tTh
5f2013d4d7 convert integer -> float 2023-02-11 19:41:30 +01:00
tTh
f05bc14461 add molly-guard 2023-02-11 19:40:52 +01:00
16 changed files with 213 additions and 87 deletions

View File

@ -9,8 +9,8 @@ qui montre ma première expérience dans ce domaine.
## La technique ## La technique
Le gros des calculs de fractales est fait dans `mods/fraktals.f90`, Le gros des calculs de fractales est fait dans `mods/fraktals.f90`,
et la gestion des pixels 'physiques' est faite par le et la gestion des pixels 'physiques' est faite par les
module externe `spitpgm`. modules externes `spitpgm` et `pixrgb`.
Les fonctions d'usage général sont dans Les fonctions d'usage général sont dans
[mods/](répertoire mods/) ave trop peu [mods/](répertoire mods/) ave trop peu
@ -38,3 +38,6 @@ Generally writen as a *sequencial unformated* file.
- Rajouter des formules - Rajouter des formules
- Ne pas procastiner sur le reste - Ne pas procastiner sur le reste
## See also
- https://www.maths.town/fractal-articles/mandelbulb/mandelbulb-all-powers/

View File

@ -153,5 +153,4 @@ function modulus2(pt)
modulus2 = real(pt)*real(pt) + imag(pt)*imag(pt) modulus2 = real(pt)*real(pt) + imag(pt)*imag(pt)
end end
!----------------------------------------------------- !-----------------------------------------------------
end module fraktals end module fraktals

View File

@ -8,7 +8,7 @@ program henon
integer :: w, h integer :: w, h
integer :: foo, bar integer :: foo, bar
double precision :: px, py double precision :: px, py
w = 2000 ; h=1600 w = 2000 ; h = 1600
write(0, *) "###### Mapping of Henon " write(0, *) "###### Mapping of Henon "
@ -25,7 +25,6 @@ program henon
!----------------------------------------------------- !-----------------------------------------------------
contains contains
!----------------------------------------------------- !-----------------------------------------------------
!----------------------------------------------------- !-----------------------------------------------------
subroutine compute_pixel_henon(a, b, maxpasse, passe, limit, rx, ry) subroutine compute_pixel_henon(a, b, maxpasse, passe, limit, rx, ry)
implicit none implicit none

View File

@ -1,33 +0,0 @@
!-----------------------------------------------------
! JULIA
! =====
! this is the main program
!-----------------------------------------------------
program julia
use spitpgm
use fraktals
implicit none
integer, dimension(512, 342) :: 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, 2500)
call spit_as_pgm_8(picz, trim(filename))
end program
!-----------------------------------------------------

View File

@ -1,31 +0,0 @@
!
! this is the main programm
!
!-----------------------------------------------------
program lorentz
use spitpgm
use fraktals
implicit none
integer, dimension(800, 600) :: picz
integer :: argc
character(200) :: filename
argc = IARGC()
if (1 .NE. argc) then
STOP ": LORENTZ NEED A FILENAME !"
endif
call getarg(1, filename)
write (0, "(A)") "Lorentz -> "//trim(filename)
call lorentz_0(picz, 50000)
call spit_as_pgm_8(picz, trim(filename))
end program
!-----------------------------------------------------

View File

@ -8,8 +8,6 @@ module xperiment
subroutine parasites_1(pic, cx, cy, maxiter) subroutine parasites_1(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
@ -23,22 +21,18 @@ subroutine parasites_1(pic, cx, cy, maxiter)
width = ubound(pic, 1) ; height = ubound(pic, 2) width = ubound(pic, 1) ; height = ubound(pic, 2)
coef = float(maxiter) coef = float(maxiter)
do ix = 1, width do ix = 1, width
fx = cx + (float(ix) / (float(width)/4.0) - 2.0) fx = cx + (float(ix) / (float(width)/4.0) - 2.0)
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) = int(fx * fy * coef * 1.005) pic(ix, iy) = int(fx * fy * coef * 1.005)
else else
pic(ix, iy) = int(fx * fy * coef) pic(ix, iy) = int(fx * fy * coef)
endif endif
enddo enddo
enddo enddo
end subroutine parasites_1 end subroutine parasites_1
!--------------------------------------------------------------- !---------------------------------------------------------------
@ -52,13 +46,9 @@ subroutine loop_of_parasites_1(nbre, mode)
integer :: idx integer :: idx
if (mode .NE. 0) STOP "BAD MODE" if (mode .NE. 0) STOP "BAD MODE"
do idx = 0, nbre do idx = 0, nbre
write(0, *) "popcorn loop ", idx write(0, *) "popcorn loop ", idx
enddo enddo
end subroutine loop_of_parasites_1 end subroutine loop_of_parasites_1
!=============================================================== !===============================================================

View File

@ -13,6 +13,8 @@ un peu foireux sur les tracés de ligne...
Distorsions approximatives de la courbe de Lissajous. Distorsions approximatives de la courbe de Lissajous.
Expériences inspirées par https://bleuje.com/tutorial1/ que c'est d'la balle !
## doubledice ## doubledice
Ou comment dessiner des gaussiennes. Ou comment dessiner des gaussiennes.

View File

@ -1,9 +1,61 @@
program doubledice program doubledice
use usegenplot use usegenplot
use utils_ga
implicit none implicit none
call init_genplot("essai.genplot") integer :: nbarg, numframe
character(len=256) :: arg
integer :: idx, foo, bar, xpos
integer :: buckets(12)
call end_genplot("OK boomer") nbarg = IARGC()
if (nbarg .GT. 0) then
call GETARG(1, arg)
! write (0, '(A40, A5)') "argument = ", arg
read (arg, *) numframe
endif
write(0, '(" ------------- DOUBLE DICE ----------")')
write(0, '(" --> frame number:", I5)') numframe
call init_genplot("dummy.genplot")
call gplt_rect(0, 0, 800, 600)
call gplt_setcol(3)
call gplt_rect(8, 8, 48, 38)
call gplt_setcol(2)
buckets = 0
do idx=1, numframe
call jouer_un_tour(buckets, idx)
foo = maxval(buckets)
! write(0, *) "max value", foo
enddo
call gplt_line(5, 40, 795, 40)
do bar=1, 12
xpos = bar*50 + 25
! write(0, *) bar, xpos, buckets(bar)
call gplt_rect(xpos, 41, xpos+50, 41+15*buckets(bar))
enddo
call end_genplot("OK boomer...")
contains
! ---------------------------------------------------------
subroutine jouer_un_tour(table, compte)
integer,intent(inout) :: table(12)
integer, intent(in) :: compte
integer :: DA, DB, valeur
DA = fair_random_dice()
DB = fair_random_dice()
valeur = DA + DB
! write(0, *) "pass ", compte, " = ", DA, DB, valeur
table(valeur) = table(valeur) + 1
end subroutine
end program end program

33
GrafAnim/doublegauss.f90 Normal file
View File

@ -0,0 +1,33 @@
program doublegauss
use pixrgb
use utils_ga
implicit none
type(t_pixrgb), allocatable :: pic(:,:)
character (len=80) :: filename
integer :: pass, iter
integer :: xrnd, yrnd
write(0, *) "----- making a doublegauss picture ----"
allocate(pic(320, 240))
call rgbpix_set_to_zero(pic)
do pass=0, 99
do iter=1, 15000
xrnd = fair_random_gauss(320)
yrnd = fair_random_gauss(240)
! print *, xrnd, yrnd
pic(xrnd,yrnd)%r = pic(xrnd,yrnd)%r + 1
pic(xrnd,yrnd)%g = pic(xrnd,yrnd)%g + 2
pic(xrnd,yrnd)%b = pic(xrnd,yrnd)%b + 3
end do
write (filename, "(a, i5.5, a)") "F/DBG/", pass, ".pnm"
print *, trim(filename)
call rgbpix_spit_as_pnm_8 (pic, trim(filename))
end do
end program

19
GrafAnim/runme.sh Executable file
View File

@ -0,0 +1,19 @@
#!/bin/bash
set -e
SCRATCH="dummy.genplot"
make doubledice
rm -f F/????.tga
for foo in $(seq 1 250)
do
rm -f dummy.genplot
./doubledice $foo
filename=$(printf "F/%04d.tga" $foo)
genplot2 -s 640x480 ${SCRATCH} $filename
done
convert -delay 10 F/????.tga foo.gif

View File

@ -3,26 +3,40 @@ module usegenplot
implicit none implicit none
integer, private :: color = 4 integer, private :: color = 4
integer, private :: iochannel = -1
logical, private :: initialised = .FALSE. logical, private :: initialised = .FALSE.
contains contains
! ------------------------------------------------------------------- ! -------------------------------------------------------------------
subroutine init_genplot(filename) subroutine init_genplot(filename)
character(*), intent(in) :: filename character(*), intent(in) :: filename
integer :: errcode
write(0, *) '--> init genplot "', filename, '"' write(0, *) '--> init genplot "', filename, '"'
open(newunit=iochannel, file=filename, iostat=errcode)
write(0, *) 'iochannel', iochannel, 'errcode', errcode
initialised = .TRUE. initialised = .TRUE.
color = 4 color = 4
! XXX STOP 'ABEND'
end subroutine end subroutine
subroutine end_genplot(message) subroutine end_genplot(message)
character(*), intent(in) :: message character(*), intent(in) :: message
integer :: errcode
write(0, *) '--> end genplot "', message, '"' write(0, *) '--> end genplot "', message, '"'
initialised = .FALSE. initialised = .FALSE.
close(unit=iochannel, iostat=errcode)
write(0, *) 'close errcode', errcode
end subroutine end subroutine
! ------------------------------------------------------------------- ! -------------------------------------------------------------------
@ -38,7 +52,7 @@ subroutine do_initialise_once(motif)
end subroutine end subroutine
! ------------------------------------------------------------------- ! -------------------------------------------------------------------
!- getter, setter, wtf ?
subroutine gplt_setcol(col) subroutine gplt_setcol(col)
integer, intent(in) :: col integer, intent(in) :: col
color = col color = col
@ -55,8 +69,7 @@ subroutine gplt_move(x, y)
if (.NOT. initialised) then if (.NOT. initialised) then
call do_initialise_once('in gplt_move') call do_initialise_once('in gplt_move')
endif endif
write(iochannel, '(3I8)') x, y, 0
print *, x, y, 0
end subroutine end subroutine
! ------------------------------------------------------------------- ! -------------------------------------------------------------------
@ -66,7 +79,7 @@ subroutine gplt_draw(x, y)
if (.NOT. initialised) then if (.NOT. initialised) then
call do_initialise_once('in gplt_draw') call do_initialise_once('in gplt_draw')
endif endif
print *, x, y, color write(iochannel, '(3I8)') x, y, color
end subroutine end subroutine
! ------------------------------------------------------------------- ! -------------------------------------------------------------------
@ -78,10 +91,23 @@ subroutine gplt_line(x1, y1, x2, y2)
end subroutine end subroutine
! ------------------------------------------------------------------- ! -------------------------------------------------------------------
!-
! sx, sy
! +-------------------+
! | x2,y2 |
! | |
! | |
! | x1,y1 |
! +-------------------+
! 0,0
subroutine gplt_rect(x1, y1, x2, y2) subroutine gplt_rect(x1, y1, x2, y2)
integer, intent(in) :: x1, y1, x2, y2 integer, intent(in) :: x1, y1, x2, y2
if (.NOT. initialised) then
call do_initialise_once('in gplt_rect')
endif
call gplt_move(x1, y1) call gplt_move(x1, y1)
call gplt_draw(x2, y1) call gplt_draw(x2, y1)
call gplt_draw(x2, y2) call gplt_draw(x2, y2)

41
GrafAnim/utils_ga.f90 Normal file
View File

@ -0,0 +1,41 @@
! -------------------------------------------------------------------
!- fonctions diverses pour faire des images bizarres
! -------------------------------------------------------------------
module utils_ga
use pixrgb
implicit none
contains
! -------------------------------------------------------------------
function fair_random_dice()
integer :: fair_random_dice
fair_random_dice = 1 + int(rand()*6.0)
end function
! -------------------------------------------------------------------
! usage --> see doublegauss.f90
function fair_random_gauss(hilevel)
integer, intent(in) :: hilevel
integer :: fair_random_gauss
integer :: foo, bar
foo = int(rand()*hilevel/2)
bar = int(rand()*hilevel/2)
fair_random_gauss = 1 + foo + bar
end function
! -------------------------------------------------------------------
! usage --> see doublegauss.f90
subroutine increment_pixel(pix, k)
type(t_pixrgb), intent(inout) :: pix
integer :: k
end subroutine
! -------------------------------------------------------------------
end module

12
GrafAnim/vue3axes.f90 Normal file
View File

@ -0,0 +1,12 @@
module vue3axes
use pixrgb
implicit none
!-------------------------------------------------------------
!-------------------------------------------------------------
!-
!- ouf, c'est fini
!-
end module

View File

@ -16,6 +16,10 @@ l'existence des _pointeurs_ compense largement.
- [RandomStuff](RandomStuff/) : on a tous droit à notre jardin secret - [RandomStuff](RandomStuff/) : on a tous droit à notre jardin secret
- [GrafAnim](GrafAnim/) : Ah, enfin de la gif89a en vue ! - [GrafAnim](GrafAnim/) : Ah, enfin de la gif89a en vue !
## Prérequis
- GNUtrucs : bash, make, awk...
## hotline ## hotline
- Le canal `#tetalab` sur le réseau IRC de - Le canal `#tetalab` sur le réseau IRC de

View File

@ -65,6 +65,12 @@ while (2==fscanf(input, "%d %d", &left, &right)) {
buffer[idx++] = left; buffer[idx++] = left;
buffer[idx++] = right; buffer[idx++] = right;
/* SANITY CONTROL */
if ( (abs(left) > 32767) || (abs(right) > 32767) ) {
fprintf(stderr, "OVERFLOW sample %9d values %7d %7d\n",
idx, left, right);
}
if (idx >= SMPL_COUNT) { if (idx >= SMPL_COUNT) {
/* flush buffer to file */ /* flush buffer to file */
sf_write_short(sndf, buffer, idx); sf_write_short(sndf, buffer, idx);

View File

@ -6,6 +6,10 @@ module soundbrotch
integer :: left integer :: left
integer :: right integer :: right
end type end type
type t_sample2r
real :: left
real :: right
end type
! --------------------------------------------------------- ! ---------------------------------------------------------
! some private variables ! some private variables