![]() ruby's art pad code snippet | show it | return | |
on startMovie
global toolBox
-- list of movie handlers for different drawing routines
set toolBox= ["swingLine", "circleFun", "spotMaker", "seeStars"]
end startMovie
on makeArt
global toolBox, theTool
-- call the drawing handlers based upon curent value of theTool
if NOT inside ( point( the mouseH, the mouseV), the rect of sprite 3) then
-- start drawing as long as we are starting in the canvas area
-- call the appropriate handler for trails drawing
do getAt(toolBox,theTool)
-- "jiggle" the tools area in case user has drawn over it
set the locH of sprite 2 to -200
set the visible of sprite 3 to 0
set the visible of sprite 3 to 1
updateStage
end if
end
on SpotMaker
-- makes spray paint patterns, random size and color
-- update the drawing sprite
set the castNum of sprite 2 = cast "spots1"
-- draw while mouse is held
repeat while the stillDown
put random(40) into theSize
set the width of sprite 2 to 1 + theSize
set the height of sprite 2 to 1 + theSize
set the locH of sprite 2 to the mouseH
set the locV of sprite 2 to the mouseV
set the foreColor of sprite 2 to random(255)
updateStage
end repeat
end
|
| The movie has four different handlers for doing different drawing techniques; by storing the handler names in a list, it would be easy to add new handlers. A mousedown on any of the tool buttons calls the makeArt handler which then calls the appropriate drawing handler. lingo era = v4-5 Obviously this could be more comapctly written in D7 Lingo. Use of stillDown, castNum is old Lingo |