Skip to content

Instantly share code, notes, and snippets.

@pomahtuk
Created October 23, 2012 07:09
Show Gist options
  • Save pomahtuk/3937384 to your computer and use it in GitHub Desktop.
Save pomahtuk/3937384 to your computer and use it in GitHub Desktop.
Color Overlay Coffe function
@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