Compare commits

..

4 Commits

Author SHA1 Message Date
tTh c2d6abdedb more useless work done 2023-05-07 23:48:37 +02:00
tTh c47b99bf7d moving a module 2023-05-07 23:46:45 +02:00
tTh 5c4ff9133c add a "set to rgb" func 2023-05-07 21:27:52 +02:00
tTh 9366c67c4b color mode for noisepic 2023-05-07 20:23:33 +02:00
10 changed files with 153 additions and 60 deletions

View File

@ -21,7 +21,8 @@ trigofest: trigofest.f90 Makefile vue3axes.o utils_ga.o
utils_ga.o -o $@ utils_ga.o -o $@
noisepic: noisepic.f90 Makefile noisepic: noisepic.f90 Makefile
gfortran $(GFOPT) $< ../Modules/spitpgm.o -o $@ gfortran $(GFOPT) $< ../Modules/spitpgm.o ../Modules/pixrgb.o \
-o $@
# ---- modules locaux # ---- modules locaux

View File

@ -1,6 +1,7 @@
program noisepic program noisepic
use spitpgm use spitpgm
use pixrgb
implicit none implicit none
integer :: numframe = 0 integer :: numframe = 0
@ -16,12 +17,15 @@ program noisepic
read (arg, *) numframe read (arg, *) numframe
endif endif
call make_noise_pic(numframe) call make_noise_color_pic(numframe)
contains contains
!-- ------------------------------------------------------------------ !-- ------------------------------------------------------------------
subroutine make_noise_pic (value) !-
!- Black & White
!-
subroutine make_noise_bw_pic (value)
implicit none
integer, intent(in) :: value integer, intent(in) :: value
integer :: foo integer :: foo
@ -30,20 +34,20 @@ subroutine make_noise_pic (value)
allocate(pic(320, 240)) allocate(pic(320, 240))
pic = 0 pic = 30 !- clear the picz
call srand(value+34) call srand(value+34)
foo = irand() foo = irand()
print *, 'val=', value, ' rnd=', foo print *, 'val=', value, ' rnd=', foo
call plot_noise_pic(pic, 15000) call plot_noise_bw_pic(pic, 15000)
write (filename, "(a, i5.5, a)") "", value, ".pgm" write (filename, "(a, i5.5, a)") "", value, ".pgm"
call spit_as_pgm_8(pic, trim(filename)) call spit_as_pgm_8(pic, trim(filename))
end subroutine end subroutine
!-- ------------------------------------------------------------------ !-- ------------------------------------------------------------------
subroutine plot_noise_pic(picz, nbre) subroutine plot_noise_bw_pic(picz, nbre)
implicit none
integer, dimension(:,:), intent(inout) :: picz integer, dimension(:,:), intent(inout) :: picz
integer, intent(in) :: nbre integer, intent(in) :: nbre
@ -51,23 +55,63 @@ subroutine plot_noise_pic(picz, nbre)
integer :: width, height integer :: width, height
integer :: quux, ix, iy, iv integer :: quux, ix, iy, iv
width = ubound(picz, 1) ; height = ubound(picz, 2) width = ubound(picz, 1) ; height = ubound(picz, 2)
! print *, 'sz picz', width, height ! print *, 'sz picz', width, height
do quux=1, nbre do quux=1, nbre
ix = 1 + mod ( irand(), width ) ix = 1 + mod ( irand(), width )
iy = 1 + mod ( irand(), height ) iy = 1 + mod ( irand(), height )
iv = mod ( irand(), 256 ) iv = mod ( irand(), 256 )
! print *, ix, iy ! print *, ix, iy
picz(ix, iy) = iv picz(ix, iy) = iv
enddo
end subroutine
!-- ------------------------------------------------------------------
!-
!- Colorized
!-
subroutine make_noise_color_pic (value)
implicit none
integer, intent(in) :: value
integer :: foo
type(t_pixrgb), dimension(:,:), allocatable :: pix
character (len=280) :: filename
allocate(pix(320, 240))
call rgbpix_set_to_rgb(pix, 30, 30, 60)
call srand(value+34)
foo = irand()
print *, 'val=', value, ' rnd=', foo
call plot_noise_color_pic(pix, 15000)
write (filename, "(a, i5.5, a)") "./", value, ".pnm"
call rgbpix_spit_as_pnm_8(pix, trim(filename))
end subroutine
!-- ------------------------------------------------------------------
subroutine plot_noise_color_pic(prgb, nbre)
implicit none
type(t_pixrgb), dimension(:,:), intent(inout) :: prgb
integer, intent(in) :: nbre
integer :: quux, ix, iy, width, height
width = ubound(prgb, 1) ; height = ubound(prgb, 2)
do quux=1, nbre
ix = 1 + mod ( irand(), width )
iy = 1 + mod ( irand(), height )
prgb(ix, iy)%r = 64 + mod ( irand(), 127 )
prgb(ix, iy)%g = 64 + mod ( irand(), 127 )
prgb(ix, iy)%b = 64 + mod ( irand(), 127 )
enddo enddo
end subroutine end subroutine
!-- ------------------------------------------------------------------ !-- ------------------------------------------------------------------
end program end program

2
Modules/.gitignore vendored
View File

@ -1,5 +1,7 @@
chkpixels chkpixels
t
trnd
*.pgm *.pgm
*.pnm *.pnm

View File

@ -1,29 +1,44 @@
# #
# * Fortraneries * # * Fortraneries from tTh *
# #
# Makefile for the general purpose moduls # Makefile for the general purpose moduls
# #
GFOPT = -Wall -Wextra -time -g GFOPT = -Wall -Wextra -g -I.
all: chkpixels all: chkpixels t
# ----------------------------------------------- # -----------------------------------------------
spitpgm.o: spitpgm.f90 Makefile spitpgm.o: spitpgm.f90 Makefile
gfortran $(GFOPT) -c $< -o $@ gfortran $(GFOPT) -c $<
pixrgb.o: pixrgb.f90 Makefile pixrgb.o: pixrgb.f90 Makefile
gfortran $(GFOPT) -c $< -o $@ gfortran $(GFOPT) -c $<
centermag.o: centermag.f90 Makefile
gfortran $(GFOPT) -c $<
dummy.o: dummy.f90 Makefile
gfortran $(GFOPT) -c $<
trials.o: trials.f90 Makefile trials.o: trials.f90 Makefile
gfortran $(GFOPT) -c $< -o $@ gfortran $(GFOPT) -c $<
mathstuff2.o: mathstuff2.f90 Makefile
gfortran $(GFOPT) -c $<
# #
# programmes de testouille # programmes de testouille
# #
OBJS = trials.o spitpgm.o pixrgb.o OBJS = trials.o spitpgm.o pixrgb.o centermag.o dummy.o \
mathstuff2.o
chkpixels: chkpixels.f90 Makefile $(OBJS) chkpixels: chkpixels.f90 Makefile $(OBJS)
gfortran $(GFOPT) $< $(OBJS) -o $@ gfortran $(GFOPT) $< $(OBJS) -o $@
t: t.f90 Makefile $(OBJS)
gfortran $(GFOPT) $< $(OBJS) -o $@
trnd: trnd.f90 Makefile $(OBJS)
gfortran $(GFOPT) $< $(OBJS) -o $@

View File

@ -1,14 +1,29 @@
# General purpose modules # General purpose modules
## Compiler un module
## spitpgm Mmmmm...
## Modules disponibles
### spitpgm
Write gray level 2d buffer (aka picture) to disk in the NetPNM format. Write gray level 2d buffer (aka picture) to disk in the NetPNM format.
## pixrgb ### pixrgb
Write 8 bits RGB pictures to PNM format. Write 8 bits RGB pictures to PNM format.
## trials ### trials
Experimental WIPs from hell. Experimental WIPs from hell.
### dummy
A "do nothing" useless module. But you cas use it to fool an optimizing
compiler, or have a sane place to put a breakpoint with gdb
## TODO
- écrire la doc !

View File

@ -1,5 +1,6 @@
!- !-
! This module try to write PNM complient RGB files ! This module try to write PNM complient RGB files
! ONLY ASCII MODE IS SUPPORTED !
!- !-
module pixrgb module pixrgb
implicit none implicit none
@ -26,6 +27,23 @@ subroutine rgbpix_set_to_zero(pic)
enddo enddo
enddo enddo
end subroutine end subroutine
!-------------------------------------------------------------------
!-
! set all the pixels to a RGB value
!-
subroutine rgbpix_set_to_rgb(pic, r, g, b)
type(t_pixrgb), intent(out) :: pic(:,:)
integer, intent(in) :: r, g, b
integer :: ix, iy
do iy=1, ubound(pic, 2)
do ix=1, ubound(pic, 1)
pic(ix, iy)%r = r
pic(ix, iy)%g = g
pic(ix, iy)%b = b
enddo
enddo
end subroutine
!------------------------------------------------------------------- !-------------------------------------------------------------------
!- !-
! NOT TESTED !!! ! NOT TESTED !!!

35
Modules/t.f90 Normal file
View File

@ -0,0 +1,35 @@
program t
use centermag
implicit none
type(t_centermag) :: cmag
print *, '====== programme de test ======'
cmag%wscr = 800
cmag%hscr = 600
call essai_centermag(cmag)
print *
STOP ': PAF LE CHIEN ?'
! --------------
contains
! --------------
subroutine essai_centermag(cm)
type(t_centermag), intent(in) :: cm
real :: rx, ry
call print_centermag (cm)
print *
call centermag_scr2real(1, 1, rx, ry)
print *, 'to real :', rx, ry
end subroutine
! --------------
end program

View File

@ -4,17 +4,13 @@
GFOPT = -Wall -Wextra -g -time GFOPT = -Wall -Wextra -g -time
all: essai displaykinds all: displaykinds
# ----------------------------------------------------- # -----------------------------------------------------
mathstuff2.o: mathstuff2.f90 Makefile
gfortran $(GFOPT) -c $<
# ----------------------------------------------------- # -----------------------------------------------------
essai: essai.f90 Makefile mathstuff2.o
gfortran $(GFOPT) $< mathstuff2.o -o $@
displaykinds: displaykinds.f90 Makefile displaykinds: displaykinds.f90 Makefile
gfortran $(GFOPT) $< -o $@ gfortran $(GFOPT) $< -o $@

View File

@ -1,33 +0,0 @@
module mathstuff2
! XXX This module was a copy of mathstuff.f90 fromthe BloubWorld
! XXX wil be moved in an other place some day...
implicit none
contains
! ----------------------------------------------------------------
! really quick'n'dirty hack
! not really tested yet...
subroutine init_random_seed()
integer, dimension(3) :: tarray
integer :: t3, foo
real :: dummy
call itime(tarray)
t3 = 3600*tarray(1) + 60*tarray(2) + tarray(3)
! write(0, '(A,3I3,A,I6)') "sranding: ", tarray, " --> ", t3
call srand(t3)
! after initializing the random generator engine,
! you MUST use it for initializing the initializer
do foo=1, tarray(1)+5
dummy = rand()
enddo
end subroutine
! ----------------------------------------------------------------
end module mathstuff2