enhance contrast levels, or use full data range
        according to value of self.panel.conf.contrast_level
351895
def set_contrast_levels(self, contrast_level=0):
        
        for cmap_panel, img_panel in zip((self.cmap_panels[0], self.cmap_panels[1]),
                                         (self.img1_panel, self.img2_panel)):
            conf = img_panel.conf
            img  = img_panel.conf.data
            if contrast_level is None:
                contrast_level = 0
            conf.contrast_level = contrast_level
            clevels = [contrast_level, 100.0-contrast_level]

            jmin = imin = img.min()
            jmax = imax = img.max()
            cmap_panel.imin_val.SetValue('%.4g' % imin)
            cmap_panel.imax_val.SetValue('%.4g' % imax)
            jmin, jmax = np.percentile(img, clevels)

            conf.int_lo[0]  = imin
            conf.int_hi[0]  = imax
            conf.cmap_lo[0] = xlo = (jmin-imin)*conf.cmap_range/(imax-imin)
            conf.cmap_hi[0] = xhi = (jmax-imin)*conf.cmap_range/(imax-imin)

            cmap_panel.cmap_hi.SetValue(xhi)
            cmap_panel.cmap_lo.SetValue(xlo)
            cmap_panel.islider_range.SetLabel('Shown: [ %.4g :  %.4g ]' % (jmin, jmax))
            cmap_panel.redraw_cmap()
            img_panel.redraw()
649961
def setup_panel_params(self, scale_x, scale_y):
        

        def train(scale, limits, name):
            """
            Train a single coordinate axis
            """
            # Which axis are we dealing with
            name = scale.aesthetics[0]

            if self.expand:
                expand = self.expand_default(scale)
            else:
                expand = (0, 0, 0, 0)

            if limits is None:
                rangee = scale.dimension(expand)
            else:
                rangee = scale.transform(limits)
                rangee = expand_range_distinct(rangee, expand)

            out = scale.break_info(rangee)
            # This is where
            # x_major, x_labels, x_minor, ...
            # range keys are created
            for key in list(out.keys()):
                new_key = '{}_{}'.format(name, key)
                out[new_key] = out.pop(key)
            return out

        out = dict(
            scales=types.SimpleNamespace(x=scale_x, y=scale_y),
            **train(scale_x, self.limits.xlim, 'x'),
            **train(scale_y, self.limits.ylim, 'y')
        )
        return out
815245
function inerpolateColorsFixedAlpha(col1, col2, amount, alpha) {
  let col1rgb = parseColor(col1);
  let col2rgb = parseColor(col2);
  return RGBobj2string({
    r: Math.min(255, col1rgb.r * amount + col2rgb.r * Math.max(0,1-amount)),
    g: Math.min(255, col1rgb.g * amount + col2rgb.g * Math.max(0,1-amount)),
    b: Math.min(255, col1rgb.b * amount + col2rgb.b * Math.max(0,1-amount)),
    a: alpha
  });
}
823106
function setImageLuminanceColorScale( $imageObject, $filterData, $sourceMimeData, $destinationMimeData,
                                          $colorScale )
    {
        $white = ImageColorAllocate( $imageObject, 255, 255, 255 );
        $black = ImageColorAllocate( $imageObject, 0, 0, 0 );

        $rmod = $colorScale[0];
        $gmod = $colorScale[1];
        $bmod = $colorScale[2];

        $width = ImageSX( $imageObject );
        $height = ImageSY( $imageObject );
        for ( $y = 0; $y < $height; ++$y )
        {
            for ( $x = 0; $x < $width; ++$x )
            {
                $rgb = ImageColorAt( $imageObject, $x, $y );

                $r = ( $rgb >> 16 ) & 0xff;
                $g = ( $rgb >> 8 ) & 0x0ff;
                $b = ( $rgb ) & 0x0ff;

                $luminance = ( $r * 0.3 ) + ( $g * 0.59 ) + ( $b * 0.11 );

                $r = $luminance * $rmod;
                $g = $luminance * $gmod;
                $b = $luminance * $bmod;

                $color = ImageColorAllocate( $imageObject, $r, $g, $b );

                ImageSetPixel( $imageObject, $x, $y, $color );
            }
        }
        return $imageObject;
    }
482588
def setThreshold(self, threshold):
        
        self.threshLine.setValue(threshold)
        self.threshold_field.setValue(threshold)
967451
def bk_dark(cls):
        ""
        wAttributes = cls._get_text_attributes()
        wAttributes &= ~win32.BACKGROUND_INTENSITY
        cls._set_text_attributes(wAttributes)
1188579
private void enhanceFAB(final FloatingActionButton fab, int dx, int dy) {
        if (isEnhancedFAB() && getFab() != null) {
            final FloatingActionButton mFloatingActionButton = this.fab;
            if (getLinearLayoutManager() != null) {
                if (dy > 0) {
                    if (mFloatingActionButton.getVisibility() == View.VISIBLE) {
                        mFloatingActionButton.hide();
                    }
                } else {
                    if (mFloatingActionButton.getVisibility() != View.VISIBLE) {
                        mFloatingActionButton.show();
                    }
                }
            }
        }
    }
169008
public void setRangeOfMeasuredValuesVisible(final boolean RANGE_OF_MEASURED_VALUES_VISIBLE) {
        getModel().setRangeOfMeasuredValuesVisible(RANGE_OF_MEASURED_VALUES_VISIBLE);
        init(getInnerBounds().width, getInnerBounds().height);
        repaint(getInnerBounds());
    }
7974
def set_viewlimits(self, panel='top'):
        
        this_panel = self.get_panel(panel)

        xmin, xmax, ymin, ymax = this_panel.conf.set_viewlimits()[0]
        # print("Set ViewLimits ", xmin, xmax, ymin, ymax)
        # make top/bottom panel follow xlimits
        if this_panel == self.panel:
            other = self.panel_bot
            for _ax in other.fig.get_axes():
                _ax.set_xlim((xmin, xmax), emit=True)
            other.draw()
199074
def _update_viewport_margins(self):
        """"""
        top = 0
        left = 0
        right = 0
        bottom = 0
        for panel in self.panels_for_zone(Panel.Position.LEFT):
            if panel.isVisible():
                width = panel.sizeHint().width()
                left += width
        for panel in self.panels_for_zone(Panel.Position.RIGHT):
            if panel.isVisible():
                width = panel.sizeHint().width()
                right += width
        for panel in self.panels_for_zone(Panel.Position.TOP):
            if panel.isVisible():
                height = panel.sizeHint().height()
                top += height
        for panel in self.panels_for_zone(Panel.Position.BOTTOM):
            if panel.isVisible():
                height = panel.sizeHint().height()
                bottom += height
        self._margin_sizes = (top, left, right, bottom)
        self.editor.setViewportMargins(left, top, right, bottom)
106274
def _check_color_dim(val):
    """"""
    val = np.atleast_2d(val)
    if val.shape[1] not in (3, 4):
        raise RuntimeError('Value must have second dimension of size 3 or 4')
    return val, val.shape[1]
1353996
public static void optimizeGraphicsQuality(Graphics2D g)
    {
        g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        g.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);
        g.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY);
        g.setRenderingHint(RenderingHints.KEY_DITHERING, RenderingHints.VALUE_DITHER_ENABLE);
        g.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);
        g.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
        g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR);
        g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
    }
1190679
public void setSampleStyle()
    {
        Color colorBackground = ScreenUtil.getColor(ScreenUtil.BACKGROUND_COLOR, null, properties);
        Color colorControl = ScreenUtil.getColor(ScreenUtil.CONTROL_COLOR, null, properties);
        Color colorText = ScreenUtil.getColor(ScreenUtil.TEXT_COLOR, null, properties);
        samplePanel.setBackground(colorBackground);
        if (colorBackground == null)
            samplePanel.setBackground(SystemColor.window);
        Font font = ScreenUtil.getFont(null, properties, true);
        sampleLabel.setFont(font);
        sampleTextField.setFont(font);
        sampleTextField.setBackground(colorControl);
        if (colorControl == null)
            sampleTextField.setBackground(SystemColor.text);
        sampleLabel.setForeground(colorText);
        if (colorText == null)
            sampleLabel.setForeground(SystemColor.textText);
        sampleTextField.setForeground(colorText);
        if (colorText == null)
            sampleTextField.setForeground(SystemColor.textText);

        if (colorBackground != null)
            backgroundButton.setBackground(colorBackground);
        if (colorControl != null)
            controlColorButton.setBackground(colorControl);
        if (colorText != null)
            textColorButton.setBackground(colorText);

        this.invalidate();
    }
794716
function mask (contrast) {
	var a = Math.pow(392.498 * contrast, 0.7);
	var b = Math.pow(0.0153 * a, 4.0);
	return Math.pow(1.0 + b, 0.25);
}
434618
def get_brightness_level(cls, percent):
        
        # Clamp to appropriate range.
        percent = min(100, max(0, percent))

        # Map 0-100 to 2-27
        value = int(2 + ((float(percent) / 100) * 25))
        return percent, value
11373
def set_contourf_properties(stroke_width, fcolor, fill_opacity, contour_levels, contourf_idx, unit):
    """"""
    return {
        "stroke": fcolor,
        "stroke-width": stroke_width,
        "stroke-opacity": 1,
        "fill": fcolor,
        "fill-opacity": fill_opacity,
        "title": "%.2f" % contour_levels[contourf_idx] + ' ' + unit
    }
52706
def _enhance_bass(self):
        """"""
        if not self._bass_enhancement:
            # like in supsmu, skip if alpha=0
            return
        bass_span = DEFAULT_SPANS[BASS_INDEX]
        enhanced_spans = []
        for i, best_span_here in enumerate(self._best_span_at_each_point):
            best_smooth_index = DEFAULT_SPANS.index(best_span_here)
            best_span = DEFAULT_SPANS[best_smooth_index]
            best_span_residual = self._residual_smooths[best_smooth_index][i]
            bass_span_residual = self._residual_smooths[BASS_INDEX][i]
            if 0 < best_span_residual < bass_span_residual:
                ri = best_span_residual / bass_span_residual
                bass_factor = ri ** (10.0 - self._bass_enhancement)
                enhanced_spans.append(best_span + (bass_span - best_span) * bass_factor)
            else:
                enhanced_spans.append(best_span)
        self._best_span_at_each_point = enhanced_spans