- 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

- # posterize.coffee

- ¶

      Caman.Filter.register "posterize", (adjust) ->
        numOfAreas = 256 / adjust
        numOfValues = 255 / (adjust - 1)

        @process "posterize", (rgba) ->
          rgba.r = Math.floor Math.floor(rgba.r / numOfAreas) * numOfValues
          rgba.g = Math.floor Math.floor(rgba.g / numOfAreas) * numOfValues
          rgba.b = Math.floor Math.floor(rgba.b / numOfAreas) * numOfValues
          rgba