Contents
Articles
Behaviors
Books
Director News
Director Web Sites
FAQ
Games
Mailing Lists
News Groups
Project Examples
Reviews
Software
Tools
Useful Web Sites
Utilities
Xtras

Don't miss these
Border Xtra
Set Properties of a Flash Member
3state Button with Cursor change
Blur Rollover-Alphamania
Mastering Macromedia Dreamweaver 3
Power Blender
Scroll Sprite by MouseLoc Behavior
Combinations and Permutations
Domicilia
cXtraPieChart
 

 

 

Behavior Tint bitmap behaviour

Added on 4/4/2001

 

Compatibilities:
behavior D7 D8 Mac PC Shockwave

Rating:

Author: BarrySwan (website)

Tints a bitmap

---------------------------> Information about this behaviour
-- [S] Tint bitmap 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 pRed, pGreen, pBlue

property pOldRed, pOldGreen, pOldBlue

---------------------------> 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)
  pOldRed = -1
  pOldGreen = -1
  pOldBlue = -1
  
end

---------------------------> Check for values being changed - if so update sprite
on prepareFrame me
  
  -- Change sprite if brightness or contrast has changed
  if pRed <> pOldRed OR pGreen <> pOldGreen OR pBlue <> pOldBlue then
    me.UpdateTint()
    
    -- Store current values
    pOldRed = pRed
    pOldGreen = pGreen
    pOldBlue = pBlue
  end if
  
end

---------------------------> The actual handler to change the sprite values
on UpdateTint me
  
  -- Apply tint
  tBGRed = pRed * 256 / 100
  tBGGreen = pGreen * 256 / 100
  tBGBlue = pBlue * 256 / 100
  
  -- Clip values
  tFGRed = max(tBGRed - 256, 0)
  tFGGreen = max(tBGGreen - 256, 0)
  tFGBlue = max(tBGBlue - 256, 0)
  
  tBGRed = min(tBGRed, 255)
  tBGGreen = min(tBGGreen, 255)
  tBGBlue = min(tBGBlue, 255)
  
  -- Set sprite values
  pS.bgcolor = rgb(tBGRed, tBGGreen, tBGBlue)
  pS.color = rgb(tFGRed, tFGGreen, tFGBlue)
  
end

---------------------------> Reset the sprite when finished
on endSprite me
  
  -- Restore the old sprite values
  pS.ink = pOldInk
  pS.bgcolor = pOldBGColor
  pS.color = pOldColor
  
end

---------------------------> Input the initial property values
on getPropertyDescriptionList me
  
  -- Set up list
  tlData = [:]
  
  -- Options for red
  tlData[#pRed] = [¬
      #format: #integer,¬
      #default: 100,¬
      #range: [#min: 0, #max: 200],¬
      #comment: "Red intensity (measured in percentage with 100% being no change):"¬
  ]
  
  -- Options for green
  tlData[#pGreen] = [¬
      #format: #integer,¬
      #default: 100,¬
      #range: [#min: 0, #max: 200],¬
      #comment: "Green intensity (measured in percentage with 100% being no change):"¬
  ]
  
  -- Options for blue
  tlData[#pBlue] = [¬
      #format: #integer,¬
      #default: 100,¬
      #range: [#min: 0, #max: 200],¬
      #comment: "Blue intensity (measured in percentage with 100% being no change):"¬
  ]
  
  -- Return list
  return tlData
  
end

---------------------------> Description of the behaviour in the behaviour inspector
on getBehaviorDescription me
  
  -- Create description string
  tInfo = "[S] Tint bitmap behaviour" & RETURN & RETURN
  
  tInfo = tInfo & "Behaviour by Barry Swan" & RETURN
  tInfo = tInfo & "E-mail: gerbil@theburrow.co.uk" & RETURN
  tInfo = tInfo & "www:    www.theburrow.co.uk" & RETURN & RETURN
  
  tInfo = tInfo & "Drop this behaviour onto a bitmap sprite to alter it's tint 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 & "Parameters are:" & RETURN & RETURN
  
  tInfo = tInfo & "Red intensity - measured as a percentage with 100% being normal. 0% is none, 200% is maximum oversaturation." & RETURN
  tInfo = tInfo & "Green intensity - measured as a percentage with 100% being normal. 0% is none, 200% is maximum oversaturation." & RETURN
  tInfo = tInfo & "Blue intensity - measured as a percentage with 100% being normal. 0% is none, 200% is maximum oversaturation." & 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 the red intensity change the 'pRed' property of the behaviour." & RETURN
  tInfo = tInfo & "To alter the green intensity change the 'pGreen' property of the behaviour." & RETURN
  tInfo = tInfo & "To alter the blue intensity change the 'pBlue' property of the behaviour."
  
  -- Return string
  return tInfo
  
end

 


Contact

MMI
36 South Court Sq
Suite 300
Newnan, GA 30263
USA

Send e-mail