Color-palette popup
4662
function( popup, forecolor )
        {
            // http://stackoverflow.com/questions/17242144/javascript-convert-hsb-hsv-color-to-rgb-accurately
            var HSVtoRGB = function( h, s, v )
            {
                var r, g, b, i, f, p, q, t;
                i = Math.floor(h * 6);
                f = h * 6 - i;
                p = v * (1 - s);
                q = v * (1 - f * s);
                t = v * (1 - (1 - f) * s);
                switch (i % 6)
                {
                    case 0: r = v, g = t, b = p; break;
                    case 1: r = q, g = v, b = p; break;
                    case 2: r = p, g = v, b = t; break;
                    case 3: r = p, g = q, b = v; break;
                    case 4: r = t, g = p, b = v; break;
                    case 5: r = v, g = p, b = q; break;
                }
                var hr = Math.floor(r * 255).toString(16);
                var hg = Math.floor(g * 255).toString(16);
                var hb = Math.floor(b * 255).toString(16);
                return '#' + (hr.length < 2 ? '0' : '') + hr +
                             (hg.length < 2 ? '0' : '') + hg +
                             (hb.length < 2 ? '0' : '') + hb;
            };
            // create table
            var table = document.createElement('table');
            table.style.borderCollapse = 'collapse';
            for( var row=1; row < 15; ++row ) // should be '16' - but last line looks so dark
            {
                var tr = document.createElement('tr');
                for( var col=0; col < 25; ++col ) // last column is grayscale
                {
                    var color;
                    if( col == 24 )
                    {
                        var gray = Math.floor(255 / 13 * (14 - row)).toString(16);
                        var hexg = (gray.length < 2 ? '0' : '') + gray;
                        color = '#' + hexg + hexg + hexg;
                    }
                    else
                    {
                        var hue        = col / 24;
                        var saturation = row <= 8 ? row     /8 : 1;
                        var value      = row  > 8 ? (16-row)/8 : 1;
                        color = HSVtoRGB( hue, saturation, value );
                    }
                    var td = document.createElement('td');
                    td.style.width = '0.5em';
                    td.style.height = '0.5em';
                    td.style.cursor = 'pointer';
                    td.style.backgroundColor = color;
                    td.title = color;
                    td.style.userSelect = 'none';
                    addEvent( td, 'click', function( e )
                        {
                            var color = this.title;
                            if( forecolor )
                                commands.forecolor( color ).closePopup().collapseSelection();
                            else
                                commands.highlight( color ).closePopup().collapseSelection();
                        });
                    tr.appendChild( td );
                }
                table.appendChild( tr );
            }
            popup.appendChild( table );
        }
821263
function colorRangeBox(selection, label) {
  selection
      .classed('form-row', true)
      .classed('form-group', true)
      .classed('align-items-center', true);
  selection.append('div')
      .classed('col-form-label', true)
      .classed('col-form-label-sm', true)
      .text(label);

  const minBox = selection.append('div');
  minBox.append('label').text('min');
  minBox.append('input').classed('min', true);

  const midBox = selection.append('div');
  midBox.append('label').text('mid');
  midBox.append('input').classed('mid', true);

  const maxBox = selection.append('div');
  maxBox.append('label').text('max');
  maxBox.append('input').classed('max', true);

  selection.on('change', () => {
    // avoid update by mousemove on the colorpicker
    d3.event.stopPropagation();
  });

  selection.selectAll('div')
      .classed('form-group', true)
      .classed('col-3', true)
      .classed('mb-0', true);

  selection.selectAll('label')
      .classed('col-form-label', true)
      .classed('col-form-label-sm', true)
      .classed('py-0', true);

  selection.selectAll('input')
      .classed('form-control', true)
      .classed('form-control-sm', true)
      .attr('type', 'color');
}
757782
def _on_click(self, event):
        """"""
        x = event.x
        y = event.y
        self.coords('cross_h', 0, y, self.winfo_width(), y)
        self.coords('cross_v', x, 0, x, self.winfo_height())
        self.event_generate("<<ColorChanged>>")
1274111
public void onClick(Widget widget) {

        if (widget == m_rbHue) {
            if (m_colorMode != CmsSliderBar.HUE) {
                m_colorMode = CmsSliderBar.HUE;
                m_slidermap.setColorSelectMode(CmsSliderBar.HUE);
                m_sliderbar.setColorSelectMode(CmsSliderBar.HUE);
                m_slidermap.setOverlayOpacity(100);
                m_sliderbar.setLayerOpacity(100, CmsSliderBar.COLORBAR_D);
            }

            try {
                CmsColor color = new CmsColor();
                color.setHSV(m_hue, 100, 100);
                m_slidermap.setOverlayColor("#" + color.getHex());
            } catch (Exception e) {
                // do something.
            }

            m_sliderbar.setSliderPosition(256 - (int)((new Integer(m_hue).floatValue() / 360) * 256));
            m_slidermap.setSliderPosition(
                (int)((new Integer(m_saturation).floatValue() / 100) * 256),
                256 - (int)((new Integer(m_brightness).floatValue() / 100) * 256));
        } else if (widget == m_rbSaturation) {
            if (m_colorMode != CmsSliderBar.SATURATIN) {
                m_colorMode = CmsSliderBar.SATURATIN;
                m_slidermap.setColorSelectMode(CmsSliderBar.SATURATIN);
                m_sliderbar.setColorSelectMode(CmsSliderBar.SATURATIN);
                m_slidermap.setOverlayColor("transparent");
                m_sliderbar.setLayerOpacity(100, CmsSliderBar.COLORBAR_D);
            }

            try {
                CmsColor color = new CmsColor();
                color.setHSV(m_hue, 100, m_brightness);
                m_sliderbar.setLayerColor("#" + color.getHex(), CmsSliderBar.COLORBAR_D);
            } catch (Exception e) {
                // do something.
            }

            m_slidermap.setOverlayOpacity(100 - m_saturation);

            m_sliderbar.setSliderPosition(256 - (int)((new Integer(m_saturation).floatValue() / 100) * 256));
            m_slidermap.setSliderPosition(
                (int)((new Integer(m_hue).floatValue() / 360) * 256),
                256 - (int)((new Integer(m_brightness).floatValue() / 100) * 256));
        } else if (widget == m_rbBrightness) {
            if (m_colorMode != CmsSliderBar.BRIGHTNESS) {
                m_colorMode = CmsSliderBar.BRIGHTNESS;
                m_slidermap.setColorSelectMode(CmsSliderBar.BRIGHTNESS);
                m_sliderbar.setColorSelectMode(CmsSliderBar.BRIGHTNESS);
                m_slidermap.setUnderlayColor("#000000");
                m_slidermap.setOverlayColor("transparent");
                m_sliderbar.setLayerOpacity(100, CmsSliderBar.COLORBAR_D);
            }

            try {
                CmsColor color = new CmsColor();
                color.setHSV(m_hue, m_saturation, 100);
                m_sliderbar.setLayerColor("#" + color.getHex(), CmsSliderBar.COLORBAR_D);
            } catch (Exception e) {
                // do something.
            }

            m_slidermap.setOverlayOpacity(m_brightness);

            m_sliderbar.setSliderPosition(256 - (int)((new Integer(m_brightness).floatValue() / 100) * 256));
            m_slidermap.setSliderPosition(
                (int)((new Integer(m_hue).floatValue() / 360) * 256),
                256 - (int)((new Integer(m_saturation).floatValue() / 100) * 256));
        } else if (widget == m_rbRed) {
            if (m_colorMode != CmsSliderBar.RED) {
                m_colorMode = CmsSliderBar.RED;
                m_slidermap.setColorSelectMode(CmsSliderBar.RED);
                m_sliderbar.setColorSelectMode(CmsSliderBar.RED);
            }
            m_slidermap.setOverlayOpacity(percentOf(m_red, 100));

            m_sliderbar.setSliderPosition(256 - m_red);
            m_slidermap.setSliderPosition(m_blue, 256 - m_green);
        } else if (widget == m_rbGreen) {
            if (m_colorMode != CmsSliderBar.GREEN) {
                m_colorMode = CmsSliderBar.GREEN;
                m_slidermap.setColorSelectMode(CmsSliderBar.GREEN);
                m_sliderbar.setColorSelectMode(CmsSliderBar.GREEN);
            }

            m_slidermap.setOverlayOpacity(percentOf(m_green, 100));

            m_sliderbar.setSliderPosition(256 - m_green);
            m_slidermap.setSliderPosition(m_blue, 256 - m_red);
        } else if (widget == m_rbBlue) {
            if (m_colorMode != CmsSliderBar.BLUE) {
                m_colorMode = CmsSliderBar.BLUE;
                m_slidermap.setColorSelectMode(CmsSliderBar.BLUE);
                m_sliderbar.setColorSelectMode(CmsSliderBar.BLUE);
            }

            m_slidermap.setOverlayOpacity(percentOf(m_blue, 100));

            m_sliderbar.setSliderPosition(256 - m_blue);
            m_slidermap.setSliderPosition(m_red, 256 - m_green);
        }

        if ((m_colorMode == CmsSliderBar.RED)
            || (m_colorMode == CmsSliderBar.GREEN)
            || (m_colorMode == CmsSliderBar.BLUE)) {
            int x = 0;
            int y = 0;

            if (m_colorMode == CmsSliderBar.RED) {
                x = m_blue;
                y = m_green;
            }

            if (m_colorMode == CmsSliderBar.GREEN) {
                x = m_blue;
                y = m_red;
            }

            if (m_colorMode == CmsSliderBar.BLUE) {
                x = m_red;
                y = m_green;
            }

            int horzPer = (int)((new Float(x).floatValue() / 256) * 100);
            int vertPer = (int)((new Float(y).floatValue() / 256) * 100);
            int horzPerRev = (int)(((256 - new Float(x).floatValue()) / 256) * 100);
            int vertPerRev = (int)(((256 - new Float(y).floatValue()) / 256) * 100);

            if (vertPerRev > horzPerRev) {
                m_sliderbar.setLayerOpacity(horzPerRev, CmsSliderBar.COLORBAR_D);
            } else {
                m_sliderbar.setLayerOpacity(vertPerRev, CmsSliderBar.COLORBAR_D);
            }
            if (vertPerRev > horzPer) {
                m_sliderbar.setLayerOpacity(horzPer, CmsSliderBar.COLORBAR_C);
            } else {
                m_sliderbar.setLayerOpacity(vertPerRev, CmsSliderBar.COLORBAR_C);
            }
            if (vertPer > horzPer) {
                m_sliderbar.setLayerOpacity(horzPer, CmsSliderBar.COLORBAR_B);
            } else {
                m_sliderbar.setLayerOpacity(vertPer, CmsSliderBar.COLORBAR_B);
            }
            if (vertPer > horzPerRev) {
                m_sliderbar.setLayerOpacity(horzPerRev, CmsSliderBar.COLORBAR_A);
            } else {
                m_sliderbar.setLayerOpacity(vertPer, CmsSliderBar.COLORBAR_A);
            }
        }
    }
572528
static void tintWidget(@NonNull ProgressBar progressBar, @ColorInt int color) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            ColorStateList tint = ColorStateList.valueOf(color);
            progressBar.setIndeterminateTintList(tint);
        }
    }
962787
def palette():
    """"""
    for i in range(0, 16):
        if i % 8 == 0:
            print()

        if i > 7:
            i = "8;5;%s" % i

        print("\033[4%sm%s\033[0m" % (i, " " * (80 // 20)), end="")

    print("\n")
36459
function _retrieveColor(palette, color, hue = '500', format) {
    if (typeof palette !== 'string' || typeof color !== 'string' || typeof hue !== 'string' || typeof format !== 'string') {
        throw new TypeError('Expected a string');
    }

    let hexColor;
    let result;

    try {
        hexColor = (palette === 'md') ? colors[palette][color][hue].hex : colors[palette][color];

        switch (format) {
            case 'rgb':
                result = _toRGB(hexColor);
                result = `rgb(${result.r}, ${result.g}, ${result.b})`;
                break;
            case 'hex':
                result = `#${hexColor}`;
                break;
            case 'raw':
                result = _toRGB(hexColor);
                result.hex = hexColor;
                break;
            default:
        }
    } catch (err) {
        throw new RangeError('No matching color.');
    }
    return result;
}
1053032
def palette(fg, bg=-1):
    

    if not hasattr(palette, "counter"):
        palette.counter = 1

    if not hasattr(palette, "selections"):
        palette.selections = {}

    selection = "%s%s" % (str(fg), str(bg))
    if not selection in palette.selections:
        palette.selections[selection] = palette.counter
        palette.counter += 1

    # Get available colours
    colors = [c for c in dir(_curses) if c.startswith('COLOR')]
    if isinstance(fg, str):
        if not "COLOR_"+fg.upper() in colors:
            fg = -1
        else:
            fg = getattr(_curses, "COLOR_"+fg.upper())
    if isinstance(bg, str):
        if not "COLOR_"+bg.upper() in colors:
            bg = -1
        else:
            bg = getattr(_curses, "COLOR_"+bg.upper())

    _curses.init_pair(palette.selections[selection], fg, bg)
    return _curses.color_pair(palette.selections[selection])
647461
def make_palette(self):
        

        p = array('B')
        t = array('B')

        for x in self.palette:
            p.extend(x[0:3])
            if len(x) > 3:
                t.append(x[3])
        p = tostring(p)
        t = tostring(t)
        if t:
            return p,t
        return p,None
612199
def detect_palette_support(basic_palette=None):
    ''' 
    '''
    result = col_init = win_enabled = None
    TERM = env.TERM or ''
    if os_name == 'nt':
        from .windows import (is_ansi_capable, enable_vt_processing,
                              is_colorama_initialized)
        if is_ansi_capable():
            win_enabled = all(enable_vt_processing())
        col_init = is_colorama_initialized()

    # linux, older Windows + colorama
    if TERM.startswith('xterm') or (TERM == 'linux') or col_init:
            result = 'basic'

    # xterm, fbterm, older Windows + ansicon
    if ('256color' in TERM) or (TERM == 'fbterm') or env.ANSICON:
        result = 'extended'

    # https://bugzilla.redhat.com/show_bug.cgi?id=1173688 - obsolete?
    if env.COLORTERM in ('truecolor', '24bit') or win_enabled:
        result = 'truecolor'

    # find the platform-dependent 16-color basic palette
    pal_name = 'Unknown'
    if result and not basic_palette:
        result, pal_name, basic_palette = _find_basic_palette(result)

    try:
        import webcolors
    except ImportError:
        webcolors = None

    log.debug(
        f'{result!r} ({os_name}, TERM={env.TERM or ""}, '
        f'COLORTERM={env.COLORTERM or ""}, ANSICON={env.ANSICON}, '
        f'webcolors={bool(webcolors)}, basic_palette={pal_name})'
    )
    return (result, basic_palette)
737354
function colorjs() {
		//TODO assert props?
		var mw = core.base();

		mw.error = function (str) {
			return String(str).red;
		};
		mw.warning = function (str) {
			return String(str).yellow;
		};
		mw.success = function (str) {
			return String(str).green;
		};
		mw.accent = function (str) {
			return String(str).cyan;
		};
		mw.signal = function (str) {
			return String(str).magenta;
		};
		mw.muted = function (str) {
			return String(str).grey;
		};
		mw.plain = function (str) {
			return String(str);
		};
		mw.toString = function () {
			return '<ministyle-colorjs>';
		};
		return mw;
	}
394134
function(ui)
              {
                try
                {
                  var all = ui.val('all');
                  activePreview.css({ backgroundColor: all && '#' + all.hex || 'transparent' });
                  setAlpha.call($this, activePreview, all && Math.precision((all.a * 100) / 255, 4) || 0);
                }
                catch (e) { }
              }
648601
function show(options) {
    if (!options.message) {
      return;
    }

    prepare_();

    let notify = null;

    const time = options.time || 8000;

    switch (options.type) {
      case 'confirm':
        notify = draw.confirm(options);
        break;

      case 'prompt':
        notify = draw.prompt(options);
        break;

      default:
        notify = draw.alert(options);

        window.setTimeout(function () {
          notify.remove();
        }, time);
    }

    wrapper_.appendChild(notify);
    notify.classList.add(bounceInClass);
  }
694713
function (xy, yz) { // function for pure rendering. No rendering elsewhere!!
    var CP = colorPicker.CP,
      cP = colorPicker.cP,
      a = 0,
      b = 0,
      c = 0,
      ctrDif, colDif, tmpHSV, nCtr, nrCtr, cPCtr, WS; // cP & CP = scope shifting
    // display all the nice colors in sliders
    if (xy) { // left slider -> right
      if (CP.xyz[0] > CP.xyz[1]) b = 1;
      else a = 1;
      if (CP.mode == 'S' || CP.mode == 'V') {
        cP.cPSR2s.backgroundColor = 'rgb(' + HSV2RGB(CP.xyz[0], 255, 255) + ')';
        b = 1;
        c = 255
      } else if (CP.mode != 'H' && !CP.modeRGB[CP.mode]) cP.cPSR2.className = 'cPSR' + (2 + a) + CP.mode + ' cPOP' + Math.round((CP.xyz[a] - CP.xyz[b]) / (255 - CP.xyz[b]) * 100 || 0);
      if (CP.mode != 'H' && !CP.modeRGB[CP.mode]) cP.cPSR3.className = 'cPSR4' + CP.mode + ' cPOP' + Math.round(Math.abs(c - CP.xyz[b]) / 2.55);
      cP.cPSLCs.cssText = 'left:' + (CP.xyz[0] / sX - 5) + 'px;top:' + Math.ceil(250 - CP.xyz[1] / sX / sZ - xyzCorr) + 'px'; // change cursor
    }
    if (!xy || yz) { // right slider -> left
      if (CP.mode == 'H') {
        tmpHSV = HSV2RGB(CP.xyz[2], 255, 255);
        cP.cPSL1s.backgroundColor = 'rgb(' + tmpHSV + ')'
      } else cP.cPSL3.className = 'cPSL3' + CP.mode + ' cPOP' + (100 - Math.round(CP.xyz[2] / 2.55));
      cP.cPSRCLs.top = c = +Math.ceil(252 - CP.xyz[2] / sX / sZ - xyzCorr) + 'px'; // change right-left cursor ... recycle var c
      if (yz) cP.cPSRCRs.top = c; // change right-right cursor
    }

    // switch brightness if contrast changes
    cPCtr = getBrightness(CP.rgbRND);
    nCtr = cPCtr > 128;
    if (cCtr !== nCtr) {
      if (nCtr) {
        if (expColor) cP.cObjs.color = '#222';
        cP.cPSLC.className = 'cPSLCB';
        CP.cPM0CN = 'cPM0 cPM0B';
        if (CP.mode != 'H' && !CP.modeRGB[CP.mode]) {
          cP.cPSRCL.className = 'cPSRCLB';
          if (xy) cP.cPSRCR.className = 'cPSRCRB'
        }
      } else {
        if (expColor) cP.cObjs.color = '#ddd';
        cP.cPSLC.className = 'cPSLCW';
        CP.cPM0CN = 'cPM0';
        if (CP.mode != 'H' && !CP.modeRGB[CP.mode]) {
          cP.cPSRCL.className = 'cPSRCLW';
          if (xy) cP.cPSRCR.className = 'cPSRCRW'
        }
      }
    }
    cCtr = nCtr;
    if (!xy || yz) { // only right
      if (CP.modeRGB[CP.mode]) {
        nrCtr = CP.xyz[2] > 153;
        if (crCtr !== nrCtr) { // RGB special mode
          if (nrCtr && CP.mode == 'G') {
            cP.cPSRCL.className = 'cPSRCLB';
            if (xy) cP.cPSRCR.className = 'cPSRCRB';
          } else {
            cP.cPSRCL.className = 'cPSRCLW';
            if (xy) cP.cPSRCR.className = 'cPSRCRW'
          }
        }
      } else if (CP.mode == 'H') { // HSB_H mode extra rules
        nrCtr = getBrightness(tmpHSV || HSV2RGB(CP.hsv[0], 255, 255)) > 128;
        if (crCtr !== nrCtr) {
          if (nrCtr) cP.cPSRCL.className = 'cPSRCLB';
          else cP.cPSRCL.className = 'cPSRCLW'
        }
      }
      crCtr = nrCtr;
    }

    // display brightness/color match bar
    colDif = getColorDifference(CP.CB2Color, CP.rgb) / 765 * difWidth; // 765 = 3 colors * 255 possible values
    ctrDif = Math.abs((cPCtr - CP.iCtr) / 255 * difWidth);
    cP.cPCTRTs.cssText = 'width:' + ctrDif + 'px;' + ((colDif > ctrDif) ? cP.CTRTop : '');
    cP.cPCDs.cssText = 'width:' + colDif + 'px;' + ((ctrDif < difWidth / 2 && colDif < difWidth / 3 * 2) ? '' : ((ctrDif < difWidth / 2 || colDif < difWidth / 3 * 2) ? cP.cPCD1 : cP.cPCD2));

    // display color values // this also touches the DOM
    cP.cPIR.value = CP.rgbRND[0];
    cP.cPIG.value = CP.rgbRND[1];
    cP.cPIB.value = CP.rgbRND[2];
    cP.cPIH.value = Math.round(CP.hsv[0] / 255 * 360);
    cP.cPIS.value = Math.round(CP.hsv[1] / 2.55);
    cP.cPIV.value = Math.round(CP.hsv[2] / 2.55);
    cP.cPIC.value = CP.cmyk[0];
    cP.cPIM.value = CP.cmyk[1];
    cP.cPIY.value = CP.cmyk[2];
    cP.cPIK.value = CP.cmyk[3];
    cP.cPIX.value = CP.hex;

    // display WEBSave/WEBSmart/otherColor button
    WS = (CP.rgbRND[0] % 51 == 0 && CP.rgbRND[1] % 51 == 0 && CP.rgbRND[2] % 51 == 0) ? 'W' : (CP.rgbRND[0] % 17 == 0 && CP.rgbRND[1] % 17 == 0 && CP.rgbRND[2] % 17 == 0) ? 'M' : '!';
    if (WS != CP.WS) cP.cPBRX.firstChild.data = CP.WS = WS;

    // display value/color in initField swatch and left/background
    cP.cPCB1s.backgroundColor = 'rgb(' + CP.rgbRND + ')';
    if (expColor) cP.cObjs.backgroundColor = 'rgb(' + CP.rgbRND + ')';
    if (expHEX) cP.cObj.value = CP.valPrefix + CP.hex;
    if (CP.bd) document.body.style.background = 'rgb(' + CP.rgbRND + ')';

    if (colorPicker.exportColor) colorPicker.exportColor();
    if (xy && yz) { // stopRender
      cP.cPSRCR.className = cP.cPSRCL.className.replace('L', 'R'); // ;o)
      cP.cPM0s.backgroundColor = 'rgb(' + CP.rgbRND + ')';
      if (CP.cPM0CN) {
        cP.cPM0.className = CP.cPM0CN;
        CP.cPM0CN = ''
      }
    }
  }
591473
function palette({ baseColor: themeColor = baseColor, src = 'css/rsuite.min.css', dist } = {}, doneCallback) {

  try {
    if (!dist) {
      throw  `ERROR: [option.dist] is required`;
    }
  } catch (e) {
    console.log(e.red);
    return;
  }

  const originColors = color.calcColors(baseColor);
  const themeColors = color.calcColors(themeColor);
  const distPath = Path.dirname(dist);

  const ensureDir = path => new Promise((resolve) => {
    fse.ensureDir(path, () => resolve());
  });

  const readData = path => new Promise(resolve => {
    fs.readFile(path, 'utf-8', (err, data) => {
      resolve(data || '');
    });
  });

  const writeData = (path, data) => new Promise((resolve, reject) => {
    fs.writeFile(path, data, (err) => {
      if (err) {
        reject(err);
      }
      resolve();
    });
  });

  const handleCallback = (...args) => doneCallback && doneCallback(args);

  const generateThemes = async function () {
    try {
      await ensureDir(distPath);
      let data = await readData(Path.join(rootPath, src));
      originColors.forEach((color, index) => {
        data = data.replace(new RegExp(color, 'g'), themeColors[index]);
      });
      await  writeData(dist, data);
      console.log(`Palette ${dist}` + '[SUCCESS]'.green);
      handleCallback();
    } catch (e) {
      console.log(`Palette ${dist}` + '[FAILD]'.red);
      handleCallback(e);
    }
  };

  generateThemes();

  return module.exports;
}
1137971
public void drawPalette(int[] colors, int selectedColor) {
        if (colors == null) {
            return;
        }

        this.removeAllViews();
        int tableElements = 0;
        int rowElements = 0;
        int rowNumber = 0;

        // Fills the table with swatches based on the array of colors.
        TableRow row = createTableRow();
        for (int color : colors) {
            tableElements++;

            View colorSwatch = createColorSwatch(color, selectedColor);
            setSwatchDescription(rowNumber, tableElements, rowElements, color == selectedColor,
                    colorSwatch);
            addSwatchToRow(row, colorSwatch, rowNumber);

            rowElements++;
            if (rowElements == mNumColumns) {
                addView(row);
                row = createTableRow();
                rowElements = 0;
                rowNumber++;
            }
        }

        // Create blank views to fill the row if the last row has not been filled.
        if (rowElements > 0) {
            while (rowElements != mNumColumns) {
                addSwatchToRow(row, createBlankSpace(), rowNumber);
                rowElements++;
            }
            addView(row);
        }
    }
1331226
function (ui, context) {
					var active = color.active;
					if (context != colorBar && active.val() == null) return;
					switch (settings.color.mode) {
					case 'h':
						active.val('h', {
							h: 360 - ui.val('y')
						}, context);
						break;
					case 's':
						active.val('s', {
							s: 100 - ui.val('y')
						}, context);
						break;
					case 'v':
						active.val('v', {
							v: 100 - ui.val('y')
						}, context);
						break;
					case 'r':
						active.val('r', {
							r: 255 - ui.val('y')
						}, context);
						break;
					case 'g':
						active.val('g', {
							g: 255 - ui.val('y')
						}, context);
						break;
					case 'b':
						active.val('b', {
							b: 255 - ui.val('y')
						}, context);
						break;
					case 'a':
						active.val('a', 255 - ui.val('y'), context);
						break;
					}
				}