nap-time commit
This commit is contained in:
@@ -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
|
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.
|
[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
|
## Initialize
|
||||||
|
|
||||||
|
|||||||
24
exemples.md
24
exemples.md
@@ -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.
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
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*.
|
|
||||||
|
|
||||||
@@ -11,16 +11,25 @@ module genplotting
|
|||||||
real :: xoffset, yoffset, xscale, yscale
|
real :: xoffset, yoffset, xscale, yscale
|
||||||
private :: xoffset, yoffset, xscale, yscale
|
private :: xoffset, yoffset, xscale, yscale
|
||||||
|
|
||||||
integer :: outunit
|
real :: rotation
|
||||||
|
private :: rotation
|
||||||
|
|
||||||
|
integer :: outunit = 6
|
||||||
private :: outunit
|
private :: outunit
|
||||||
|
|
||||||
contains
|
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)
|
subroutine genp_init (foo, fname)
|
||||||
integer, intent(in) :: foo
|
integer, intent(in) :: foo
|
||||||
character (len=*), intent(in) :: fname
|
character (len=*), intent(in) :: fname
|
||||||
|
|
||||||
if (FOO .NE. 0) THEN
|
IF (FOO .NE. 0) THEN
|
||||||
WRITE(0, '("FOO .NE. 0")')
|
WRITE(0, '("FOO .NE. 0")')
|
||||||
CALL EXIT(1)
|
CALL EXIT(1)
|
||||||
END IF
|
END IF
|
||||||
@@ -35,6 +44,8 @@ subroutine genp_init (foo, fname)
|
|||||||
ymin = 9e9 ; ymax = -9e9
|
ymin = 9e9 ; ymax = -9e9
|
||||||
xoffset = 0.0 ; yoffset = 0.0
|
xoffset = 0.0 ; yoffset = 0.0
|
||||||
xscale = 0.0 ; yscale = 0.0
|
xscale = 0.0 ; yscale = 0.0
|
||||||
|
rotation = 0.0
|
||||||
|
|
||||||
end subroutine
|
end subroutine
|
||||||
! ---------------------------------------------------------
|
! ---------------------------------------------------------
|
||||||
subroutine genp_set_offset(ox, oy)
|
subroutine genp_set_offset(ox, oy)
|
||||||
@@ -76,6 +87,14 @@ subroutine genp_line(xa, ya, xb, yb, color)
|
|||||||
call genp_draw(xb, yb, color)
|
call genp_draw(xb, yb, color)
|
||||||
end subroutine
|
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)
|
subroutine genp_end (foo)
|
||||||
integer, intent(in) :: foo
|
integer, intent(in) :: foo
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
program oscilloscope
|
||||||
use genplotting
|
use genplotting
|
||||||
implicit none
|
implicit none
|
||||||
@@ -8,40 +14,41 @@ program oscilloscope
|
|||||||
call srand(time())
|
call srand(time())
|
||||||
call genp_init (0, 'WS/oscilloscope.scratch')
|
call genp_init (0, 'WS/oscilloscope.scratch')
|
||||||
|
|
||||||
frequences(1) = 0.86
|
frequences(1) = 24.86
|
||||||
frequences(2) = 1.77
|
frequences(2) = 29.77
|
||||||
frequences(3) = 1.56
|
frequences(3) = 37.56
|
||||||
frequences(4) = 3.04
|
frequences(4) = 49.3
|
||||||
|
|
||||||
|
call do_oscilloscope(frequences, 2)
|
||||||
|
|
||||||
call do_oscilloscope(frequences, 1)
|
|
||||||
call genp_end (0)
|
call genp_end (0)
|
||||||
contains
|
contains
|
||||||
! ---------------------------------------------------------
|
! ---------------------------------------------------------
|
||||||
subroutine plot_axes(amp)
|
real function compute_a_value(clk, freq, phase)
|
||||||
real, intent(in) :: amp
|
real, intent(in) :: clk, freq, phase
|
||||||
call genp_move(0.0, -amp)
|
real :: v, f
|
||||||
call genp_draw(0.0, amp, 7)
|
f = freq*(clk+phase)
|
||||||
call genp_move(-amp, 0.0)
|
v = sin(f) + (0.3 * sin(3*f)) + (0.1 * sin(5*f))
|
||||||
call genp_draw( amp, 0.0, 7)
|
compute_a_value = v
|
||||||
end subroutine
|
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
|
real, intent(in) :: freq, phy, ypos
|
||||||
integer, intent(in) :: nbsteps
|
integer, intent(in) :: nbsteps, col
|
||||||
|
|
||||||
integer idx
|
integer idx
|
||||||
real rstep, px, py
|
real rstep, px, py
|
||||||
logical firstdot
|
logical firstdot
|
||||||
|
|
||||||
firstdot = .true.
|
firstdot = .TRUE.
|
||||||
do idx=0, nbsteps
|
do idx=0, nbsteps
|
||||||
rstep = (real(idx)/real(nbsteps))
|
rstep = (real(idx)/real(nbsteps))
|
||||||
px = -10.0 + (20.0 * rstep)
|
px = -10.0 + (20.0 * rstep)
|
||||||
py = ypos + sin(15*(rstep+phy)*freq)
|
py = ypos + compute_a_value (rstep, freq, phy)
|
||||||
if (firstdot) then
|
if (firstdot) then
|
||||||
call genp_move(px, py) ; firstdot = .false.
|
call genp_move(px, py) ; firstdot = .false.
|
||||||
else
|
else
|
||||||
call genp_draw(px, py, 2)
|
call genp_draw(px, py, col)
|
||||||
endif
|
endif
|
||||||
enddo
|
enddo
|
||||||
|
|
||||||
@@ -51,10 +58,10 @@ subroutine do_oscilloscope(freqs, col)
|
|||||||
real, intent(in), dimension(4) :: freqs
|
real, intent(in), dimension(4) :: freqs
|
||||||
integer, intent(in) :: col
|
integer, intent(in) :: col
|
||||||
|
|
||||||
call plot_a_trace(freqs(1), 0.2, 90, 6.66)
|
call plot_a_trace(freqs(1), 0.2, 120, 6.66, col)
|
||||||
call plot_a_trace(freqs(2), 1.0, 90, 3.33)
|
call plot_a_trace(freqs(2), 1.0, 120, 3.33, col)
|
||||||
call plot_a_trace(freqs(3), 2.6, 90, -3.33)
|
call plot_a_trace(freqs(3), 2.6, 120, -3.33, col)
|
||||||
call plot_a_trace(freqs(4), 3.9, 90, -6.66)
|
call plot_a_trace(freqs(4), 3.1, 120, -6.66, col)
|
||||||
call plot_axes(10.0)
|
call plot_axes(10.0)
|
||||||
|
|
||||||
end subroutine
|
end subroutine
|
||||||
|
|||||||
@@ -1,24 +1,30 @@
|
|||||||
!
|
!
|
||||||
! BUILD A STAR FIELD
|
! BUILD A STAR FIELD
|
||||||
|
|
||||||
|
! this crapware is released by tTh under the
|
||||||
|
! DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
||||||
!
|
!
|
||||||
program starfield
|
program starfield
|
||||||
use genplotting
|
use genplotting
|
||||||
implicit none
|
implicit none
|
||||||
write (0, '(A)') "----[ genplotting starfield ]----"
|
write (0, '(A)') "----[ genplotting starfield ]----"
|
||||||
call genp_init (0, 'WS/starfield.scratch')
|
call genp_init (0, 'WS/starfield.scratch')
|
||||||
call do_starfield (451)
|
call do_starfield (200)
|
||||||
call genp_end (0)
|
call genp_end (0)
|
||||||
contains
|
contains
|
||||||
! ---------------------------------------------------------
|
! ---------------------------------------------------------
|
||||||
subroutine plot_a_star(at_x, at_y, sz, color)
|
subroutine plot_a_star(at_x, at_y, sz, color)
|
||||||
real, intent(in) :: at_x, at_y, sz
|
real, intent(in) :: at_x, at_y, sz
|
||||||
integer, intent(in) :: color
|
integer, intent(in) :: color
|
||||||
|
|
||||||
integer :: idx
|
integer :: idx
|
||||||
real :: rad, xv, yv
|
real :: rad, xv, yv
|
||||||
|
|
||||||
write(0, '("plot a star ", 2F8.3)') at_x, at_y
|
write(0, '("plot a star ", 2F8.3)') at_x, at_y
|
||||||
call genp_set_offset(at_x, at_y)
|
call genp_set_offset(at_x, at_y)
|
||||||
do idx=0, 360, 36
|
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)
|
xv = sz * sin(rad) ; yv = sz * cos(rad)
|
||||||
call genp_move(0.0, 0.0)
|
call genp_move(0.0, 0.0)
|
||||||
call genp_draw(xv, yv, color)
|
call genp_draw(xv, yv, color)
|
||||||
@@ -27,12 +33,13 @@ end subroutine
|
|||||||
! ---------------------------------------------------------
|
! ---------------------------------------------------------
|
||||||
subroutine do_starfield (nbstar)
|
subroutine do_starfield (nbstar)
|
||||||
integer, intent(in) :: nbstar
|
integer, intent(in) :: nbstar
|
||||||
|
|
||||||
integer idx, color
|
integer idx, color
|
||||||
real px, py, sz
|
real px, py, sz
|
||||||
do idx=1, nbstar
|
do idx=1, nbstar
|
||||||
px = (rand(0) * 10.00) - 5.00
|
px = (rand(0) * 10.00) - 5.00
|
||||||
py = (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)
|
color = 1 + mod(idx, 7)
|
||||||
call plot_a_star(px, py, sz, color)
|
call plot_a_star(px, py, sz, color)
|
||||||
end do
|
end do
|
||||||
|
|||||||
30
usage.md
30
usage.md
@@ -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)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user