---------------------------> Information about this behaviour
-- [S] Change bitmap brightness and contrast behaviour
-- Behaviour written by Barry Swan
-- E-mail: gerbil@theburrow.co.uk
-- WWW: http://www.theburrow.co.uk
---------------------------> Property definitions for the behaviour
property pSN, pS
property pOldInk, pOldBGColor, pOldColor
property pBrightness
property pContrast
property pOldBrightness
property pOldContrast
---------------------------> Initialise the sprite and properties
on beginSprite me
-- Set up sprite properties
pSN = me.spriteNum
pS = sprite(pSN)
pOldInk = pS.ink
pOldBGColor = pS.bgcolor
pOldColor = pS.color
-- Set to use darken ink
pS.ink = 41
-- Set up behaviour properties (to guarantee a refresh on the first prepareFrame)
pOldBrightness = -1
pOldContrast = -1
end
---------------------------> Check for values being changed - if so update sprite
on prepareFrame me
-- Change sprite if brightness or contrast has changed
if pBrightness <> pOldBrightness OR pContrast <> pOldContrast then
me.UpdateBrightnessAndContrast()
-- Store current values
pOldBrightness = pBrightness
pOldContrast = pContrast
end if
end
---------------------------> The actual handler to change the sprite values
on UpdateBrightnessAndContrast me
tInfo = tInfo & "Drop this behaviour onto a bitmap sprite to alter it's brightness and contrast without altering the graphic itself." & RETURN
tInfo = tInfo & "Note that it uses the DARKEN ink. Therefore it will override the ink setting for the sprite in the score." & RETURN
tInfo = tInfo & "The DARKEN ink has transparency identical to MATTE ink." & RETURN & RETURN
tInfo = tInfo & "Brightness - measured as a percentage with 100% being normal. 0% is darkest, 200% is lightest." & RETURN
tInfo = tInfo & "Contrast - measured as a percentage with 100% being normal. 0% is no contrast." & RETURN & RETURN
tInfo = tInfo & "You can change the properties and the behaviour will automatically update the graphic to represent the new values." & RETURN
tInfo = tInfo & "To alter brightness change the 'pBrightness' property of the behaviour." & RETURN
tInfo = tInfo & "To alter contrast change the 'pContrast' property of the behaviour."
-- Return string
return tInfo
end
Contact
MMI
36 South Court Sq
Suite 300
Newnan, GA 30263
USA