Compare commits
2 Commits
daa0d0765f
...
392d9f1b81
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
392d9f1b81 | ||
|
|
485f2f646d |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -7,4 +7,5 @@
|
||||
!picz/*.png
|
||||
|
||||
spirale
|
||||
starfield
|
||||
|
||||
|
||||
5
Makefile
5
Makefile
@@ -8,6 +8,11 @@ genplotting.o: genplotting.f90 Makefile
|
||||
|
||||
# -----------------------------------------------
|
||||
|
||||
starfield: starfield.f90 Makefile genplotting.o
|
||||
gfortran -Wall $< genplotting.o -o $@
|
||||
|
||||
# -----------------------------------------------
|
||||
|
||||
spirale: spirale.f90 Makefile genplotting.o
|
||||
gfortran -Wall $< genplotting.o -o $@
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
! SPIRALING...
|
||||
! THE GENPLOTTING MODULE
|
||||
!
|
||||
! new Thu Apr 23 01:13.37 PM UTC 2026
|
||||
!
|
||||
module genplotting
|
||||
@@ -31,23 +32,36 @@ subroutine genp_init (foo, fname)
|
||||
xscale = 0.0 ; yscale = 0.0
|
||||
end subroutine
|
||||
! ---------------------------------------------------------
|
||||
subroutine genp_set_offset(ox, oy)
|
||||
real, intent(in) :: ox, oy
|
||||
xoffset = ox ; yoffset = oy
|
||||
end subroutine
|
||||
subroutine genp_get_offset(ox, oy)
|
||||
real, intent(out) :: ox, oy
|
||||
ox = xoffset ; oy = yoffset
|
||||
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
|
||||
real :: lx, ly
|
||||
lx = px + xoffset ; ly = py + yoffset
|
||||
write (outunit, '(2F12.5, I5)') lx, ly, -1
|
||||
if (lx .lt. xmin) xmin = lx
|
||||
if (lx .gt. xmax) xmax = lx
|
||||
if (ly .lt. ymin) ymin = ly
|
||||
if (ly .gt. ymax) ymax = ly
|
||||
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
|
||||
real :: lx, ly
|
||||
lx = px + xoffset ; ly = py + yoffset
|
||||
write (outunit, '(2F12.5, I5)') lx, ly, color
|
||||
if (lx .lt. xmin) xmin = lx
|
||||
if (lx .gt. xmax) xmax = lx
|
||||
if (ly .lt. ymin) ymin = ly
|
||||
if (ly .gt. ymax) ymax = ly
|
||||
end subroutine
|
||||
! ---------------------------------------------------------
|
||||
! ---------------------------------------------------------
|
||||
|
||||
47
starfield.f90
Normal file
47
starfield.f90
Normal file
@@ -0,0 +1,47 @@
|
||||
program starfield
|
||||
use genplotting
|
||||
implicit none
|
||||
|
||||
write (0, '(A)') "----[ genplotting starfield ]----"
|
||||
|
||||
call genp_init (0, 'starfield.scratch')
|
||||
call do_starfield (105)
|
||||
call genp_end (0)
|
||||
|
||||
contains
|
||||
! ---------------------------------------------------------
|
||||
subroutine plot_a_star(at_x, at_y, sz, col)
|
||||
real, intent(in) :: at_x, at_y, sz
|
||||
integer, intent(in) :: col
|
||||
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, 30
|
||||
rad = 0.04 + (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, col)
|
||||
enddo
|
||||
|
||||
end subroutine
|
||||
! ---------------------------------------------------------
|
||||
subroutine do_starfield (nbstar)
|
||||
integer, intent(in) :: nbstar
|
||||
|
||||
integer idx, color
|
||||
real px, py, sz
|
||||
|
||||
do idx=0, nbstar
|
||||
px = (rand(0) * 10.00) - 5.00
|
||||
py = (rand(0) * 10.00) - 5.00
|
||||
sz = (rand(0) * 0.16) + 0.19
|
||||
color = 1 + mod(idx, 7)
|
||||
call plot_a_star(px, py, sz, color)
|
||||
end do
|
||||
end subroutine
|
||||
! ---------------------------------------------------------
|
||||
! ---------------------------------------------------------
|
||||
end program
|
||||
Reference in New Issue
Block a user