2023-02-11 20:29:07 +01:00
|
|
|
! -------------------------------------------------------------------
|
|
|
|
!- 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
|
|
|
|
|
2023-12-24 20:53:27 +01:00
|
|
|
foo = int((rand()*hilevel)/2)
|
|
|
|
bar = int((rand()*hilevel)/2)
|
2023-02-11 20:29:07 +01:00
|
|
|
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
|
|
|
|
! -------------------------------------------------------------------
|
|
|
|
|
2023-12-24 20:53:27 +01:00
|
|
|
subroutine dim_pix_rgb(pix, k)
|
|
|
|
type(t_pixrgb), intent(inout) :: pix(:,:)
|
|
|
|
integer,intent(in) :: k
|
|
|
|
integer :: ix, iy
|
|
|
|
|
|
|
|
! write(0, *) "dim pixrgb", k
|
|
|
|
|
|
|
|
do ix=1, ubound(pix, 1)
|
|
|
|
do iy=1, ubound(pix, 2)
|
|
|
|
if (pix(ix,iy)%r .GT. k) then
|
|
|
|
pix(ix,iy)%r = pix(ix,iy)%r - k
|
|
|
|
endif
|
|
|
|
if (pix(ix,iy)%g .GT. k) then
|
|
|
|
pix(ix,iy)%g = pix(ix,iy)%g - k
|
|
|
|
endif
|
|
|
|
if (pix(ix,iy)%b .GT. k) then
|
|
|
|
pix(ix,iy)%b = pix(ix,iy)%b - k
|
|
|
|
endif
|
|
|
|
enddo
|
|
|
|
enddo
|
|
|
|
|
|
|
|
end subroutine
|
|
|
|
! -------------------------------------------------------------------
|
2023-02-11 20:29:07 +01:00
|
|
|
end module
|