// @flow

import { RANGE } from "constants/controlTypes";

import type { ColorRGBA } from "types";

const optionTypes = {
  levels: { type: RANGE, range: [1, 256], default: 2 }
};

const defaults = {
  levels: optionTypes.levels.default
};

// Gets nearest color
const getColor = (
  color: ColorRGBA,
  options: { levels: number } = defaults
): ColorRGBA => {
  const step = 255 / (options.levels - 1);

  // $FlowFixMe
  return color.map(c => {
    const bucket = Math.round(c / step);
    return Math.round(bucket * step);
  });
};

export default {
  name: "nearest",
  getColor,
  options: defaults,
  optionTypes,
  defaults
};

@@ -354,16 +354,70 @@
 BA =%3E %7B%0A
+  if (options.levels %3E= 256) %7B%0A    return color;%0A  %7D%0A%0A
   const 

Return early if full colour