Interactively change the color distribution algorithm
        by scrolling.
975089
def sc_dist(self, viewer, event, msg=True):
        
        direction = self.get_direction(event.direction)
        self._cycle_dist(viewer, msg, direction=direction)
        return True
1098913
public void setColorRange(int firstIndex, int lastIndex, int color) {
		for (int i = firstIndex; i <= lastIndex; i++)
			map[i] = color;
	}
241616
def render(self, display):
        """"""

        # to handle changing objects / callable
        if self.shawn_text != self._last_text:
            self._render()

        if self.text:
            papy = self._surface.get_width()
            if papy <= self.width:
                display.blit(self._surface, (self.topleft, self.size))
            else:
                display.blit(self._surface, (self.topleft, self.size), ((papy - self.w, 0), self.size))
        else:
            display.blit(self.default_text, (self.topleft, self.size))

        if self._focus:
            groom = self.cursor_pos()
            line(display, (groom, self.top), (groom, self.bottom), CONCRETE)
315701
def rgb(self, color_tuple):
        """"""
        # Check bounds
        self.color = tuple(map(self._apply_float_bounds, color_tuple[:3]))

        # Include alpha if necessary
        if len(color_tuple) > 3:
            self.alpha = self._apply_float_bounds(color_tuple[3])
442384
function (color, elem, prop, wrapper) {
                var renderer = this,
                  colorObject,
                  regexRgba = /^rgba/,
                  markup,
                  fillType,
                  ret = NONE;

                // Check for linear or radial gradient
                if (color && color.linearGradient) {
                    fillType = 'gradient';
                } else if (color && color.radialGradient) {
                    fillType = 'pattern';
                }


                if (fillType) {

                    var stopColor,
                      stopOpacity,
                      gradient = color.linearGradient || color.radialGradient,
                      x1,
                      y1,
                      x2,
                      y2,
                      opacity1,
                      opacity2,
                      color1,
                      color2,
                      fillAttr = '',
                      stops = color.stops,
                      firstStop,
                      lastStop,
                      colors = [],
                      addFillNode = function () {
                          // Add the fill subnode. When colors attribute is used, the meanings of opacity and o:opacity2
                          // are reversed.
                          markup = ['<fill colors="' + colors.join(',') + '" opacity="', opacity2, '" o:opacity2="', opacity1,
                              '" type="', fillType, '" ', fillAttr, 'focus="100%" method="any" />'];
                          createElement(renderer.prepVML(markup), null, null, elem);
                      };

                    // Extend from 0 to 1
                    firstStop = stops[0];
                    lastStop = stops[stops.length - 1];
                    if (firstStop[0] > 0) {
                        stops.unshift([
                            0,
                            firstStop[1]
                        ]);
                    }
                    if (lastStop[0] < 1) {
                        stops.push([
                            1,
                            lastStop[1]
                        ]);
                    }

                    // Compute the stops
                    each(stops, function (stop, i) {
                        if (regexRgba.test(stop[1])) {
                            colorObject = Color(stop[1]);
                            stopColor = colorObject.get('rgb');
                            stopOpacity = colorObject.get('a');
                        } else {
                            stopColor = stop[1];
                            stopOpacity = 1;
                        }

                        // Build the color attribute
                        colors.push((stop[0] * 100) + '% ' + stopColor);

                        // Only start and end opacities are allowed, so we use the first and the last
                        if (!i) {
                            opacity1 = stopOpacity;
                            color2 = stopColor;
                        } else {
                            opacity2 = stopOpacity;
                            color1 = stopColor;
                        }
                    });

                    // Apply the gradient to fills only.
                    if (prop === 'fill') {

                        // Handle linear gradient angle
                        if (fillType === 'gradient') {
                            x1 = gradient.x1 || gradient[0] || 0;
                            y1 = gradient.y1 || gradient[1] || 0;
                            x2 = gradient.x2 || gradient[2] || 0;
                            y2 = gradient.y2 || gradient[3] || 0;
                            fillAttr = 'angle="' + (90  - math.atan(
                                (y2 - y1) / // y vector
                                (x2 - x1) // x vector
                              ) * 180 / mathPI) + '"';

                            addFillNode();

                            // Radial (circular) gradient
                        } else {

                            var r = gradient.r,
                              sizex = r * 2,
                              sizey = r * 2,
                              cx = gradient.cx,
                              cy = gradient.cy,
                              radialReference = elem.radialReference,
                              bBox,
                              applyRadialGradient = function () {
                                  if (radialReference) {
                                      bBox = wrapper.getBBox();
                                      cx += (radialReference[0] - bBox.x) / bBox.width - 0.5;
                                      cy += (radialReference[1] - bBox.y) / bBox.height - 0.5;
                                      sizex *= radialReference[2] / bBox.width;
                                      sizey *= radialReference[2] / bBox.height;
                                  }
                                  fillAttr = 'src="' + defaultOptions.global.VMLRadialGradientURL + '" ' +
                                    'size="' + sizex + ',' + sizey + '" ' +
                                    'origin="0.5,0.5" ' +
                                    'position="' + cx + ',' + cy + '" ' +
                                    'color2="' + color2 + '" ';

                                  addFillNode();
                              };

                            // Apply radial gradient
                            if (wrapper.added) {
                                applyRadialGradient();
                            } else {
                                // We need to know the bounding box to get the size and position right
                                wrapper.onAdd = applyRadialGradient;
                            }

                            // The fill element's color attribute is broken in IE8 standards mode, so we
                            // need to set the parent shape's fillcolor attribute instead.
                            ret = color1;
                        }

                        // Gradients are not supported for VML stroke, return the first color. #722.
                    } else {
                        ret = stopColor;
                    }

                    // if the color is an rgba color, split it and add a fill node
                    // to hold the opacity component
                } else if (regexRgba.test(color) && elem.tagName !== 'IMG') {

                    colorObject = Color(color);

                    markup = ['<', prop, ' opacity="', colorObject.get('a'), '"/>'];
                    createElement(this.prepVML(markup), null, null, elem);

                    ret = colorObject.get('rgb');


                } else {
                    var propNodes = elem.getElementsByTagName(prop); // 'stroke' or 'fill' node
                    if (propNodes.length) {
                        propNodes[0].opacity = 1;
                        propNodes[0].type = 'solid';
                    }
                    ret = color;
                }

                return ret;
            }
1359612
void wrappedSmoothScrollBy(int dx, int dy) {
        if (!mScrollable) {
            return;
        }

        smoothScrollBy(dx, dy);
        if (mLockableScrollChangedListener != null) {
            mLockableScrollChangedListener.onSmoothScrollBy(dx, dy);
        }
    }
213505
function Hue() {
        Channel.apply(this, arguments);
        this.dataType = NUMBER | HUE;
        this.cssType = NUMBER;
        this.range = [0, 360];
        this.filter = MOD;
        this.initial = 0;
    }
69473
def change_color(self, selections, value):
        '''

        '''
        if 'atoms' in selections:
            atms = selections['atoms'].mask
            if value is None:
                #self.radii_state.array[atms] = [vdw_radii.get(t) * 0.3  for t in self.system.type_array[atms]]
                self.atom_colors.array[atms, 0:3] = [self.color_scheme.get(t, colors.deep_pink)[0:3]
                                                     for t in self.system.type_array[atms]]
            else:
                self.atom_colors.array[atms, 0:3] = value[0:3]
    
        self.atom_renderer.update_colors(self.atom_colors.array)
        self.on_atom_colors_changed()
955867
protected void redraw() {

        if (isAttached()) {
            int outerHeight = getElement().getOffsetHeight();
            int innerHeight = m_containerElement.getOffsetHeight();
            if (outerHeight >= innerHeight) {
                setScrollbarVisible(false);
            } else {
                setScrollbarVisible(true);
                adjustKnobHeight(outerHeight, innerHeight);
                setKnobPosition(m_currentValue);
            }
        }
        if (m_slidingMouse) {
            m_mouseSlidingStartY = m_lastMouseY;
            m_mouseSlidingStartValue = m_currentValue;
        }
    }
27597
def render(self, display):
        """"""
        # to handle changing objects / callable
        if self.text != self._last_text:
            self._render()

        display.blit(self._surface, (self.topleft, self.size))
615457
public static void adjustForDisplay(ImageGray transform , int numLevels , double valueRange ) {
		if( transform instanceof GrayF32)
			adjustForDisplay((GrayF32)transform,numLevels,(float)valueRange);
		else
			adjustForDisplay((GrayI)transform,numLevels,(int)valueRange);
	}
327593
function moveRender (type) {
    var method = type ? 'down' : 'up'
    
    ui
      .left(lastLen + 2)
      .up(count - cur)
      .write('  ')
    
    // Each time move to right-bottom.
    ui[method]()
      .left(2)
      .write(chalk.blue(pointer))
      .left(2)
      .down(count - (type ? ++cur : --cur))
      .right(lastLen + 2)
  }
1222242
def blit(self, image, x, y):
        """"""
        # adjust the position with the local bbox
        x += self.font_bbox[2] - self.bbox[2]
        y += self.font_bbox[3] - self.bbox[3]
        x += self.font_bbox[0] - self.bbox[0]
        y += self.font_bbox[1] - self.bbox[1]
        image[y:y+self.height, x:x+self.width] = self.bitmap * 255
391705
def color_interp(data):
    """"""
    from rasterio.enums import ColorInterp as ci
    modes = {'L': [ci.gray],
             'LA': [ci.gray, ci.alpha],
             'YCbCr': [ci.Y, ci.Cb, ci.Cr],
             'YCbCrA': [ci.Y, ci.Cb, ci.Cr, ci.alpha]}

    try:
        mode = ''.join(data['bands'].values)
        return modes[mode]
    except KeyError:
        colors = {'R': ci.red,
                  'G': ci.green,
                  'B': ci.blue,
                  'A': ci.alpha,
                  'C': ci.cyan,
                  'M': ci.magenta,
                  'Y': ci.yellow,
                  'H': ci.hue,
                  'S': ci.saturation,
                  'L': ci.lightness,
                  'K': ci.black,
                  }
        return [colors[band] for band in data['bands'].values]
1200164
public void adjustColor(float r, float g, float b, float a) {
		if (color == Color.white) {
			color = new Color(1,1,1,1f);
		} 
		color.r += r;
		color.g += g;
		color.b += b;
		color.a += a;
	}
401629
public void changeAlpha(int alpha) {
        alpha = alpha > 255 ? 255 : alpha < 0 ? 0 : alpha;

        Color foreground = getForeground();
        int red = foreground.getRed();
        int green = foreground.getGreen();
        int blue = foreground.getBlue();

        Color withAlpha = new Color(red, green, blue, alpha);
        super.setForeground(withAlpha);
    }
931885
public static ColorFilter adjustHue( float value )
    {
        ColorMatrix cm = new ColorMatrix();

        adjustHue(cm, value);

        return new ColorMatrixColorFilter(cm);
    }