- Jump To … +
  analyze.coffee autoload.coffee blender.coffee calculate.coffee caman.coffee convert.coffee event.coffee filter.coffee io.coffee layer.coffee logger.coffee module.coffee pixel.coffee plugin.coffee renderer.coffee store.coffee util.coffee blenders.coffee filters.coffee size.coffee blur.coffee camera.coffee compoundBlur.coffee edges.coffee posterize.coffee presets.coffee rotate.coffee stackBlur.coffee threshold.coffee

- # threshold.coffee

- ¶

      Caman.Filter.register "threshold", (adjust) ->
        @process "threshold", (rgba) ->
          luminance = (0.2126 * rgba.r) + (0.7152 * rgba.g) + (0.0722 * rgba.b)

          if luminance < adjust
            rgba.r = 0
            rgba.g = 0
            rgba.b = 0
          else
            rgba.r = 255
            rgba.g = 255
            rgba.b = 255

          rgba