Re: [LogoForum] The FILL Command
The message below is being cross-posted from LogoForum.
Oops; the output from my previous program was the number
of recursive calls.
Here is the corrected program:
to aa :n :size
; :n - number of sides of polygon
; :size - side length of polygon
;
cs
bitload "boundary.bmp
pu ht setpc 0
local[theta phi p_radius r.total]
make "r.total 0
make "theta 360/:n
make "phi (90-:theta/2)
make "p_radius :size/(2*cos :phi)
rt 180-:phi fd :p_radius lt 180-:phi
tile 1
(show "|Number of polygons used = | :r.total "FINISHED)
end
to poly :dir
local "p
pd
(repeat :n
[fd :size lt :dir*:theta])
pu
setfc ifelse :dir<0[2][4]
make "p list pos heading
lt :dir*:phi fd :p_radius fill
make "r.total :r.total+1
setpos first :p seth last :p
end
to probe? :dir
local [p c]
make "p list pos heading
lt :dir*:phi fd :p_radius
make "c pixel=7 ;(and pixel=7 :radius>distance [0 0])
setpos first :p seth last :p
op :c
end
to tile :dir
ifelse probe? :dir [poly :dir][stop]
(repeat :n
[tile -1*:dir
fd :size lt :dir*:theta
])
end
By modifying the above the number of pixels enclosed
within a boundary can be found, but the relationship
between this number and the enclosed area is not simple!
to aa
cs
bitload "boundary.bmp
pu ht setpc 0
localmake "r.total 0
tile 1
(show "|Number of pixels present = | :r.total "FINISHED)
end
to tile :dir
ifelse pixel=7 [setpixel 4 make "r.total :r.total+1][stop]
(repeat 4
[tile -1*:dir
fd 1 lt :dir*90
])
end
For both programs a thick boundary line is advisible.
Mike
---- Original Message -----
From: "gvandemark1" <gvandemark@xxxxxxxxxxxxx>
To: <LogoForum@xxxxxxxxxxxxxxx>
Sent: Tuesday, January 24, 2006 4:54 AM
Subject: [LogoForum] The FILL Command
I am trying to develop a method for determining the "area" of an
irregular shape. When the FILL command is called to fill in an
enclosed space, does it return a value representing the number of
pixels that were filled?
If not, is there any way to compute, at least approximately, the
number of pixels within a fill area?
Thanks in advance for your help.
LogoForum messages are archived at:
http://groups.yahoo.com/group/LogoForum
.