diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b89aea2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +*.mod +*.o +*.scratch +*.tga + +*.png +!picz/*.png + +spirale + diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..1a2d8c5 --- /dev/null +++ b/Makefile @@ -0,0 +1,19 @@ + +all: spirale.png + +# ----------------------------------------------- + +genplotting.o: genplotting.f90 Makefile + gfortran -Wall -c $< + +# ----------------------------------------------- + +spirale: spirale.f90 Makefile genplotting.o + gfortran -Wall $< genplotting.o -o $@ + +spirale.png: spirale Makefile + ./spirale > s.scratch + genplot2 -s 512x512 s.scratch a.tga + convert a.tga $@ + +# ----------------------------------------------- diff --git a/README.md b/README.md index 23c75a7..d4f12cb 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,11 @@ # GenPlotting90 -Diverses tentatives de dessins inutiles avec du Fortran moderne. Croisimot #UselessGraphic dans le grabd Ternet sauvage. \ No newline at end of file +Voici quelques tentatives de dessins inutiles réalisés avec du +[Fortran moderne](https://fortran-lang.org/fr/learn/), et quelques +morceaux de C parce que *why not ?* + +Un peu de lecture : [utilisation](usage.md) et [exemples](exemples.md). + +Vous pouvez suivre le croisimot [#UselessGraphic](https://mastodon.tetaneutral.net/tags/uselessgraphic) +dans le grand Ternet sauvage. Pour me contacter, il faut utiliser les +[méthodes]( diff --git a/exemples.md b/exemples.md new file mode 100644 index 0000000..8feb147 --- /dev/null +++ b/exemples.md @@ -0,0 +1,10 @@ +# Genplotting exemples + +## Spiral + +Code source : [spirale.f90](spirale.f90) / if you change the parameter +in the call to `do_spirale`, you can see some nice variations on the +spiraling thing. + +![#UselessGraphic : la spirale](picz/spirale.png) + diff --git a/genplotting.f90 b/genplotting.f90 new file mode 100644 index 0000000..a03f09c --- /dev/null +++ b/genplotting.f90 @@ -0,0 +1,76 @@ +! SPIRALING... +! new Thu Apr 23 01:13.37 PM UTC 2026 +! +module genplotting + implicit none + + real :: xmin, xmax, ymin, ymax + private :: xmin, xmax, ymin, ymax + + real :: xoffset, yoffset, xscale, yscale + private :: xoffset, yoffset, xscale, yscale + + integer :: outunit + private :: outunit + +contains +! --------------------------------------------------------- +subroutine genp_init (foo, fname) + integer, intent(in) :: foo + character (len=*), intent(in) :: fname + + outunit = 6 ! stdout + if (len(fname) .gt. 0) then + write (0, '("genplot init opening : ", A)') fname + open(newunit=outunit,file=fname) + endif + + xmin = 9e9 ; xmax = -9e9 + ymin = 9e9 ; ymax = -9e9 + xoffset = 0.0 ; yoffset = 0.0 + xscale = 0.0 ; yscale = 0.0 +end subroutine +! --------------------------------------------------------- +subroutine genp_move (px, py) + real, intent(in) :: px, py + write (outunit, '(2F12.5, I5)') px, py, -1 + if (px .lt. xmin) xmin = px + if (px .gt. xmax) xmax = px + if (py .lt. ymin) ymin = py + if (py .gt. ymax) ymax = py +end subroutine +! --------------------------------------------------------- +subroutine genp_draw (px, py, color) + real, intent(in) :: px, py + integer, intent(in) :: color + write (outunit, '(2F12.5, I5)') px, py, color + if (px .lt. xmin) xmin = px + if (px .gt. xmax) xmax = px + if (py .lt. ymin) ymin = py + if (py .gt. ymax) ymax = py +end subroutine +! --------------------------------------------------------- +! --------------------------------------------------------- +subroutine genp_end (foo) + integer, intent(in) :: foo + + write (0, '("--- genp_end ---")') + write (0, '("minmax X", 2F16.5)') xmin, xmax + write (0, '("minmax Y", 2F16.5)') ymin, ymax + + write (outunit, '(2F16.5, I6)') xmin*1.05, ymin*1.05, -1 + write (outunit, '(2F16.5, I6)') xmin*1.05, ymax*1.05, 0 + write (outunit, '(2F16.5, I6)') xmax*1.05, ymax*1.05, 0 + write (outunit, '(2F16.5, I6)') xmax*1.05, ymin*1.05, 0 + write (outunit, '(2F16.5, I6)') xmin*1.05, ymin*1.05, 0 + close (outunit) + + if (6 .ne. outunit) then + write (0, '("genp_end on ", I6, " is ", I6)') outunit, foo + endif + +end subroutine +! --------------------------------------------------------- +! --------------------------------------------------------- + +end module genplotting diff --git a/picz/spirale.png b/picz/spirale.png new file mode 100644 index 0000000..a1b6ef7 Binary files /dev/null and b/picz/spirale.png differ diff --git a/spirale.f90 b/spirale.f90 new file mode 100644 index 0000000..3c11f76 --- /dev/null +++ b/spirale.f90 @@ -0,0 +1,34 @@ +! SPIRALING... +! new Thu Apr 23 04:27:03 PM UTC 2026 +! + +program spirale + use genplotting + implicit none + + write (0, '(A)') "----[ genplotting spirale ]----" + + call genp_init (0, 's.scratch') + call do_spirale (1337) + call genp_end (0) + +contains +! --------------------------------------------------------- +subroutine do_spirale (nbpass) + integer, intent(in) :: nbpass + integer idx, col + real rad, px, py, dist + + px = 0.0 ; py = 0.0 + call genp_move (px, py) + do idx=1, nbpass + dist = real(idx) * 0.51 + rad = real(idx) * 0.0666 + px = dist * sin(rad) + py = dist * cos(rad) + col = 3 + call genp_draw (px, py, col) + enddo +end subroutine +! --------------------------------------------------------- +end program diff --git a/usage.md b/usage.md new file mode 100644 index 0000000..81a231a --- /dev/null +++ b/usage.md @@ -0,0 +1,22 @@ +# Usage + +Three steps : initialize, use and terminating. + +## Initialize + +Call the subroutine `genp_init` with two parameters. +The first is an integer and must be 0. +The second is the filename for recording the plottings instructions, +if this filename is an empty string, *stdout* will be used. + +## Use it + +- call genp_move(x, y) +- call genp_draw(x, y, c) + +## Terminator + +- call genp_end(0) + + +