From 95a8502d0f707e3d32e780473c2d8362418fe4e6 Mon Sep 17 00:00:00 2001 From: Tonton Th Date: Tue, 5 May 2026 14:23:20 +0200 Subject: [PATCH] nap-time commit --- docs/usage.md | 3 ++- exemples.md | 24 ------------------------ genplotting.f90 | 23 +++++++++++++++++++++-- oscilloscope.f90 | 49 +++++++++++++++++++++++++++--------------------- starfield.f90 | 13 ++++++++++--- usage.md | 30 ----------------------------- 6 files changed, 61 insertions(+), 81 deletions(-) delete mode 100644 exemples.md delete mode 100644 usage.md diff --git a/docs/usage.md b/docs/usage.md index 45ed196..a3dbd2d 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -5,7 +5,8 @@ The genplotting library use, as a backend, an external who can be installed with the [libtthimage](https://git.tetalab.org/tTh/libtthimage) and convert scratchfiles to [Targa](https://en.wikipedia.org/wiki/Truevision_TGA) image file. -Three steps : initialize, use and terminating. +For drawing an *useless graphic*, you have to follow three steps: +initialize, use and terminating. ## Initialize diff --git a/exemples.md b/exemples.md deleted file mode 100644 index 49631d9..0000000 --- a/exemples.md +++ /dev/null @@ -1,24 +0,0 @@ -# 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) - -This was my first testbed for this new *disruptive* technology, but -there was so many variations of spirales, and i'm thinking about -a powerfull spiral generator. *Stay tuned, film at 11*. - -## Dessins numériques - -By the way, I'm using all that *futilo-technology* for trying to -make some -[numeric pictures](http://maison.tth.netlib.re/dessins/numerique.html) -(aka #UselessGraphic). I try to use various mathematic fundations, and -I hack and divert and modify and ignore all that for just make -[UselessGraphic](https://mastodon.tetaneutral.net/tags/uselessgraphic). -*Feel free to share and enjoy*. - diff --git a/genplotting.f90 b/genplotting.f90 index 827c8bf..cc326c4 100644 --- a/genplotting.f90 +++ b/genplotting.f90 @@ -11,16 +11,25 @@ module genplotting real :: xoffset, yoffset, xscale, yscale private :: xoffset, yoffset, xscale, yscale - integer :: outunit + real :: rotation + private :: rotation + + integer :: outunit = 6 private :: outunit contains ! --------------------------------------------------------- +! the first parameter _must_ be 0. +! the second can be +! - the name of a file for recoding plot instructions +! or +! - an empty string for send plot command to stdout +! subroutine genp_init (foo, fname) integer, intent(in) :: foo character (len=*), intent(in) :: fname - if (FOO .NE. 0) THEN + IF (FOO .NE. 0) THEN WRITE(0, '("FOO .NE. 0")') CALL EXIT(1) END IF @@ -35,6 +44,8 @@ subroutine genp_init (foo, fname) ymin = 9e9 ; ymax = -9e9 xoffset = 0.0 ; yoffset = 0.0 xscale = 0.0 ; yscale = 0.0 + rotation = 0.0 + end subroutine ! --------------------------------------------------------- subroutine genp_set_offset(ox, oy) @@ -76,6 +87,14 @@ subroutine genp_line(xa, ya, xb, yb, color) call genp_draw(xb, yb, color) end subroutine ! --------------------------------------------------------- +subroutine plot_axes(amp) + real, intent(in) :: amp + call genp_move(0.0, -amp) + call genp_draw(0.0, amp, 7) + call genp_move(-amp, 0.0) + call genp_draw( amp, 0.0, 7) +end subroutine +! --------------------------------------------------------- subroutine genp_end (foo) integer, intent(in) :: foo diff --git a/oscilloscope.f90 b/oscilloscope.f90 index 7224b82..7dd0ccc 100644 --- a/oscilloscope.f90 +++ b/oscilloscope.f90 @@ -1,3 +1,9 @@ +! +! OSCILLOSCOPE EXPERIMENT +! +! this crapware is released by tTh under the +! DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE +! program oscilloscope use genplotting implicit none @@ -8,40 +14,41 @@ program oscilloscope call srand(time()) call genp_init (0, 'WS/oscilloscope.scratch') - frequences(1) = 0.86 - frequences(2) = 1.77 - frequences(3) = 1.56 - frequences(4) = 3.04 + frequences(1) = 24.86 + frequences(2) = 29.77 + frequences(3) = 37.56 + frequences(4) = 49.3 + + call do_oscilloscope(frequences, 2) - call do_oscilloscope(frequences, 1) call genp_end (0) contains ! --------------------------------------------------------- -subroutine plot_axes(amp) - real, intent(in) :: amp - call genp_move(0.0, -amp) - call genp_draw(0.0, amp, 7) - call genp_move(-amp, 0.0) - call genp_draw( amp, 0.0, 7) -end subroutine +real function compute_a_value(clk, freq, phase) + real, intent(in) :: clk, freq, phase + real :: v, f + f = freq*(clk+phase) + v = sin(f) + (0.3 * sin(3*f)) + (0.1 * sin(5*f)) + compute_a_value = v +end function ! --------------------------------------------------------- -subroutine plot_a_trace(freq, phy, nbsteps, ypos) +subroutine plot_a_trace(freq, phy, nbsteps, ypos, col) real, intent(in) :: freq, phy, ypos - integer, intent(in) :: nbsteps + integer, intent(in) :: nbsteps, col integer idx real rstep, px, py logical firstdot - firstdot = .true. + firstdot = .TRUE. do idx=0, nbsteps rstep = (real(idx)/real(nbsteps)) px = -10.0 + (20.0 * rstep) - py = ypos + sin(15*(rstep+phy)*freq) + py = ypos + compute_a_value (rstep, freq, phy) if (firstdot) then call genp_move(px, py) ; firstdot = .false. else - call genp_draw(px, py, 2) + call genp_draw(px, py, col) endif enddo @@ -51,10 +58,10 @@ subroutine do_oscilloscope(freqs, col) real, intent(in), dimension(4) :: freqs integer, intent(in) :: col - call plot_a_trace(freqs(1), 0.2, 90, 6.66) - call plot_a_trace(freqs(2), 1.0, 90, 3.33) - call plot_a_trace(freqs(3), 2.6, 90, -3.33) - call plot_a_trace(freqs(4), 3.9, 90, -6.66) + call plot_a_trace(freqs(1), 0.2, 120, 6.66, col) + call plot_a_trace(freqs(2), 1.0, 120, 3.33, col) + call plot_a_trace(freqs(3), 2.6, 120, -3.33, col) + call plot_a_trace(freqs(4), 3.1, 120, -6.66, col) call plot_axes(10.0) end subroutine diff --git a/starfield.f90 b/starfield.f90 index 47f66c0..c12c669 100644 --- a/starfield.f90 +++ b/starfield.f90 @@ -1,24 +1,30 @@ ! ! BUILD A STAR FIELD + +! this crapware is released by tTh under the +! DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE ! program starfield use genplotting implicit none write (0, '(A)') "----[ genplotting starfield ]----" call genp_init (0, 'WS/starfield.scratch') - call do_starfield (451) + call do_starfield (200) call genp_end (0) contains ! --------------------------------------------------------- subroutine plot_a_star(at_x, at_y, sz, color) real, intent(in) :: at_x, at_y, sz integer, intent(in) :: color + integer :: idx real :: rad, xv, yv + write(0, '("plot a star ", 2F8.3)') at_x, at_y call genp_set_offset(at_x, at_y) do idx=0, 360, 36 - rad = 0.042 + (real(idx) * (3.14159 / 180)) + ! convert index to radians + rad = real(idx) * (3.14159 / 180) xv = sz * sin(rad) ; yv = sz * cos(rad) call genp_move(0.0, 0.0) call genp_draw(xv, yv, color) @@ -27,12 +33,13 @@ end subroutine ! --------------------------------------------------------- subroutine do_starfield (nbstar) integer, intent(in) :: nbstar + integer idx, color real px, py, sz do idx=1, nbstar px = (rand(0) * 10.00) - 5.00 py = (rand(0) * 10.00) - 5.00 - sz = (rand(0) * 0.16) + 0.16 + sz = (rand(0) * 0.30) + 0.12 color = 1 + mod(idx, 7) call plot_a_star(px, py, sz, color) end do diff --git a/usage.md b/usage.md deleted file mode 100644 index 45ed196..0000000 --- a/usage.md +++ /dev/null @@ -1,30 +0,0 @@ -# Usage - -The genplotting library use, as a backend, an external -[software](https://git.tetalab.org/tTh/libtthimage/src/branch/master/Tools/genplot2.c) -who can be installed with the [libtthimage](https://git.tetalab.org/tTh/libtthimage) and convert scratchfiles to -[Targa](https://en.wikipedia.org/wiki/Truevision_TGA) image file. - -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 - -- real xa, ya, xb, yb -- integer color -- call genp_move(xa, ya) -- call genp_draw(xa, ya, color) -- call genp_line(xa, ya, xb, yb, color) - -## Terminator - -- call genp_end(0) - - -