more complex mode: background, frame and title
189673
def complex_framing
      background = generate_background

      self.space_to_device = vertical_frame_padding

      if fetch_config['title']
        background = put_title_into_background(background, fetch_config['stack_title'])
      end

      if self.frame # we have no frame on le mac
        resize_frame!
        put_into_frame

        # Decrease the size of the framed screenshot to fit into the defined padding + background
        frame_width = background.width - horizontal_frame_padding * 2
        frame_height = background.height - effective_text_height - vertical_frame_padding

        if fetch_config['show_complete_frame']
          # calculate the final size of the screenshot to resize in one go
          # it may be limited either by the width or height of the frame
          image_aspect_ratio = @image.width.to_f / @image.height.to_f
          image_width = [frame_width, @image.width].min
          image_height = [frame_height, image_width / image_aspect_ratio].min
          image_width = image_height * image_aspect_ratio
          @image.resize("#{image_width}x#{image_height}") if image_width < @image.width || image_height < @image.height
        else
          # the screenshot size is only limited by width.
          # If higher than the frame, the screenshot is cut off at the bottom
          @image.resize("#{frame_width}x") if frame_width < @image.width
        end
      end

      @image = put_device_into_background(background)

      image
    end
1169891
def title(label, style=None):
    
    fig = current_figure()
    fig.title = label
    if style is not None:
        fig.title_style = style
533005
def composite(
    background_image,
    foreground_image,
    foreground_width_ratio=0.25,
    foreground_position=(0.0, 0.0),
):
    """"""

    if foreground_width_ratio <= 0:
        return background_image

    composite = background_image.copy()
    width = int(foreground_width_ratio * background_image.shape[1])
    foreground_resized = resize(foreground_image, width)
    size = foreground_resized.shape

    x = int(foreground_position[1] * (background_image.shape[1] - size[1]))
    y = int(foreground_position[0] * (background_image.shape[0] - size[0]))

    # TODO: warn if resulting coordinates are out of bounds?
    composite[y : y + size[0], x : x + size[1]] = foreground_resized

    return composite
877570
function minimizeStyles(message) {
  var nestingDepth = message.frameIndex.split('.').length - 1;
  var iframe = document.createElement('iframe');
  document.body.appendChild(iframe);
  iframe.setAttribute(
      'style',
      `height: ${message.windowHeight}px;` + 
      `width: ${message.windowWidth}px;`);

  var html = message.html.join('');
  html = unescapeHTML(html, nestingDepth);
  iframe.contentDocument.documentElement.innerHTML = html;
  var doc = iframe.contentDocument;

  // Remove entry in |message.html| where extra style element was specified.
  message.html[message.pseudoElementTestingStyleIndex] = '';
  var finalPseudoElements = [];
  for (var selector in message.pseudoElementSelectorToCSSMap) {
    minimizePseudoElementStyle(message, doc, selector, finalPseudoElements);
  }

  if (finalPseudoElements.length > 0) {
    message.html[message.pseudoElementPlaceHolderIndex] =
        `<style>${finalPseudoElements.join(' ')}</style>`;
  }

  if (message.rootStyleIndex) {
    minimizeStyle(
        message,
        doc,
        doc.documentElement,
        message.rootId,
        message.rootStyleIndex);
  }

  for (var id in message.idToStyleIndex) {
    var index = message.idToStyleIndex[id];
    var element = doc.getElementById(id);
    if (element) {
      minimizeStyle(message, doc, element, id, index);
    }
  }
  iframe.remove();
}
551412
def write_title_rich(title, horiz = nil, layout = nil, overlay = nil) # :nodoc:
      @writer.tag_elements('c:title') do
        # Write the c:tx element.
        write_tx_rich(title, horiz)
        # Write the c:layout element.
        write_layout(layout, 'text')
        # Write the c:overlay element.
        write_overlay if overlay
      end
    end
670961
def make_options_frame(self):
        
        self.tab_frame = ttk.Notebook(self.option_frame, width=800)
        self.tab_configure = tk.Frame(self.tab_frame)
        self.tab_classify = tk.Frame(self.tab_frame)
        self.make_configure_tab()
        self.make_classify_tab()

        self.tab_frame.add(self.tab_configure, text="Configure")
        self.tab_frame.add(self.tab_classify, text="Classify")
        self.tab_frame.pack(fill=tk.BOTH, expand=True)
1327162
function initFrameMargins()
    {
        $this->ezFrame = array();

        $config = eZINI::instance( 'pdf.ini' );

        $this->ezFrame['header'] = array( 'y0' => $this->ez['pageHeight'],
                                          'leftMargin' => $config->variable( 'Header', 'LeftMargin' ),
                                          'rightMargin' => $config->variable( 'Header', 'RightMargin' ),
                                          'topMargin' => $config->variable( 'Header', 'TopMargin' ),
                                          'bottomMargin' => $config->variable( 'Header', 'BottomMargin' ) );
        $this->ezFrame['footer'] = array( 'y0' => $this->ez['bottomMargin'],
                                          'leftMargin' => $config->variable( 'Footer', 'LeftMargin' ),
                                          'rightMargin' => $config->variable( 'Footer', 'RightMargin' ),
                                          'topMargin' => $config->variable( 'Footer', 'TopMargin' ),
                                          'bottomMargin' => $config->variable( 'Footer', 'BottomMargin' ) );
    }
787629
private String loadFrameTitle() {
		try {
			return messageSource == null ? null : messageSource.getMessage(
					SPLASH_TITLE_KEY, null, null);
		} catch (NoSuchMessageException e) {
			return null;
		}
	}
350515
def cyan(cls):
        ""
        wAttributes = cls._get_text_attributes()
        wAttributes &= ~win32.FOREGROUND_MASK
        wAttributes |=  win32.FOREGROUND_CYAN
        cls._set_text_attributes(wAttributes)
794272
protected void customizeTitle(TextTitle title, Font font)
	{
		title.setFont(font);
		title.setTextAlignment(HorizontalAlignment.LEFT);
		title.setPaint(Color.BLACK);
		title.setBackgroundPaint(TRANSPARENT_COLOR);
	}
53148
def _included_frames(frame_list, frame_format):
    """"""
    return INCLUDED_FRAMES.format(Nframes=len(frame_list),
                                  frame_dir=os.path.dirname(frame_list[0]),
                                  frame_format=frame_format)
271310
def middle_frame(obj):
    ""
    plot, renderer, fmt = single_frame_plot(obj)
    middle_frame = int(len(plot) / 2)
    plot.update(middle_frame)
    return {'text/html': renderer.html(plot, fmt)}
1355757
function customize () {
  var q1 = {
    name: 'title',
    message: 'What is your scene\'s title? (e.g., Forest Scene)',
    type: 'input',
    default: 'aframe-boilerplate'
  };

  var q2 = {
    name: 'handControls',
    message: 'Do you want tracked controls with hand models?',
    type: 'confirm',
    default: false
  };

  // Go.
  return new Promise(function (resolve) {
    inquirer.prompt([q1, q2]).then(function (answers) {
      // Slugify.
      answers.shortTitle = answers.title.toLowerCase().replace(/\s+/g, '-'
);
      run(answers)
      resolve(answers.shortTitle);
    });
  });

  /**
   * Do all the string replacements.
   */
  function run (answers) {
    answers.aframeVersion = aframeVersion;
    ls(['index.html', 'package.json', 'README.md']).forEach(function (file) {
      fs.writeFileSync(file, nunjucks.render(file, answers));
    });
  }
}
645836
private void defineInternalFrameIconifyButtons(UIDefaults d) {
        String p = "InternalFrame:InternalFrameTitlePane:\"InternalFrameTitlePane.iconifyButton\"";
        String c = PAINTER_PREFIX + "TitlePaneIconifyButtonPainter";

        d.put(p + ".States", "Enabled,MouseOver,Pressed,Disabled,Focused,Selected,WindowNotFocused,WindowMinimized");
        d.put(p + ".WindowNotFocused", new TitlePaneIconifyButtonWindowNotFocusedState());
        d.put(p + ".WindowMinimized", new TitlePaneIconifyButtonWindowMinimizedState());
        d.put(p + ".contentMargins", new InsetsUIResource(0, 0, 0, 0));

        // Set the iconify button states.
        d.put(p + "[Enabled].backgroundPainter", new LazyPainter(c, TitlePaneIconifyButtonPainter.Which.BACKGROUND_ENABLED));
        d.put(p + "[Disabled].backgroundPainter", new LazyPainter(c, TitlePaneIconifyButtonPainter.Which.BACKGROUND_DISABLED));
        d.put(p + "[MouseOver].backgroundPainter", new LazyPainter(c, TitlePaneIconifyButtonPainter.Which.BACKGROUND_MOUSEOVER));
        d.put(p + "[Pressed].backgroundPainter", new LazyPainter(c, TitlePaneIconifyButtonPainter.Which.BACKGROUND_PRESSED));
        d.put(p + "[Enabled+WindowNotFocused].backgroundPainter", new LazyPainter(c, TitlePaneIconifyButtonPainter.Which.BACKGROUND_ENABLED_WINDOWNOTFOCUSED));
        d.put(p + "[MouseOver+WindowNotFocused].backgroundPainter", new LazyPainter(c, TitlePaneIconifyButtonPainter.Which.BACKGROUND_MOUSEOVER_WINDOWNOTFOCUSED));
        d.put(p + "[Pressed+WindowNotFocused].backgroundPainter", new LazyPainter(c, TitlePaneIconifyButtonPainter.Which.BACKGROUND_PRESSED_WINDOWNOTFOCUSED));
        
        // Set the restore button states.
        d.put(p + "[Disabled+WindowMinimized].backgroundPainter",
              new LazyPainter(c,
                              TitlePaneIconifyButtonPainter.Which.BACKGROUND_MINIMIZED_DISABLED));
        d.put(p + "[Enabled+WindowMinimized].backgroundPainter",
              new LazyPainter(c,
                              TitlePaneIconifyButtonPainter.Which.BACKGROUND_MINIMIZED_ENABLED));
        d.put(p + "[MouseOver+WindowMinimized].backgroundPainter",
              new LazyPainter(c,
                              TitlePaneIconifyButtonPainter.Which.BACKGROUND_MINIMIZED_MOUSEOVER));
        d.put(p + "[Pressed+WindowMinimized].backgroundPainter",
              new LazyPainter(c,
                              TitlePaneIconifyButtonPainter.Which.BACKGROUND_MINIMIZED_PRESSED));
        d.put(p + "[Enabled+WindowMinimized+WindowNotFocused].backgroundPainter",
              new LazyPainter(c,
                              TitlePaneIconifyButtonPainter.Which.BACKGROUND_MINIMIZED_ENABLED_WINDOWNOTFOCUSED));
        d.put(p + "[MouseOver+WindowMinimized+WindowNotFocused].backgroundPainter",
              new LazyPainter(c,
                              TitlePaneIconifyButtonPainter.Which.BACKGROUND_MINIMIZED_MOUSEOVER_WINDOWNOTFOCUSED));
        d.put(p + "[Pressed+WindowMinimized+WindowNotFocused].backgroundPainter",
              new LazyPainter(c,
                              TitlePaneIconifyButtonPainter.Which.BACKGROUND_MINIMIZED_PRESSED_WINDOWNOTFOCUSED));

        d.put(p + ".icon", new SeaGlassIcon(p, "iconPainter", 26, 18));
    }
1210728
function background(options) {
    options = options || {};
    // ReSharper disable once UnusedParameter
    return function (config) {
        var values = [];
        [
            'attachment',
            'clip',
            'color',
            'image',
            'origin',
            'position',
            'repeat',
            'size'
        ].forEach(function (prop) {
            if (options.hasOwnProperty(prop)) {
                values.push(options[prop]);
            }
        });
        if (values.length) {
            return [['background', values.join(' ')]];
        }
        return [];
    };
}
2219
def backgroundCMD(self, catalog, mode='cloud-in-cells', weights=None):
        

        # Select objects in annulus
        cut_annulus = self.roi.inAnnulus(catalog.lon,catalog.lat)
        color = catalog.color[cut_annulus]
        mag   = catalog.mag[cut_annulus]

        # Units are (deg^2)
        solid_angle = ugali.utils.binning.take2D(self.solid_angle_cmd, color, mag,
                                                 self.roi.bins_color, self.roi.bins_mag)

        # Weight each object before binning
        # Divide by solid angle and bin size in magnitudes to get number density 
        # [objs / deg^2 / mag^2]
        if weights is None:
            number_density = (solid_angle*self.roi.delta_color*self.roi.delta_mag)**(-1)
        else:
            number_density = weights*(solid_angle*self.roi.delta_color*self.roi.delta_mag)**(-1)

        mode = str(mode).lower()
        if mode == 'cloud-in-cells':
            # Apply cloud-in-cells algorithm
            cmd_background = ugali.utils.binning.cloudInCells(color,mag,
                                                              [self.roi.bins_color,self.roi.bins_mag],
                                                              weights=number_density)[0]
        elif mode == 'bootstrap':
            # Not implemented
            raise ValueError("Bootstrap mode not implemented")
            mag_1_array = catalog.mag_1
            mag_2_array = catalog.mag_2

            catalog.mag_1 + (catalog.mag_1_err * np.random.normal(0, 1., len(catalog.mag_1)))
            catalog.mag_2 + (catalog.mag_2_err * np.random.normal(0, 1., len(catalog.mag_2)))

        elif mode == 'histogram':
            # Apply raw histogram
            cmd_background = np.histogram2d(mag,color,bins=[self.roi.bins_mag,self.roi.bins_color],
                                            weights=number_density)[0]

        elif mode == 'kde':
            # Gridded kernel density estimator
            logger.warning("### KDE not implemented properly")
            cmd_background = ugali.utils.binning.kernelDensity(color,mag,
                                                               [self.roi.bins_color,self.roi.bins_mag],
                                                               weights=number_density)[0]
        elif mode == 'uniform':
            logger.warning("### WARNING: Uniform CMD")
            hist = np.histogram2d(mag,color,bins=[self.roi.bins_mag,self.roi.bins_color], weights=number_density)[0]
            cmd_background = np.mean(hist)*np.ones(hist.shape)
            observable = (self.solid_angle_cmd > self.minimum_solid_angle)
            cmd_background *= observable
            return cmd_background
        else:
            raise ValueError("Unrecognized mode: %s"%mode)
        ## Account for the objects that spill out of the observable space
        ## But what about the objects that spill out to red colors??
        #for index_color in range(0, len(self.roi.centers_color)):
        #    for index_mag in range(0, len(self.roi.centers_mag)):
        #        if self.solid_angle_cmd[index_mag][index_color] < self.minimum_solid_angle:
        #            cmd_background[index_mag - 1][index_color] += cmd_background[index_mag][index_color]
        #            cmd_background[index_mag][index_color] = 0.
        #            break

        cmd_area = self.solid_angle_cmd*self.roi.delta_color*self.roi.delta_mag # [deg^2 * mag^2]

        # ADW: This accounts for leakage to faint magnitudes
        # But what about the objects that spill out to red colors??
        # Maximum obsevable magnitude index for each color (uses the fact that
        # np.argmin returns first minimum (zero) instance found.
        # NOTE: More complicated maps may have holes causing problems

        observable = (self.solid_angle_cmd > self.minimum_solid_angle)
        index_mag = observable.argmin(axis=0) - 1
        index_color = np.arange(len(self.roi.centers_color))
        # Add the cumulative leakage back into the last bin of the CMD
        leakage = (cmd_background * ~observable).sum(axis=0)
        cmd_background[[index_mag,index_color]] += leakage
        # Zero out all non-observable bins
        cmd_background *= observable

        # Avoid dividing by zero by setting empty bins to the value of the 
        # minimum filled bin of the CMD. This choice is arbitrary and 
        # could be replaced by a static minimum, some fraction of the 
        # CMD maximum, some median clipped minimum, etc. However, should 
        # be robust against outliers with very small values.
        min_cmd_background = max(cmd_background[cmd_background > 0.].min(),
                                 1e-4*cmd_background.max())
        cmd_background[observable] = cmd_background[observable].clip(min_cmd_background)

        ### # ADW: This is a fudge factor introduced to renormalize the CMD
        ### # to the number of input stars in the annulus. While leakage
        ### # will still smooth the distribution, it shouldn't result in 
        ### fudge_factor = len(mag) / float((cmd_background*cmd_area).sum())
        ### cmd_background *= fudge_factor

        return cmd_background
461797
function compositeRGB(foreground, background) {
  const [fr, fg, fb, fa] = chroma(foreground).rgba()
  const [br, bg, bb] = chroma(background).rgb()
  return chroma([(1 - fa) * br + fa * fr, (1 - fa) * bg + fa * fg, (1 - fa) * bb + fa * fb]).css()
}