TetaTricks/code/fortran/dessiner.f90

123 lines
3.3 KiB
Fortran
Raw Normal View History

2023-03-08 06:49:36 +11:00
program dessiner
use plplot
implicit none
2023-03-21 10:16:54 +11:00
integer :: i
2023-03-08 06:49:36 +11:00
character(len=80) :: version
call plgver(version)
2024-03-11 12:20:47 +11:00
write (*,'(" ",a,a)') 'plPlot version: ', trim(version)
2023-03-08 06:49:36 +11:00
2024-03-11 12:20:47 +11:00
call dessin_X11 (0.12, 1.51, 11)
!! call dessin_dans_un_fichier ()
2023-03-08 06:49:36 +11:00
2023-03-21 10:16:54 +11:00
contains ! -----------------------------
!------------------------------------------------------
2023-04-03 08:32:29 +11:00
!- __ __ _
!- \ \/ / __ __ (_) _ __
!- \ / \ \ /\ / / | | | '_ \
!- / \ \ V V / | | | | | |
!- /_/\_\ \_/\_/ |_| |_| |_|
!-
2023-03-22 01:03:09 +11:00
subroutine dessin_X11 (sha, shb, color)
2023-03-21 10:16:54 +11:00
real, intent(in) :: sha, shb
integer, intent(in) :: color
2023-03-08 06:49:36 +11:00
2023-03-21 10:16:54 +11:00
integer, parameter :: lg = 2000
2023-03-08 06:49:36 +11:00
real :: x(lg), y(lg)
2023-03-21 10:16:54 +11:00
real :: k, amp
2023-03-08 06:49:36 +11:00
integer :: i
2023-03-22 01:03:09 +11:00
print *, 'dessin X11:', sha, shb, color
call plsdev('xwin')
call plinit ()
2024-03-11 12:20:47 +11:00
call plenv (-2.5, 2.5, -2.5, 2.5, 1, 2)
2023-03-22 01:03:09 +11:00
2024-03-11 12:20:47 +11:00
amp = 2.06
2023-03-08 06:49:36 +11:00
do i = 1, lg
2024-03-11 12:20:47 +11:00
k = real(i)/real(lg) * 6.2832 * 2.0
x(i) = amp * sin((k+sha))
y(i) = amp * cos((k+shb))
2023-03-08 06:49:36 +11:00
enddo
2023-03-21 10:16:54 +11:00
! print *, k, x(i), y(i)
2023-03-08 06:49:36 +11:00
call plcol0 (15) ! pure white
call pllab ("Fuzzfactor", "Yoyodines", "Some nice plots from tTh")
2023-03-21 10:16:54 +11:00
call plcol0 (color)
2023-03-08 06:49:36 +11:00
call plline (x, y)
2023-04-03 08:32:29 +11:00
call plend ()
2023-03-22 01:03:09 +11:00
2023-03-08 06:49:36 +11:00
end subroutine
2023-03-21 10:16:54 +11:00
!------------------------------------------------------
2023-03-22 01:03:09 +11:00
!- _ __ ___ ___ ___
!- __ _ (_) / _| ( _ ) / _ \ __ _ |__ \
!- / _` | | | | |_ / _ \ | (_) | / _` | / /
!- | (_| | | | | _| | (_) | \__, | | (_| | |_|
!- \__, | |_| |_| \___/ /_/ \__,_| (_)
!- |___/
subroutine dessin_dans_un_fichier ()
2023-04-03 08:32:29 +11:00
integer, parameter :: nbpts = 20
real, parameter :: usz = 15.0 ! univers size
2023-03-22 01:03:09 +11:00
real :: x(nbpts), y(nbpts)
integer :: frame, i
character(len=89) :: filename
character(len=89) :: buffer
character(len=3) :: str
print *, 'Dessin dans un fichier'
do i=1, nbpts
2023-04-03 08:32:29 +11:00
x(i) = usz * (rand() - 0.5000)
y(i) = usz * (rand() - 0.5000) * 0.50
2023-03-22 01:03:09 +11:00
enddo
2023-04-03 08:32:29 +11:00
do frame= 0, 119
2023-03-22 01:03:09 +11:00
write (filename, "(a, i4.4, a)") "WS/A", frame, ".png"
print *, frame, ' => ', trim(filename)
call plsdev ('pngcairo')
call plsfnam (trim(filename))
call plinit ()
call plenv (-10., 10., -10., 10., 0, 1)
call plcol0 (3)
do i=1, nbpts
2023-04-03 08:32:29 +11:00
x(i) = x(i) + 1.2 * (rand() - 0.5000)
y(i) = y(i) + 1.2 * (rand() - 0.5000)
2023-03-22 01:03:09 +11:00
call plline (x, y)
enddo
write(buffer, "(i3.3)") frame
str = trim(buffer)
call plcol0 (15)
call plstring (x, y, buffer)
2023-04-03 08:32:29 +11:00
call plend ()
2023-03-22 01:03:09 +11:00
enddo
2023-04-03 08:32:29 +11:00
end subroutine
!------------------------------------------------------
!- _ _ ____
!- | |_ _ __ ___ (_) | _ \
!- | __| | '__| / _ \ | | | | | |
!- | |_ | | | (_) | | | | |_| |
!- \__| |_| \___/ |_| |____/
!-
subroutine dessiner_en_trois_D ()
integer, parameter :: szgrid = 64
integer :: i, j
2023-03-21 10:16:54 +11:00
2023-04-03 08:32:29 +11:00
print *, 'Dessin en 3D (de merde :)'
call plsdev ('xwin')
call plinit ()
call plend ()
2023-03-21 10:16:54 +11:00
end subroutine
!------------------------------------------------------
2023-03-08 06:49:36 +11:00
end program