TetaTricks/code/fortran/dessiner.f90

123 lines
3.3 KiB
Fortran
Raw Normal View History

2023-03-07 20:49:36 +01:00
program dessiner
use plplot
implicit none
2023-03-21 00:16:54 +01:00
integer :: i
2023-03-07 20:49:36 +01:00
character(len=80) :: version
call plgver(version)
2023-03-21 15:03:09 +01:00
write (*,'(a,a)') 'plPlot version: ', trim(version)
2023-03-07 20:49:36 +01:00
2023-03-21 15:03:09 +01:00
! call dessin_X11 (0.00, 1.51, 11)
call dessin_dans_un_fichier ()
2023-03-07 20:49:36 +01:00
2023-03-21 00:16:54 +01:00
contains ! -----------------------------
!------------------------------------------------------
2023-04-02 23:32:29 +02:00
!- __ __ _
!- \ \/ / __ __ (_) _ __
!- \ / \ \ /\ / / | | | '_ \
!- / \ \ V V / | | | | | |
!- /_/\_\ \_/\_/ |_| |_| |_|
!-
2023-03-21 15:03:09 +01:00
subroutine dessin_X11 (sha, shb, color)
2023-03-21 00:16:54 +01:00
real, intent(in) :: sha, shb
integer, intent(in) :: color
2023-03-07 20:49:36 +01:00
2023-03-21 00:16:54 +01:00
integer, parameter :: lg = 2000
2023-03-07 20:49:36 +01:00
real :: x(lg), y(lg)
2023-03-21 00:16:54 +01:00
real :: k, amp
2023-03-07 20:49:36 +01:00
integer :: i
2023-03-21 15:03:09 +01:00
print *, 'dessin X11:', sha, shb, color
call plsdev('xwin')
call plinit ()
call plenv (-2.1, 2.1, -2.1, 2.1, 1, 2)
amp = 2.16
2023-03-07 20:49:36 +01:00
do i = 1, lg
2023-03-21 00:16:54 +01:00
k = real(i)/real(lg) * 6.2832 * 4.0
x(i) = amp * sin((k+sha)*5)
y(i) = amp * cos((k+shb)*3)
2023-03-07 20:49:36 +01:00
enddo
2023-03-21 00:16:54 +01:00
! print *, k, x(i), y(i)
2023-03-07 20:49:36 +01:00
call plcol0 (15) ! pure white
call pllab ("Fuzzfactor", "Yoyodines", "Some nice plots from tTh")
2023-03-21 00:16:54 +01:00
call plcol0 (color)
2023-03-07 20:49:36 +01:00
call plline (x, y)
2023-04-02 23:32:29 +02:00
call plend ()
2023-03-21 15:03:09 +01:00
2023-03-07 20:49:36 +01:00
end subroutine
2023-03-21 00:16:54 +01:00
!------------------------------------------------------
2023-03-21 15:03:09 +01:00
!- _ __ ___ ___ ___
!- __ _ (_) / _| ( _ ) / _ \ __ _ |__ \
!- / _` | | | | |_ / _ \ | (_) | / _` | / /
!- | (_| | | | | _| | (_) | \__, | | (_| | |_|
!- \__, | |_| |_| \___/ /_/ \__,_| (_)
!- |___/
subroutine dessin_dans_un_fichier ()
2023-04-02 23:32:29 +02:00
integer, parameter :: nbpts = 20
real, parameter :: usz = 15.0 ! univers size
2023-03-21 15:03:09 +01: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-02 23:32:29 +02:00
x(i) = usz * (rand() - 0.5000)
y(i) = usz * (rand() - 0.5000) * 0.50
2023-03-21 15:03:09 +01:00
enddo
2023-04-02 23:32:29 +02:00
do frame= 0, 119
2023-03-21 15:03:09 +01: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-02 23:32:29 +02:00
x(i) = x(i) + 1.2 * (rand() - 0.5000)
y(i) = y(i) + 1.2 * (rand() - 0.5000)
2023-03-21 15:03:09 +01:00
call plline (x, y)
enddo
write(buffer, "(i3.3)") frame
str = trim(buffer)
call plcol0 (15)
call plstring (x, y, buffer)
2023-04-02 23:32:29 +02:00
call plend ()
2023-03-21 15:03:09 +01:00
enddo
2023-04-02 23:32:29 +02:00
end subroutine
!------------------------------------------------------
!- _ _ ____
!- | |_ _ __ ___ (_) | _ \
!- | __| | '__| / _ \ | | | | | |
!- | |_ | | | (_) | | | | |_| |
!- \__| |_| \___/ |_| |____/
!-
subroutine dessiner_en_trois_D ()
integer, parameter :: szgrid = 64
integer :: i, j
2023-03-21 00:16:54 +01:00
2023-04-02 23:32:29 +02:00
print *, 'Dessin en 3D (de merde :)'
call plsdev ('xwin')
call plinit ()
call plend ()
2023-03-21 00:16:54 +01:00
end subroutine
!------------------------------------------------------
2023-03-07 20:49:36 +01:00
end program