Converts percentage values into actual pixel values based on the known
 render size.

 Returns a hash consisting of :x, :y, :width, and :height elements.
554253
def bounds_for(canvas_size, position, size)
      return nil if (position.nil? || size.nil?)
      bounds = {}
      bounds[:x] = canvas_size.first * (position.first / 100.to_f)
      bounds[:y] = canvas_size.last  * (position.last  / 100.to_f)
      bounds[:width] = canvas_size.first * (size.first / 100.to_f)
      bounds[:height] = canvas_size.last * (size.last  / 100.to_f)
      bounds
    end
244679
def finite_pixels(self):
        
        finite_px = np.where(np.isfinite(self.data))
        finite_px = np.c_[finite_px[0], finite_px[1]]
        return finite_px
1374781
def texture_formats(self):
        """"""
        info = self._get_renderer_info()
        return {PixelFormat(info.texture_formats[i]) for i in range(info.num_texture_formats)}
799553
def pixel(self, x, y, size=None):
        """"""
        if (size is None):
            size = self.sz
        # Have we go to the smallest element?
        if (size <= 3):
            if (_not_diagonal(x, y)):
                return None
            else:
                return (0, 0, 0)
        divisor = size // 3
        if (_not_diagonal(x // divisor, y // divisor)):
            return None
        return self.pixel(x % divisor, y % divisor, divisor)
145847
def getPixelAttrRandom(self, x, y):
        ''
        c = list(attr for attr, rows in self.pixels[y][x].items()
                         for r in rows if attr and attr not in self.hiddenAttrs)
        return random.choice(c) if c else 0
1086315
def pixels(self, value: float) -> 'Size':
        """"""
        raise_not_number(value)
        self.maximum = '{}px'.format(value)
        return self
930759
def render(self, compress=False):
        

        if not compress and self.original_literal:
            return self.original_literal

        candidates = []

        # TODO this assumes CSS resolution is 8-bit per channel, but so does
        # Ruby.
        r, g, b, a = self.value
        r, g, b = int(round(r)), int(round(g)), int(round(b))

        # Build a candidate list in order of preference.  If `compress` is
        # True, the shortest candidate is used; otherwise, the first candidate
        # is used.

        # Try color name
        key = r, g, b, a
        if key in COLOR_LOOKUP:
            candidates.append(COLOR_LOOKUP[key])

        if a == 1:
            # Hex is always shorter than function notation
            if all(ch % 17 == 0 for ch in (r, g, b)):
                candidates.append("#%1x%1x%1x" % (r // 17, g // 17, b // 17))
            else:
                candidates.append("#%02x%02x%02x" % (r, g, b))
        else:
            # Can't use hex notation for RGBA
            if compress:
                sp = ''
            else:
                sp = ' '
            candidates.append("rgba(%d,%s%d,%s%d,%s%.6g)" % (r, sp, g, sp, b, sp, a))

        if compress:
            return min(candidates, key=len)
        else:
            return candidates[0]
51953
private static BitMatrix renderResult(QRCode code, int width, int height, int quietZone) {
    ByteMatrix input = code.getMatrix();
    if (input == null) {
      throw new IllegalStateException();
    }
    int inputWidth = input.getWidth();
    int inputHeight = input.getHeight();
    int qrWidth = inputWidth + (quietZone * 2);
    int qrHeight = inputHeight + (quietZone * 2);
    int outputWidth = Math.max(width, qrWidth);
    int outputHeight = Math.max(height, qrHeight);

    int multiple = Math.min(outputWidth / qrWidth, outputHeight / qrHeight);
    // Padding includes both the quiet zone and the extra white pixels to accommodate the requested
    // dimensions. For example, if input is 25x25 the QR will be 33x33 including the quiet zone.
    // If the requested size is 200x160, the multiple will be 4, for a QR of 132x132. These will
    // handle all the padding from 100x100 (the actual QR) up to 200x160.
    int leftPadding = (outputWidth - (inputWidth * multiple)) / 2;
    int topPadding = (outputHeight - (inputHeight * multiple)) / 2;

    BitMatrix output = new BitMatrix(outputWidth, outputHeight);

    for (int inputY = 0, outputY = topPadding; inputY < inputHeight; inputY++, outputY += multiple) {
      // Write the contents of this row of the barcode
      for (int inputX = 0, outputX = leftPadding; inputX < inputWidth; inputX++, outputX += multiple) {
        if (input.get(inputX, inputY) == 1) {
          output.setRegion(outputX, outputY, multiple, multiple);
        }
      }
    }

    return output;
  }
1190374
function(properties, options) {
    var widthUnit = '',
      heightUnit = '';

    // name takes precedence
    if (properties.name) {
      return properties.name;
    } else {
      // figure out the units for width and height (they can be different)
      widthUnit = ((properties.width || 0).toString().indexOf('%') > 0) ? options.units.percentage : options.units.pixel;
      heightUnit = ((properties.height || 0 ).toString().indexOf('%') > 0) ? options.units.percentage : options.units.pixel;

      if (properties.width && properties.height) {
        return parseFloat(properties.width) + widthUnit + options.units.multiply + parseFloat(properties.height) + heightUnit;
      } else {
        return (properties.width) ? parseFloat(properties.width) + widthUnit : parseFloat(properties.height) + heightUnit;
      }
    }
  }
1218887
def tile_to_pixel(tile, centered=False):
        """"""
        pixel = [tile[0] * 256, tile[1] * 256]
        if centered:
            # should clip on max map size
            pixel = [pix + 128 for pix in pixel]
        return pixel[0], pixel[1]
929916
def get_canvas_square_dpi(pageinfo, options):
    """"""
    return float(
        max(
            (pageinfo.xres) or VECTOR_PAGE_DPI,
            (pageinfo.yres) or VECTOR_PAGE_DPI,
            VECTOR_PAGE_DPI if pageinfo.has_vector else 0,
            options.oversample or 0,
        )
    )
755299
def render(self, rect, data):
        """"""
        # We can't use our get minimum size, because that enforces
        # the size limits.
        size = self.element.get_minimum_size(data)

        # Assume we're bottom left at our natural size.
        x = rect.x
        y = rect.y
        w = size.x
        h = size.y

        extra_width = rect.w - w
        extra_height = rect.h - h

        if self.horizontal_align == AlignLM.ALIGN_CENTER:
            x += extra_width * 0.5
        elif self.horizontal_align == AlignLM.ALIGN_RIGHT:
            x += extra_width
        elif self.horizontal_align == AlignLM.GROW_X:
            w = rect.w

        if self.vertical_align == AlignLM.ALIGN_MIDDLE:
            y += extra_height * 0.5
        elif self.vertical_align == AlignLM.ALIGN_TOP:
            y += extra_height
        elif self.vertical_align == AlignLM.GROW_Y:
            h = rect.h

        self.element.render(datatypes.Rectangle(x, y, w, h), data)
522364
def getPixelAttrMost(self, x, y):
        ''
        r = self.pixels[y][x]
        c = sorted((len(rows), attr, rows) for attr, rows in list(r.items()) if attr and attr not in self.hiddenAttrs)
        if not c:
            return 0
        _, attr, rows = c[-1]
        if isinstance(self.source, BaseSheet) and anySelected(self.source, rows):
            attr = CursesAttr(attr, 8).update_attr(colors.color_graph_selected, 10).attr
        return attr
1159329
def pixel_to_size_ratio(self):
        
        left, right, _, _ = self.get_view_coordinates()
        width = right - left
        display_width = self.get_allocation().width
        return display_width / float(width)
458177
def get_capture_dimensions(capture):
    """"""
    width = int(capture.get(cv2.CAP_PROP_FRAME_WIDTH))
    height = int(capture.get(cv2.CAP_PROP_FRAME_HEIGHT))
    return width, height
129723
def to_a
      width.times.map do |x|
        height.times.map do |y|
          sample_distance x, y
        end
      end
    end
101729
def percentSame(image1, image2):
        '''
        
        '''

        # If the images differ in size, return 0% same.
        size_x1, size_y1 = image1.size
        size_x2, size_y2 = image2.size
        if (size_x1 != size_x2 or
                    size_y1 != size_y2):
            return 0

        # Images are the same size
        # Return the percent of pixels that are equal.
        numPixelsSame = 0
        numPixelsTotal = size_x1 * size_y1
        image1Pixels = image1.load()
        image2Pixels = image2.load()

        # Loop over all pixels, comparing pixel in image1 to image2
        for x in range(size_x1):
            for y in range(size_y1):
                if image1Pixels[x, y] == image2Pixels[x, y]:
                    numPixelsSame += 1

        return numPixelsSame / float(numPixelsTotal)