Compare commits

..

14 Commits

Author SHA1 Message Date
Tonton Th
0bc55225fc add rotation, need more tests 2026-05-21 16:23:06 +02:00
Tonton Th
3d4fce2ed0 add links... 2026-05-17 19:49:43 +02:00
Tonton Th
ec199da8dd add more bla 2026-05-17 08:07:46 +02:00
Tonton Th
a20725f5ef Oups !!! 2026-05-17 07:51:27 +02:00
Tonton Th
42d066678d some adjustements, but need more work 2026-05-17 07:27:25 +02:00
Tonton Th
ea373fa198 fine tuning 2026-05-17 07:25:02 +02:00
Tonton Th
52e5e99b07 use the render procedure 2026-05-15 11:30:09 +02:00
Tonton Th
086c2af118 add the circles factory 2026-05-14 19:52:23 +02:00
Tonton Th
e060fad764 testing recent changes 2026-05-13 10:02:22 +02:00
Tonton Th
be961b46fc add "make me a circle" thing 2026-05-13 09:59:37 +02:00
Tonton Th
1dd0e71577 add scaling engine 2026-05-13 09:57:35 +02:00
Tonton Th
a0d63856af FIX A POTENTIAL NASTY BUG 2026-05-12 20:43:15 +02:00
Tonton Th
fce8fd4989 add an important molly-guard 2026-05-10 19:07:54 +02:00
Tonton Th
05066538ef add more bla 2026-05-10 01:48:55 +02:00
11 changed files with 263 additions and 45 deletions

1
.gitignore vendored
View File

@@ -14,4 +14,5 @@ lissajous
squarmania
testbed
rndwlkng
morecircles

View File

@@ -7,14 +7,30 @@ all: testbed
genplotting.o: genplotting.f90 Makefile
gfortran -Wall -c $<
testbed: testbed.f90 Makefile genplotting.o
gfortran -Wall $< genplotting.o -o $@
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
@@ -22,8 +38,7 @@ starfield: starfield.f90 Makefile genplotting.o
starfield.png: starfield Makefile
./starfield
genplot2 -s 512x512 WS/starfield.scratch WS/a.tga
convert WS/a.tga $@
convert -verbose WS/a.tga $@
# -----------------------------------------------
@@ -52,7 +67,6 @@ spirale: spirale.f90 Makefile genplotting.o
spirale.png: spirale Makefile
./spirale
genplot2 -s 512x512 WS/spirale.scratch WS/a.tga
convert WS/a.tga $@
# -----------------------------------------------

View File

@@ -2,11 +2,16 @@
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 ?*
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
[méthodes](https://www.tetalab.org/fr/contact) habituelles du Tetalab.

View File

@@ -7,25 +7,47 @@ who can be installed with the [libtthimage](https://git.tetalab.org/tTh/libtthim
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.
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,
if this filename is an empty string, *stdout* will be used.
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)
- `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)
- `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
View 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

View File

@@ -11,8 +11,9 @@ module genplotting
real :: xoffset, yoffset, xscale, yscale
private :: xoffset, yoffset, xscale, yscale
real :: rotation
private :: rotation
real :: rotation, rotmatrix(3,3)
private :: rotation, rotmatrix, compute_rot_matrix
private :: print_rot_matrix
integer :: outunit = 6
private :: outunit
@@ -21,7 +22,7 @@ contains
! ---------------------------------------------------------
! the first parameter _must_ be 0.
! the second can be
! - the name of a file for recoding plot instructions
! - the name of a file for recording plot instructions
! or
! - an empty string for send plot command to stdout
!
@@ -43,7 +44,8 @@ subroutine genp_init (foo, fname)
xmin = 9e9 ; xmax = -9e9
ymin = 9e9 ; ymax = -9e9
xoffset = 0.0 ; yoffset = 0.0
xscale = 0.0 ; yscale = 0.0
xscale = 1.0 ; yscale = 1.0
rotation = 0.0
end subroutine
@@ -57,10 +59,71 @@ subroutine genp_get_offset(ox, oy)
ox = xoffset ; oy = yoffset
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)
real, intent(in) :: px, py
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
if (lx .lt. xmin) xmin = lx
if (lx .gt. xmax) xmax = lx
@@ -72,7 +135,8 @@ subroutine genp_draw (px, py, color)
real, intent(in) :: px, py
integer, intent(in) :: color
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
if (lx .lt. xmin) xmin = lx
if (lx .gt. xmax) xmax = lx
@@ -95,10 +159,38 @@ subroutine genp_plot_axes(amp)
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)
integer, intent(in) :: foo
write (0, '("--- genp_end ---")')
write (0, '("------------- genp_end -------------")')
write (0, '("minmax X ", 2F18.5)') xmin, xmax
write (0, '("minmax Y ", 2F18.5)') ymin, ymax
@@ -128,6 +220,11 @@ subroutine genp_do_render(srcfile, tgafile, xsize, ysize)
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

28
morecircles.f90 Normal file
View 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

View File

@@ -11,27 +11,24 @@ program rndwlkng
implicit none
type walker
real :: xloc, yloc
real :: xloc, yloc ! where I am ?
real :: heading ! direction in degrees
real :: powa
real :: powa ! correlated to nothing
end type walker
type (walker) drunky
integer pass
drunky%xloc = 0.00
drunky%yloc = 0.00
drunky%heading = 13.37
drunky%powa = 4.00
call srand(time())
call genp_init(0, "WS/rndwlkng.scratch")
do pass=1, 100
do pass=1, 73
drunky%xloc = 5555 * (rand(0) - 0.50)
drunky%yloc = 5555 * (rand(0) - 0.50)
drunky%heading = 13.37
drunky%powa = 4.00
call move_the_walker(drunky, 1000, mod(pass, 5)+1)
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)
@@ -47,18 +44,15 @@ subroutine move_the_walker(bob, nbmove, col)
real :: rad, mv, dx, dy
call genp_move(bob%xloc, bob%yloc)
do idx=1, nbmove
rad = ( 3.141592654 * bob%heading ) / 180.0
mv = 0.5 + (bob%powa * rand(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 + 33 * (rand(0) - 0.50000)
bob%heading = bob%heading + 42.42 * (rand(0) - 0.50000)
call genp_draw(bob%xloc, bob%yloc, col)
enddo
end subroutine

View File

@@ -9,12 +9,15 @@ program spirale
use genplotting
implicit none
character(*), parameter :: scratch = "WS/spirale.scratch"
write (0, '(A)') "----[ genplotting spirale ]----"
call genp_init (0, 'WS/spirale.scratch')
call do_spirale (1337, 0.51, 0.0666, 0.7, 3)
call genp_init (0, scratch)
call do_spirale (1337, 0.51, 0.0666, 0.7, 5)
call do_spirale (1337, 0.42, 0.0333, 0.7, 6)
call genp_end (0)
call genp_do_render(scratch, "WS/a.tga", 512, 512)
contains
! ---------------------------------------------------------

View File

@@ -7,10 +7,15 @@
program starfield
use genplotting
implicit none
character(*), parameter :: scratch = "WS/starfield.scratch"
write (0, '(A)') "----[ genplotting starfield ]----"
call genp_init (0, 'WS/starfield.scratch')
call do_starfield (200)
call genp_init (0, scratch)
call do_starfield (300)
call genp_end (0)
call genp_do_render(scratch, "WS/a.tga", 512, 512)
contains
! ---------------------------------------------------------
subroutine plot_a_star(at_x, at_y, sz, color)
@@ -20,7 +25,7 @@ subroutine plot_a_star(at_x, at_y, sz, color)
integer :: idx
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)
do idx=0, 360, 36
! convert index to radians

View File

@@ -1,10 +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_plot_axes(13.37)
call genp_test_rotation()
! call genp_plot_axes(5.1)
call genp_end(0)
call genp_do_render("foo.scratch", "foo.tga", 512, 512)
end program