A more “playable” version of the “radiation dose map”
Posted: Mon Apr 28, 2025 5:45 am
The color “red” is used to represent radiation. The FILL ALPHA factor is used to generate the intensity grade.
In the yellow section of the code, radiation sources may be added, deleted, or modified. A wave length of zero value generates a steady, non-pulsating source.
Touching a screen position will display the local intensity (0-1) in the button in the upper right of the screen.
Touching that button will stop the program.
In the yellow section of the code, radiation sources may be added, deleted, or modified. A wave length of zero value generates a steady, non-pulsating source.
Touching a screen position will display the local intensity (0-1) in the button in the upper right of the screen.
Touching that button will stop the program.
Code: Select all
' *** Main program ***
init_prog()
n_sources=define_sources()
view(4) ' result with blocksize 4 pixels
do slowdown
get touch(0) as x,y
get pixel sc*x,sc*y color r,g,b,a
button "stop" text r ! pause .1
until button_pressed("stop")
end
def init_prog()
graphics ! graphics clear 0,0,0 ! fill color 1,0,0
set toolbar off ! option angle degrees
get screen size .sw,.sh ! .sc=screen_scale()
button "stop" text "" at 620,20 size 120,40
end def
def define_sources()
' for each source: screen location x,y, intensity, wave length
source_data:
'y'
data 250,200, 100, 20
data 450,390, 100, 40
data 300,750, 80, 0 ' non_pulsating sources
data 200,400, 50, 0
''
while data_exist() ! read x,x,x,x ! n+=1 ! end while
restore to source_data
dim .xx(n),.yy(n),.ampl(n), .freq(n)
for i=0 to n-1
read .xx(i),.yy(i),.ampl(i),.freq(i)
ampmax=max(ampmax,.ampl(i))
if .freq(i)>0 then .freq(i)=360/.freq(i)
next i
for i=0 to n-1 ! .ampl(i)/=ampmax ! next i
return n ' return # of sources
end def
def view(dw)
dw=max(dw,2) ! ds=dw/2
for x=0 to .sw step dw
for y=0 to .sh step dw
fill alpha intensity(x,y)
fill rect x-ds,y-ds to x+ds-1,y+ds-1
next y
next x
end def
def intensity(x,y)
calfa=1 ! m=300
for i=0 to .n_sources-1
dist=max(1,sqrt((.xx(i)-x)^2 + (.yy(i)-y)^2))
fac=dist/m ! if dist<m then fac=fac^2-2*fac+1 else fac=0
alf=fac*.ampl(i)*(1+cos(dist*.freq(i))/2)
calfa*=(1-alf)
next i
return 1-calfa
end def