Created
October 23, 2012 07:09
-
-
Save pomahtuk/3937384 to your computer and use it in GitHub Desktop.
Color Overlay Coffe function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@count_overlay = (color, overlay) -> | |
# First part: If Lower Layer Value > 127.5, then do the following - | |
# Value Unit = (255-Lower Layer Value)/127.5 | |
# Min Value = Lower Layer Value - (255-Lower Layer Value) | |
# Overlay = (Upper Layer Value * Value Unit) + Min Value | |
# Second part: If Lower Layer Value < 127.5, then do the following - | |
# Value Unit=Lower Layer Value/127.5 | |
# Overlay = Upper Layer Value * Value Unit | |
color = parseInt(color) | |
overlay = parseInt(overlay) | |
if color > 127.5 | |
val_unit = (255 - color)/127.5 | |
min_val = color - (255 - color) | |
overlay_val = (overlay*val_unit) + min_val | |
else | |
val_unit = color/127.5 | |
overlay_val = overlay*val_unit | |
Math.round overlay_val |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment