Compare commits
5 Commits
11d1cfd7de
...
87ff3d8815
Author | SHA1 | Date | |
---|---|---|---|
|
87ff3d8815 | ||
|
c05d80a223 | ||
|
18ec65d612 | ||
|
5f2013d4d7 | ||
|
f05bc14461 |
@ -9,8 +9,8 @@ qui montre ma première expérience dans ce domaine.
|
||||
## La technique
|
||||
|
||||
Le gros des calculs de fractales est fait dans `mods/fraktals.f90`,
|
||||
et la gestion des pixels 'physiques' est faite par le
|
||||
module externe `spitpgm`.
|
||||
et la gestion des pixels 'physiques' est faite par les
|
||||
modules externes `spitpgm` et `pixrgb`.
|
||||
|
||||
Les fonctions d'usage général sont dans
|
||||
[mods/](répertoire mods/) ave trop peu
|
||||
@ -38,3 +38,6 @@ Generally writen as a *sequencial unformated* file.
|
||||
- Rajouter des formules
|
||||
- Ne pas procastiner sur le reste
|
||||
|
||||
## See also
|
||||
|
||||
- https://www.maths.town/fractal-articles/mandelbulb/mandelbulb-all-powers/
|
||||
|
@ -153,5 +153,4 @@ function modulus2(pt)
|
||||
modulus2 = real(pt)*real(pt) + imag(pt)*imag(pt)
|
||||
end
|
||||
!-----------------------------------------------------
|
||||
|
||||
end module fraktals
|
||||
|
@ -25,7 +25,6 @@ program henon
|
||||
!-----------------------------------------------------
|
||||
contains
|
||||
!-----------------------------------------------------
|
||||
|
||||
!-----------------------------------------------------
|
||||
subroutine compute_pixel_henon(a, b, maxpasse, passe, limit, rx, ry)
|
||||
implicit none
|
||||
|
@ -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
|
||||
|
||||
!-----------------------------------------------------
|
@ -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
|
||||
|
||||
!-----------------------------------------------------
|
@ -8,8 +8,6 @@ module xperiment
|
||||
|
||||
subroutine parasites_1(pic, cx, cy, maxiter)
|
||||
implicit none
|
||||
|
||||
! here is the wtf
|
||||
integer, intent(inout), dimension (:,:) :: pic
|
||||
|
||||
real, intent(in) :: cx, cy
|
||||
@ -23,22 +21,18 @@ subroutine parasites_1(pic, cx, cy, maxiter)
|
||||
|
||||
width = ubound(pic, 1) ; height = ubound(pic, 2)
|
||||
coef = float(maxiter)
|
||||
|
||||
do ix = 1, width
|
||||
fx = cx + (float(ix) / (float(width)/4.0) - 2.0)
|
||||
burps = (RAND() .lt. 0.01)
|
||||
do iy = 1, height
|
||||
fy = cy + (float(iy) / (float(height)/4.0) - 2.0)
|
||||
|
||||
if (burps) then
|
||||
pic(ix, iy) = int(fx * fy * coef * 1.005)
|
||||
else
|
||||
pic(ix, iy) = int(fx * fy * coef)
|
||||
endif
|
||||
|
||||
enddo
|
||||
enddo
|
||||
|
||||
end subroutine parasites_1
|
||||
|
||||
!---------------------------------------------------------------
|
||||
@ -52,13 +46,9 @@ subroutine loop_of_parasites_1(nbre, mode)
|
||||
integer :: idx
|
||||
|
||||
if (mode .NE. 0) STOP "BAD MODE"
|
||||
|
||||
do idx = 0, nbre
|
||||
|
||||
write(0, *) "popcorn loop ", idx
|
||||
|
||||
enddo
|
||||
|
||||
end subroutine loop_of_parasites_1
|
||||
|
||||
!===============================================================
|
||||
|
@ -13,6 +13,8 @@ un peu foireux sur les tracés de ligne...
|
||||
|
||||
Distorsions approximatives de la courbe de Lissajous.
|
||||
|
||||
Expériences inspirées par https://bleuje.com/tutorial1/ que c'est d'la balle !
|
||||
|
||||
## doubledice
|
||||
|
||||
Ou comment dessiner des gaussiennes.
|
||||
|
@ -1,9 +1,61 @@
|
||||
program doubledice
|
||||
use usegenplot
|
||||
use utils_ga
|
||||
|
||||
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
|
||||
|
33
GrafAnim/doublegauss.f90
Normal file
33
GrafAnim/doublegauss.f90
Normal 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
19
GrafAnim/runme.sh
Executable 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
|
@ -3,26 +3,40 @@ module usegenplot
|
||||
implicit none
|
||||
|
||||
integer, private :: color = 4
|
||||
integer, private :: iochannel = -1
|
||||
logical, private :: initialised = .FALSE.
|
||||
|
||||
contains
|
||||
|
||||
! -------------------------------------------------------------------
|
||||
|
||||
subroutine init_genplot(filename)
|
||||
|
||||
character(*), intent(in) :: filename
|
||||
|
||||
integer :: errcode
|
||||
|
||||
write(0, *) '--> init genplot "', filename, '"'
|
||||
open(newunit=iochannel, file=filename, iostat=errcode)
|
||||
write(0, *) 'iochannel', iochannel, 'errcode', errcode
|
||||
|
||||
initialised = .TRUE.
|
||||
color = 4
|
||||
|
||||
! XXX STOP 'ABEND'
|
||||
|
||||
end subroutine
|
||||
|
||||
subroutine end_genplot(message)
|
||||
|
||||
character(*), intent(in) :: message
|
||||
|
||||
integer :: errcode
|
||||
|
||||
write(0, *) '--> end genplot "', message, '"'
|
||||
initialised = .FALSE.
|
||||
|
||||
close(unit=iochannel, iostat=errcode)
|
||||
write(0, *) 'close errcode', errcode
|
||||
|
||||
end subroutine
|
||||
|
||||
! -------------------------------------------------------------------
|
||||
@ -38,7 +52,7 @@ subroutine do_initialise_once(motif)
|
||||
end subroutine
|
||||
|
||||
! -------------------------------------------------------------------
|
||||
|
||||
!- getter, setter, wtf ?
|
||||
subroutine gplt_setcol(col)
|
||||
integer, intent(in) :: col
|
||||
color = col
|
||||
@ -55,8 +69,7 @@ subroutine gplt_move(x, y)
|
||||
if (.NOT. initialised) then
|
||||
call do_initialise_once('in gplt_move')
|
||||
endif
|
||||
|
||||
print *, x, y, 0
|
||||
write(iochannel, '(3I8)') x, y, 0
|
||||
end subroutine
|
||||
|
||||
! -------------------------------------------------------------------
|
||||
@ -66,7 +79,7 @@ subroutine gplt_draw(x, y)
|
||||
if (.NOT. initialised) then
|
||||
call do_initialise_once('in gplt_draw')
|
||||
endif
|
||||
print *, x, y, color
|
||||
write(iochannel, '(3I8)') x, y, color
|
||||
end subroutine
|
||||
|
||||
! -------------------------------------------------------------------
|
||||
@ -78,10 +91,23 @@ subroutine gplt_line(x1, y1, x2, y2)
|
||||
end subroutine
|
||||
|
||||
! -------------------------------------------------------------------
|
||||
!-
|
||||
! sx, sy
|
||||
! +-------------------+
|
||||
! | x2,y2 |
|
||||
! | |
|
||||
! | |
|
||||
! | x1,y1 |
|
||||
! +-------------------+
|
||||
! 0,0
|
||||
|
||||
subroutine gplt_rect(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_draw(x2, y1)
|
||||
call gplt_draw(x2, y2)
|
||||
|
41
GrafAnim/utils_ga.f90
Normal file
41
GrafAnim/utils_ga.f90
Normal 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
12
GrafAnim/vue3axes.f90
Normal file
@ -0,0 +1,12 @@
|
||||
module vue3axes
|
||||
use pixrgb
|
||||
implicit none
|
||||
!-------------------------------------------------------------
|
||||
|
||||
|
||||
!-------------------------------------------------------------
|
||||
!-
|
||||
!- ouf, c'est fini
|
||||
!-
|
||||
end module
|
||||
|
@ -16,6 +16,10 @@ l'existence des _pointeurs_ compense largement.
|
||||
- [RandomStuff](RandomStuff/) : on a tous droit à notre jardin secret
|
||||
- [GrafAnim](GrafAnim/) : Ah, enfin de la gif89a en vue !
|
||||
|
||||
## Prérequis
|
||||
|
||||
- GNUtrucs : bash, make, awk...
|
||||
|
||||
## hotline
|
||||
|
||||
- Le canal `#tetalab` sur le réseau IRC de
|
||||
|
@ -65,6 +65,12 @@ while (2==fscanf(input, "%d %d", &left, &right)) {
|
||||
buffer[idx++] = left;
|
||||
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) {
|
||||
/* flush buffer to file */
|
||||
sf_write_short(sndf, buffer, idx);
|
||||
|
@ -6,6 +6,10 @@ module soundbrotch
|
||||
integer :: left
|
||||
integer :: right
|
||||
end type
|
||||
type t_sample2r
|
||||
real :: left
|
||||
real :: right
|
||||
end type
|
||||
! ---------------------------------------------------------
|
||||
! some private variables
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user