Mac OS X - how to darken screen?

Scott Rossi scott at tactilemedia.com
Fri Sep 17 20:16:42 EDT 2010


Phil:

I don't know if you tried Klaus's suggestion (programmatically setting the
blendLevel), but you'll have more control compared to using the built-in
dissolve effect, and if I'm not mistaken the dissolve will look like crap on
Windows without QT installed.  Just a suggestion.

on mouseUp
   put the screenRect into pTargetScreenRect
   showBlackScreen pTargetScreenRect
   wait 3 seconds with messages
   send "showNormalScreen" to me
end mouseUp

command showBlackScreen pTargetScreenRect
   # pTargetScreenRect = the rect of your target screen
   -- make a 'cover' stack to fill screen
   create inv stack "screencover" -- temp stack, no need to save it
   set the backgroundColor of stack "screencover" to black
   set the blendLevel of stack "screencover" to 100 -- transparent
   palette stack "screencover" -- make this stack the frontmost layer
   set the rect of stack "screencover" to pTargetScreenRect -- size to
screen
   show stack "screencover" -- but it's still transparent
   -- make the screen go dark
   repeat with N = 19 down to 0
      set blendLevel of stack "screencover" to N * 5
      wait 20 millisecs with messages
   end repeat
end showBlackScreen

command showNormalScreen
   -- make the screen look normal again
   repeat with N = 1 to 20
      set blendLevel of stack "screencover" to N * 5
      wait 20 millisecs with messages
   end repeat
   delete stack "screencover" -- end the stack's existence
end showNormalScreen


Best Regards,

Scott Rossi
Creative Director
Tactile Media, UX Design




Recently, Phil Davis wrote:

>   Thanks so much everyone! Great tips all. Here is my final code, tested on
> Mac 
> OS X 10.5.8 and Windows 7:
> 
> command showBlackScreen pTargetScreenRect
>     # pTargetScreenRect = the rect of your target screen
> 
>     -- make a 'cover' stack to fill screen
>     create inv stack "screencover" -- temp stack, no need to save it
>     set the backgroundColor of stack "screencover" to black
>     set the blendLevel of stack "screencover" to 100 -- transparent
>     palette stack "screencover" -- make this stack the frontmost layer
>     set the rect of stack "screencover" to pTargetScreenRect -- make it same
> size as screen
>     show stack "screencover" -- but it's still transparent
> 
>     -- make the screen go dark
>     lock screen -- hide changes until all is ready for display
>     set the blendLevel of stack "screencover" to 1 -- almost opaque (0 causes
> flash on Win 7)
>     set the defaultStack to "screencover" -- to make dissolve work right
>     unlock screen with effect dissolve fast -- to reveal black stack
> end showBlackScreen
> 
> 
> 
> command showNormalScreen
>     -- make the screen look normal again
>     lock screen -- hide changes until all is ready for display
>     set the defaultStack to "screencover" -- to make dissolve work right
>     set the blendLevel of stack "screencover" to 100 -- transparent
>     unlock screen with effect dissolve fast -- to reveal normal screen
>     delete stack "screencover" -- end the stack's existence
> end showNormalScreen
> 
> 
> Best -
> Phil
> 






More information about the use-livecode mailing list