TetaTricks/code/fortran/dessiner.f90

98 lines
2.5 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-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-03-21 15:03:09 +01:00
call plend
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 ()
integer, parameter :: nbpts = 40
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
x(i) = 8.50 * (rand() - 0.5000)
y(i) = 8.50 * (rand() - 0.5000)
enddo
do frame= 0, 149
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
x(i) = x(i) + (rand() - 0.5000)
y(i) = y(i) + (rand() - 0.5000)
call plline (x, y)
enddo
write(buffer, "(i3.3)") frame
str = trim(buffer)
call plcol0 (15)
call plstring (x, y, buffer)
call plend
enddo
2023-03-21 00:16:54 +01:00
end subroutine
!------------------------------------------------------
2023-03-07 20:49:36 +01:00
end program