on renamebuttons
repeat with j = 1 to the number of castlibs
repeat with i = 1 to the number of members of castlib j
mem=member (i, j)
nm=mem.name
repeat with k = 1 to nm.length
if nm.char[k] = ''_'' then put '' '' into nm.char[k]
end repeat
mem.name=nm
end repeat
end repeat
end
if voidp (lib) then lib= the activecastlib
s=castlib (lib).selection
repeat with lyst in s
repeat with i = lyst[1] to lyst[2]
mem = member (i, lib)
nm = mem.name
off = offset (''_'', nm)
if off <> 0 then put '' '' into nm.char[off]
mem.name=nm
end repeat
end repeat
on transformbitmaps lib
if voidp (lib) then lib= the activecastlib
s=castlib (lib).selection
repeat with lyst in s
repeat with i = lyst[1] to lyst[2]
mem = member (i, lib)
if mem.type <> #bitmap then next repeat
im = mem.image
if im.depth = 32 then
im2=image (im.width, im.height, 16)
im2.copypixels (im, im.rect, im.rect)
reg = mem.regpoint
mem.image = im2
mem.regpoint = reg
end if
end repeat
end repeat
end
if voidp (lib) then lib = the activecastlib
if voidp (retain) then retain = 1
if voidp (sameplace) then sameplace = 1
s=castlib (lib).selection
repeat with lyst in s
repeat with i = lyst[1] to lyst[2]
mem=member (i, lib)
if mem.type <> #text then next repeat
if sameplace then
newmem = new (#text)
newmem.media = mem.media
newmem.name = mem.name
erase mem
mem=newmem
f=new (#field, member (i, lib))
else
f = new (#field)
end if
f.text = mem.text
f.rect=mem.rect
f.alignment = string (mem.alignment)
f.name = mem.name
repeat with k = 1 to mem.text.length
the font of char k of field f = mem.char[k].font
the fontsize of char k of field f = mem.char[k].fontsize
s = mem.char[k].fontstyle
tx = ''''
repeat with sym in s
tx = tx & sym & '',''
end repeat
if tx.length > 0 then
delete tx.char[tx.length]
the fontstyle of char k of field f = tx
end if
end repeat
if not retain then erase mem
end repeat
end repeat
v=new (#vectorshape)
v.vertexlist = [[#vertex: point (0, 0)], [#vertex: point (0, w)], [#vertex: point
(w, w)],
[#vertex: point (w, 0)]]
if voidp (bg) then bg = rgb (255, 255, 255)
if voidp (col) then col = rgb (0, 0, 0)
if voidp (s) then s = 1
v.backgroundcolor = bg
v.strokecolor = col
v.strokewidth = s
v.closed = 1
v.fillmode = #none
mem = new (#bitmap)
mem.image = v.image
mem.name = string (nm)
erase v
end
这个例子相当的简单,但是你可以用这个程序很长时间。那么,这个怎么样:一种画曲径的方法。我们用这种形式的数据清单供给它:[[1,2],[0,1]]。每一个数字代表曲径里一个单一的正方形,and has a value representing whether there is a wall to the right or to the
right or to the bottom of that square.
因此:
on drawmaze m, w
if voidp (w) then w = 20
vert = m.count
hor = m[1].count
maze = image (w * hor + 1, w * vert + 1, 16)
repeat with i = 1 to vert
repeat with j = 1 to hor
sq = m[ i ][j]
if sq mod 2 or i = vert then maze.draw ((j - 1) * w, i * w, j * w, i * w + 1,
rgb (0, 0, 0))
if sq > 1 or j = hor then maze.draw (j * w, (i - 1) * w, j * w + 1, i * w, rgb
(0, 0, 0))
end repeat
end repeat
maze.draw (0, 0, 1, w * vert, rgb (0, 0, 0))
maze.draw (0, 0, w * hor, 1, rgb (0, 0, 0))