Compare commits
20 Commits
aca035c8be
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0bc55225fc | ||
|
|
3d4fce2ed0 | ||
|
|
ec199da8dd | ||
|
|
a20725f5ef | ||
|
|
42d066678d | ||
|
|
ea373fa198 | ||
|
|
52e5e99b07 | ||
|
|
086c2af118 | ||
|
|
e060fad764 | ||
|
|
be961b46fc | ||
|
|
1dd0e71577 | ||
|
|
a0d63856af | ||
|
|
fce8fd4989 | ||
|
|
05066538ef | ||
|
|
0a2598af5b | ||
|
|
d4c3783d72 | ||
|
|
a079f026f7 | ||
|
|
95a8502d0f | ||
|
|
6747f0e243 | ||
|
|
d0914b588a |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -12,4 +12,7 @@ randomwalk
|
|||||||
oscilloscope
|
oscilloscope
|
||||||
lissajous
|
lissajous
|
||||||
squarmania
|
squarmania
|
||||||
|
testbed
|
||||||
|
rndwlkng
|
||||||
|
morecircles
|
||||||
|
|
||||||
|
|||||||
31
Makefile
31
Makefile
@@ -1,11 +1,36 @@
|
|||||||
|
#
|
||||||
|
|
||||||
all: spirale.png
|
all: testbed
|
||||||
|
|
||||||
# -----------------------------------------------
|
# -----------------------------------------------
|
||||||
|
|
||||||
genplotting.o: genplotting.f90 Makefile
|
genplotting.o: genplotting.f90 Makefile
|
||||||
gfortran -Wall -c $<
|
gfortran -Wall -c $<
|
||||||
|
|
||||||
|
genp_tests.o: genp_tests.f90 genplotting.o Makefile
|
||||||
|
gfortran -Wall -c $<
|
||||||
|
|
||||||
|
testbed: testbed.f90 Makefile genp_tests.o genplotting.o
|
||||||
|
gfortran -Wall $< genplotting.o genp_tests.o -o $@
|
||||||
|
|
||||||
|
# -----------------------------------------------
|
||||||
|
|
||||||
|
rndwlkng: rndwlkng.f90 Makefile genplotting.o
|
||||||
|
gfortran -Wall $< genplotting.o -o $@
|
||||||
|
|
||||||
|
rndwlkng.png: rndwlkng Makefile
|
||||||
|
./rndwlkng
|
||||||
|
convert rndwlkng.tga rndwlkng.png
|
||||||
|
|
||||||
|
# -----------------------------------------------
|
||||||
|
|
||||||
|
morecircles: morecircles.f90 Makefile genplotting.o
|
||||||
|
gfortran -Wall $< genplotting.o -o $@
|
||||||
|
|
||||||
|
morecircles.png: morecircles Makefile
|
||||||
|
./morecircles
|
||||||
|
convert morecircles.tga morecircles.png
|
||||||
|
|
||||||
# -----------------------------------------------
|
# -----------------------------------------------
|
||||||
|
|
||||||
starfield: starfield.f90 Makefile genplotting.o
|
starfield: starfield.f90 Makefile genplotting.o
|
||||||
@@ -13,8 +38,7 @@ starfield: starfield.f90 Makefile genplotting.o
|
|||||||
|
|
||||||
starfield.png: starfield Makefile
|
starfield.png: starfield Makefile
|
||||||
./starfield
|
./starfield
|
||||||
genplot2 -s 512x512 WS/starfield.scratch WS/a.tga
|
convert -verbose WS/a.tga $@
|
||||||
convert WS/a.tga $@
|
|
||||||
|
|
||||||
# -----------------------------------------------
|
# -----------------------------------------------
|
||||||
|
|
||||||
@@ -43,7 +67,6 @@ spirale: spirale.f90 Makefile genplotting.o
|
|||||||
|
|
||||||
spirale.png: spirale Makefile
|
spirale.png: spirale Makefile
|
||||||
./spirale
|
./spirale
|
||||||
genplot2 -s 512x512 WS/spirale.scratch WS/a.tga
|
|
||||||
convert WS/a.tga $@
|
convert WS/a.tga $@
|
||||||
|
|
||||||
# -----------------------------------------------
|
# -----------------------------------------------
|
||||||
|
|||||||
11
README.md
11
README.md
@@ -2,11 +2,16 @@
|
|||||||
|
|
||||||
Voici quelques tentatives de dessins inutiles réalisés avec du
|
Voici quelques tentatives de dessins inutiles réalisés avec du
|
||||||
[Fortran moderne](https://fortran-lang.org/fr/learn/), et quelques
|
[Fortran moderne](https://fortran-lang.org/fr/learn/), et quelques
|
||||||
morceaux de C parce que *why not ?*
|
morceaux de C parce que *why not ?* L'idée générale c'est d'utiliser
|
||||||
|
de la basse technologie (traduction hasardeuse de **lowtech**) pour
|
||||||
|
servir la noble cause de la
|
||||||
|
[techno-futilité](https://wiki.interhacker.space/index.php?title=Techno-futilit%C3%A9).
|
||||||
|
|
||||||
Un peu de lecture : [utilisation](usage.md) et [exemples](exemples.md).
|
Un peu de lecture : [license](LICENSE), [utilisation](usage.md) et
|
||||||
|
[exemples](exemples.md).
|
||||||
|
|
||||||
Vous pouvez suivre le croisimot [#UselessGraphic](https://mastodon.tetaneutral.net/tags/uselessgraphic)
|
Vous pouvez suivre le croisimot
|
||||||
|
[#UselessGraphic](https://pleroma.interhacker.space/tag/uselessgraphic)
|
||||||
dans le grand Ternet sauvage. Pour me contacter, il faut utiliser les
|
dans le grand Ternet sauvage. Pour me contacter, il faut utiliser les
|
||||||
[méthodes](https://www.tetalab.org/fr/contact) habituelles du Tetalab.
|
[méthodes](https://www.tetalab.org/fr/contact) habituelles du Tetalab.
|
||||||
|
|
||||||
|
|||||||
@@ -2,11 +2,11 @@
|
|||||||
|
|
||||||
## Spiral
|
## Spiral
|
||||||
|
|
||||||
Code source : [spirale.f90](spirale.f90) / if you change the parameter
|
Source code: [spirale.f90](../spirale.f90) / if you change the parameter
|
||||||
in the call to `do_spirale`, you can see some nice variations on the
|
in the call to `do_spirale`, you can see some nice variations on the
|
||||||
spiraling thing.
|
spiraling thing.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
This was my first testbed for this new *disruptive* technology, but
|
This was my first testbed for this new *disruptive* technology, but
|
||||||
there was so many variations of spirales, and i'm thinking about
|
there was so many variations of spirales, and i'm thinking about
|
||||||
53
docs/usage.md
Normal file
53
docs/usage.md
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
# 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.
|
||||||
|
|
||||||
|
For drawing an *useless graphic*, you have to follow three steps:
|
||||||
|
initialize, use and terminating.
|
||||||
|
You can look at some [examples](exemples.md) and at a
|
||||||
|
[full page](http://maison.tth.netlib.re/dessins/numerique.html)
|
||||||
|
off UselessGraphics.
|
||||||
|
|
||||||
|
## Initialize
|
||||||
|
|
||||||
|
Call the subroutine `genp_init` with two parameters.
|
||||||
|
The first is an integer and must be 0. In the futur, it may be used for
|
||||||
|
setting some predefined configurations.
|
||||||
|
|
||||||
|
The second is the filename for recording the plottings instructions,
|
||||||
|
I'm using the `.scratch` extension for naming this file.
|
||||||
|
And if this filename is an empty string, *stdout* will be used, so
|
||||||
|
you can pipe the data for post-processing purpose.
|
||||||
|
**Be warned:** if you use this option, don't write anything to the
|
||||||
|
unit 6 **!**
|
||||||
|
|
||||||
|
## 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)`
|
||||||
|
This procedure end the current plotting, add some *bells* to the *WIP*,
|
||||||
|
and close the output file, if an output file was specified.
|
||||||
|
|
||||||
|
## Rendering
|
||||||
|
|
||||||
|
- `subroutine genp_do_render(srcfile, tgafile, xsize, ysize)`
|
||||||
|
|
||||||
|
After doing all that useless computing graphics, you can call
|
||||||
|
the render, only if you have given a filename to `genp_init`.
|
||||||
|
The render engine that I use can only write Targa file, but
|
||||||
|
I'm going to add `PNG` to it output in a near futur.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
41
genp_tests.f90
Normal file
41
genp_tests.f90
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
!
|
||||||
|
! MODULE FOR TESTING THE GENPLOTTING MODULE
|
||||||
|
!
|
||||||
|
! this crapware is released by tTh under the
|
||||||
|
! DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
||||||
|
!
|
||||||
|
! new Sun May 17 11:21:39 AM UTC 2026
|
||||||
|
|
||||||
|
module genp_tests
|
||||||
|
use genplotting
|
||||||
|
implicit none
|
||||||
|
contains
|
||||||
|
! ---------------------------------------------------------
|
||||||
|
subroutine genp_test_rotation()
|
||||||
|
|
||||||
|
real :: mat(3, 3)
|
||||||
|
real :: pta(3), ptb(3)
|
||||||
|
integer :: pass, i, j
|
||||||
|
|
||||||
|
write(0, '("*** TEST ROTATION ***")' )
|
||||||
|
do pass=1, 90
|
||||||
|
call genp_set_rotation (real(pass)*0.10)
|
||||||
|
write(0, *) " * the matrix was : "
|
||||||
|
call genp_get_rot_matrix(mat)
|
||||||
|
do i=1, 3
|
||||||
|
do j=1, 3
|
||||||
|
write (0, '(" ", F8.5)', advance='no') mat(i,j)
|
||||||
|
end do
|
||||||
|
write(0, *)
|
||||||
|
end do
|
||||||
|
|
||||||
|
call genp_move(0.0, 0.0)
|
||||||
|
pta(1) = 11.0 ; pta(2) = 0.0 ; pta(3) = 0.0
|
||||||
|
ptb = matmul(mat, pta)
|
||||||
|
write(0, '(" got XY: ", F8.5, " ", F8.5)') ptb(1), ptb(2)
|
||||||
|
call genp_draw(ptb(1), ptb(2), 1+mod(pass, 7))
|
||||||
|
end do ! pass
|
||||||
|
|
||||||
|
end subroutine
|
||||||
|
! ---------------------------------------------------------
|
||||||
|
end module
|
||||||
163
genplotting.f90
163
genplotting.f90
@@ -11,16 +11,26 @@ 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, rotmatrix(3,3)
|
||||||
|
private :: rotation, rotmatrix, compute_rot_matrix
|
||||||
|
private :: print_rot_matrix
|
||||||
|
|
||||||
|
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 recording 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
|
||||||
@@ -34,7 +44,10 @@ subroutine genp_init (foo, fname)
|
|||||||
xmin = 9e9 ; xmax = -9e9
|
xmin = 9e9 ; xmax = -9e9
|
||||||
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 = 1.0 ; yscale = 1.0
|
||||||
|
|
||||||
|
rotation = 0.0
|
||||||
|
|
||||||
end subroutine
|
end subroutine
|
||||||
! ---------------------------------------------------------
|
! ---------------------------------------------------------
|
||||||
subroutine genp_set_offset(ox, oy)
|
subroutine genp_set_offset(ox, oy)
|
||||||
@@ -46,10 +59,71 @@ subroutine genp_get_offset(ox, oy)
|
|||||||
ox = xoffset ; oy = yoffset
|
ox = xoffset ; oy = yoffset
|
||||||
end subroutine
|
end subroutine
|
||||||
! ---------------------------------------------------------
|
! ---------------------------------------------------------
|
||||||
|
! new Tue May 12 06:51:57 PM UTC 2026
|
||||||
|
subroutine genp_set_scale(sx, sy)
|
||||||
|
real, intent(in) :: sx, sy
|
||||||
|
xscale = sx ; yscale = sy
|
||||||
|
end subroutine
|
||||||
|
subroutine genp_get_scale(sx, sy)
|
||||||
|
real, intent(out) :: sx, sy
|
||||||
|
sx = xscale ; sy = yscale
|
||||||
|
end subroutine
|
||||||
|
! ---------------------------------------------------------
|
||||||
|
! this is a private procedure, don't call it from your prog
|
||||||
|
subroutine compute_rot_matrix(angle)
|
||||||
|
real, intent(in) :: angle
|
||||||
|
write (0, '("compute rot matrix for", F8.5, " radians")') &
|
||||||
|
angle
|
||||||
|
rotmatrix (1, 1) = cos(angle)
|
||||||
|
rotmatrix (1, 2) = sin(angle)
|
||||||
|
rotmatrix (1, 3) = 0.0
|
||||||
|
|
||||||
|
rotmatrix (2, 1) = -sin(angle)
|
||||||
|
rotmatrix (2, 2) = cos(angle)
|
||||||
|
rotmatrix (2, 3) = 0.0
|
||||||
|
|
||||||
|
rotmatrix (3, 1) = 0.0
|
||||||
|
rotmatrix (3, 2) = 0.0
|
||||||
|
rotmatrix (3, 3) = 1.0
|
||||||
|
|
||||||
|
end subroutine
|
||||||
|
! -----------------
|
||||||
|
! we have computed some fancy numbers
|
||||||
|
! and we want to see them !
|
||||||
|
subroutine print_rot_matrix(fd)
|
||||||
|
integer, intent(in) :: fd
|
||||||
|
|
||||||
|
integer :: i, j
|
||||||
|
do i=1, 3
|
||||||
|
do j=1, 3
|
||||||
|
write (fd, '(" ", F8.5)', advance='no') rotmatrix(i,j)
|
||||||
|
end do
|
||||||
|
write(fd, *)
|
||||||
|
end do
|
||||||
|
end subroutine
|
||||||
|
! ---------------------------------------------------------
|
||||||
|
subroutine genp_set_rotation(angle)
|
||||||
|
real, intent(in) :: angle
|
||||||
|
rotation = angle
|
||||||
|
! compute the matrix here !
|
||||||
|
call compute_rot_matrix(angle)
|
||||||
|
! call print_rot_matrix(0)
|
||||||
|
end subroutine
|
||||||
|
|
||||||
|
real function genp_get_rotation()
|
||||||
|
genp_get_rotation = rotation
|
||||||
|
end function
|
||||||
|
|
||||||
|
subroutine genp_get_rot_matrix (dst)
|
||||||
|
real, intent(out) :: dst(3, 3)
|
||||||
|
dst = rotmatrix
|
||||||
|
end subroutine
|
||||||
|
! ---------------------------------------------------------
|
||||||
subroutine genp_move (px, py)
|
subroutine genp_move (px, py)
|
||||||
real, intent(in) :: px, py
|
real, intent(in) :: px, py
|
||||||
real :: lx, ly
|
real :: lx, ly
|
||||||
lx = px + xoffset ; ly = py + yoffset
|
lx = (px*xscale) + xoffset
|
||||||
|
ly = (py*yscale) + yoffset
|
||||||
write (outunit, '(2F12.5, I5)') lx, ly, -1
|
write (outunit, '(2F12.5, I5)') lx, ly, -1
|
||||||
if (lx .lt. xmin) xmin = lx
|
if (lx .lt. xmin) xmin = lx
|
||||||
if (lx .gt. xmax) xmax = lx
|
if (lx .gt. xmax) xmax = lx
|
||||||
@@ -61,7 +135,8 @@ subroutine genp_draw (px, py, color)
|
|||||||
real, intent(in) :: px, py
|
real, intent(in) :: px, py
|
||||||
integer, intent(in) :: color
|
integer, intent(in) :: color
|
||||||
real :: lx, ly
|
real :: lx, ly
|
||||||
lx = px + xoffset ; ly = py + yoffset
|
lx = (px*xscale) + xoffset
|
||||||
|
ly = (py*yscale) + yoffset
|
||||||
write (outunit, '(2F12.5, I5)') lx, ly, color
|
write (outunit, '(2F12.5, I5)') lx, ly, color
|
||||||
if (lx .lt. xmin) xmin = lx
|
if (lx .lt. xmin) xmin = lx
|
||||||
if (lx .gt. xmax) xmax = lx
|
if (lx .gt. xmax) xmax = lx
|
||||||
@@ -76,10 +151,46 @@ 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 genp_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_circle(radius, steps, color)
|
||||||
|
real, intent(in) :: radius
|
||||||
|
integer, intent(in) :: steps, color
|
||||||
|
|
||||||
|
integer :: idx
|
||||||
|
real :: fk, ang, x, y
|
||||||
|
logical :: firstdot
|
||||||
|
|
||||||
|
if (steps .LT.3 ) then
|
||||||
|
write(0, '("circle: steps ", I3, " bad value")') steps
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
|
||||||
|
firstdot = .TRUE.
|
||||||
|
do idx=0, steps
|
||||||
|
fk = real(idx) / real(steps)
|
||||||
|
ang = 6.283185307 * fk
|
||||||
|
! write(0, '(I5, " -> ", 2F10.5)') idx, fk, ang
|
||||||
|
x = radius * cos(ang) ; y = radius * sin(ang)
|
||||||
|
if (firstdot) then
|
||||||
|
call genp_move(x, y) ; firstdot = .FALSE.
|
||||||
|
else
|
||||||
|
call genp_draw(x, y, color)
|
||||||
|
endif
|
||||||
|
enddo
|
||||||
|
|
||||||
|
end subroutine
|
||||||
|
! ---------------------------------------------------------
|
||||||
subroutine genp_end (foo)
|
subroutine genp_end (foo)
|
||||||
integer, intent(in) :: foo
|
integer, intent(in) :: foo
|
||||||
|
|
||||||
write (0, '("--- genp_end ---")')
|
write (0, '("------------- genp_end -------------")')
|
||||||
write (0, '("minmax X ", 2F18.5)') xmin, xmax
|
write (0, '("minmax X ", 2F18.5)') xmin, xmax
|
||||||
write (0, '("minmax Y ", 2F18.5)') ymin, ymax
|
write (0, '("minmax Y ", 2F18.5)') ymin, ymax
|
||||||
|
|
||||||
@@ -96,6 +207,46 @@ subroutine genp_end (foo)
|
|||||||
|
|
||||||
end subroutine
|
end subroutine
|
||||||
! ---------------------------------------------------------
|
! ---------------------------------------------------------
|
||||||
|
! /!\ warning /!\
|
||||||
|
! this procedure is highly experimental, don't use it
|
||||||
|
! for any real (or critical) work, but it was fine for
|
||||||
|
! playing around with the #UselessGraphic concept.
|
||||||
|
|
||||||
|
subroutine genp_do_render(srcfile, tgafile, xsize, ysize)
|
||||||
|
character (len=*), intent(in) :: srcfile, tgafile
|
||||||
|
integer, intent(in) :: xsize, ysize
|
||||||
|
|
||||||
|
character (len=1664) :: cmdline
|
||||||
|
character (len=20) :: dima, dimb
|
||||||
|
integer :: i, j, errcode
|
||||||
|
|
||||||
|
if (6 .EQ. outunit) then
|
||||||
|
write(0, '(" Sorry, I can not do that, Dave !")')
|
||||||
|
stop " >>> FATAL ERROR"
|
||||||
|
endif
|
||||||
|
|
||||||
|
write(0, '("--- genp do_render ---")')
|
||||||
|
write(0, '(" srcfile: ", A)') srcfile
|
||||||
|
write(0, '(" tgafile: ", A)') tgafile
|
||||||
|
write(0, '(" picsize: ", 2I5)') xsize, ysize
|
||||||
|
|
||||||
|
write(dima, '(I5, "x", I5)') xsize, ysize
|
||||||
|
! write(0, '("dima [",A, "]")') dima
|
||||||
|
dimb = "" ; j = 1
|
||||||
|
do i=1, len(dima)
|
||||||
|
if (dima(i:i) .NE. ' ') then
|
||||||
|
dimb(j:j) = dima(i:i)
|
||||||
|
j = j +1
|
||||||
|
endif
|
||||||
|
enddo
|
||||||
|
! write(0, '("[",A, "]")') trim(dimb)
|
||||||
|
write(cmdline, '("genplot2 -s ", A, " ", A, " ", A)') &
|
||||||
|
trim(dimb), srcfile, tgafile
|
||||||
|
write(0, '(A)') trim(cmdline)
|
||||||
|
call execute_command_line(cmdline, exitstat=errcode)
|
||||||
|
write(0, '("errcode was :", I6)') errcode
|
||||||
|
|
||||||
|
end subroutine
|
||||||
! ---------------------------------------------------------
|
! ---------------------------------------------------------
|
||||||
|
|
||||||
end module genplotting
|
end module genplotting
|
||||||
|
|||||||
28
morecircles.f90
Normal file
28
morecircles.f90
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
!
|
||||||
|
! YOU LIKE CIRCLES ? TAKE IT SISTA !
|
||||||
|
!
|
||||||
|
! this crapware is released by tTh under the
|
||||||
|
! DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
||||||
|
!
|
||||||
|
|
||||||
|
program morecircles
|
||||||
|
use genplotting
|
||||||
|
implicit none
|
||||||
|
integer idx
|
||||||
|
real fdx, xp, yp, scx, scy
|
||||||
|
call genp_init(0, "WS/morecircles.scratch")
|
||||||
|
scx = 0.6 ; scy = 2.3
|
||||||
|
do idx=5, 60
|
||||||
|
fdx = real(idx)
|
||||||
|
xp = 3.5 * cos((fdx/14.0)-0.7)
|
||||||
|
yp = 3.5 * sin((fdx/10.0)+0.3)
|
||||||
|
call genp_set_offset(xp, yp)
|
||||||
|
call genp_set_scale(scx, scy)
|
||||||
|
call genp_circle(fdx, 60, 1+mod(idx, 3))
|
||||||
|
scx = scx + 0.0185
|
||||||
|
scy = scy - 0.0129
|
||||||
|
enddo
|
||||||
|
call genp_end(0)
|
||||||
|
call genp_do_render("WS/morecircles.scratch", "morecircles.tga", &
|
||||||
|
512, 512)
|
||||||
|
end program
|
||||||
@@ -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,11 +58,11 @@ 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 genp_plot_axes(10.0)
|
||||||
|
|
||||||
end subroutine
|
end subroutine
|
||||||
! ---------------------------------------------------------
|
! ---------------------------------------------------------
|
||||||
|
|||||||
61
rndwlkng.f90
Normal file
61
rndwlkng.f90
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
!
|
||||||
|
! Random Walk Next Generation
|
||||||
|
! new Fri May 8 06:53:02 AM UTC 2026
|
||||||
|
!
|
||||||
|
! this crapware is released by tTh under the
|
||||||
|
! DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
||||||
|
!
|
||||||
|
! ---------------------------------------------------------
|
||||||
|
program rndwlkng
|
||||||
|
use genplotting
|
||||||
|
implicit none
|
||||||
|
|
||||||
|
type walker
|
||||||
|
real :: xloc, yloc ! where I am ?
|
||||||
|
real :: heading ! direction in degrees
|
||||||
|
real :: powa ! correlated to nothing
|
||||||
|
end type walker
|
||||||
|
|
||||||
|
type (walker) drunky
|
||||||
|
integer pass
|
||||||
|
|
||||||
|
call srand(time())
|
||||||
|
|
||||||
|
call genp_init(0, "WS/rndwlkng.scratch")
|
||||||
|
|
||||||
|
do pass=1, 73
|
||||||
|
drunky%xloc = 5555 * (rand(0) - 0.50)
|
||||||
|
drunky%yloc = 5555 * (rand(0) - 0.50)
|
||||||
|
drunky%heading = 360 * rand(0)
|
||||||
|
drunky%powa = 6.00
|
||||||
|
call move_the_walker(drunky, 700, mod(pass, 6)+1)
|
||||||
|
end do
|
||||||
|
|
||||||
|
call genp_end(0)
|
||||||
|
call genp_do_render("WS/rndwlkng.scratch", "rndwlkng.tga", 512, 512)
|
||||||
|
|
||||||
|
contains
|
||||||
|
! ---------------------------------------------------------
|
||||||
|
subroutine move_the_walker(bob, nbmove, col)
|
||||||
|
type (walker), intent(inout) :: bob
|
||||||
|
integer, intent(in) :: nbmove, col
|
||||||
|
|
||||||
|
integer :: idx
|
||||||
|
real :: rad, mv, dx, dy
|
||||||
|
|
||||||
|
call genp_move(bob%xloc, bob%yloc)
|
||||||
|
do idx=1, nbmove
|
||||||
|
rad = ( 3.141592654 * bob%heading ) / 180.0
|
||||||
|
mv = 1.555 + (bob%powa * rand(0))
|
||||||
|
dx = mv * sin(rad)
|
||||||
|
dy = mv * cos(rad)
|
||||||
|
bob%xloc = bob%xloc + dx
|
||||||
|
bob%yloc = bob%yloc + dy
|
||||||
|
bob%heading = bob%heading + 42.42 * (rand(0) - 0.50000)
|
||||||
|
call genp_draw(bob%xloc, bob%yloc, col)
|
||||||
|
enddo
|
||||||
|
|
||||||
|
end subroutine
|
||||||
|
! ---------------------------------------------------------
|
||||||
|
end program
|
||||||
|
! ---------------------------------------------------------
|
||||||
@@ -9,12 +9,15 @@ program spirale
|
|||||||
use genplotting
|
use genplotting
|
||||||
implicit none
|
implicit none
|
||||||
|
|
||||||
|
character(*), parameter :: scratch = "WS/spirale.scratch"
|
||||||
|
|
||||||
write (0, '(A)') "----[ genplotting spirale ]----"
|
write (0, '(A)') "----[ genplotting spirale ]----"
|
||||||
|
|
||||||
call genp_init (0, 'WS/spirale.scratch')
|
call genp_init (0, scratch)
|
||||||
call do_spirale (1337, 0.51, 0.0666, 0.7, 3)
|
call do_spirale (1337, 0.51, 0.0666, 0.7, 5)
|
||||||
call do_spirale (1337, 0.42, 0.0333, 0.7, 6)
|
call do_spirale (1337, 0.42, 0.0333, 0.7, 6)
|
||||||
call genp_end (0)
|
call genp_end (0)
|
||||||
|
call genp_do_render(scratch, "WS/a.tga", 512, 512)
|
||||||
|
|
||||||
contains
|
contains
|
||||||
! ---------------------------------------------------------
|
! ---------------------------------------------------------
|
||||||
|
|||||||
@@ -1,24 +1,35 @@
|
|||||||
!
|
!
|
||||||
! 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
|
||||||
|
|
||||||
|
character(*), parameter :: scratch = "WS/starfield.scratch"
|
||||||
|
|
||||||
write (0, '(A)') "----[ genplotting starfield ]----"
|
write (0, '(A)') "----[ genplotting starfield ]----"
|
||||||
call genp_init (0, 'WS/starfield.scratch')
|
call genp_init (0, scratch)
|
||||||
call do_starfield (451)
|
call do_starfield (300)
|
||||||
call genp_end (0)
|
call genp_end (0)
|
||||||
|
call genp_do_render(scratch, "WS/a.tga", 512, 512)
|
||||||
|
|
||||||
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 at ", 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 +38,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
|
||||||
|
|||||||
18
testbed.f90
Normal file
18
testbed.f90
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
!
|
||||||
|
! TESTBED FOR GENPLOTTING90
|
||||||
|
!
|
||||||
|
! this crapware is released by tTh under the
|
||||||
|
! DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
||||||
|
!
|
||||||
|
|
||||||
|
program testbed
|
||||||
|
use genplotting
|
||||||
|
use genp_tests
|
||||||
|
implicit none
|
||||||
|
|
||||||
|
call genp_init(0, "foo.scratch")
|
||||||
|
call genp_test_rotation()
|
||||||
|
! call genp_plot_axes(5.1)
|
||||||
|
call genp_end(0)
|
||||||
|
|
||||||
|
end program
|
||||||
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