Convert a size in pxel to a size in points.
346340
def px_to_pt(self, px):
        """"""
        if px < 200:
            pt = self.PX_TO_PT[px]
        else:
            pt = int(floor((px - 1.21) / 1.332))

        return pt
757707
def _size_map(size):
    '''
    
    '''
    try:
        # I know, I know, EAFP.
        # But everything else is reason for None
        if not isinstance(size, int):
            if re.search(r'[Kk]', size):
                size = 1024 * float(re.sub(r'[Kk]', '', size))
            elif re.search(r'[Mm]', size):
                size = 1024**2 * float(re.sub(r'[Mm]', '', size))
            size = int(size)
        return size
    except Exception:
        return None
509545
def sizeHint(self, option, index):
        """"""
        # calculate size by data component
        component = index.internalPointer()
        width = self.component.duration() * self.pixelsPerms*1000
        return QtCore.QSize(width, 50)
1108288
def from_pixel(cls, pixel_x=0, pixel_y=0, zoom=None):
        """"""
        max_pixel = (2 ** zoom) * TILE_SIZE
        assert 0 <= pixel_x <= max_pixel, 'Point X needs to be a value between 0 and (2^zoom) * 256.'
        assert 0 <= pixel_y <= max_pixel, 'Point Y needs to be a value between 0 and (2^zoom) * 256.'
        meter_x = pixel_x * resolution(zoom) - ORIGIN_SHIFT
        meter_y = pixel_y * resolution(zoom) - ORIGIN_SHIFT
        meter_x, meter_y = cls._sign_meters(meters=(meter_x, meter_y), pixels=(pixel_x, pixel_y), zoom=zoom)
        return cls.from_meters(meter_x=meter_x, meter_y=meter_y)
1072524
public int getPixelSize(Component component) {
        if (unit == PIXEL) {
            return intValue();
        } else if (unit == POINT) {
            return Sizes.pointAsPixel(intValue(), component);
        } else if (unit == INCH) {
            return Sizes.inchAsPixel(value, component);
        } else if (unit == MILLIMETER) {
            return Sizes.millimeterAsPixel(value, component);
        } else if (unit == CENTIMETER) {
            return Sizes.centimeterAsPixel(value, component);
        } else if (unit == DIALOG_UNITS_X) {
            return Sizes.dialogUnitXAsPixel(intValue(), component);
        } else if (unit == DIALOG_UNITS_Y) {
            return Sizes.dialogUnitYAsPixel(intValue(), component);
        } else {
            throw new IllegalStateException("Invalid unit " + unit);
        }
    }
487204
def value_px(self):
        """"""
        step = self.w / (self.max - self.min)
        return self.x + step * (self.get() - self.min)
537715
def _quadPoints(size, disp1, disp2):
        """"""
        w, h = size
        x1, y1 = disp1
        x2, y2 = disp2

        return (
            x1,    -y1,
            -x1,    h + y2,
            w + x2, h - y2,
            w - x2, y1
        )
115518
def world_to_image(bbox, size):
    """"""

    px_per_unit = (float(size[0])/bbox.width, float(size[1])/bbox.height)
    return lambda x,y: ((x-bbox.xmin) * px_per_unit[0], size[1] - (y-bbox.ymin)*px_per_unit[1])
909706
def get_point(cls, idx, size):
        
        x, y = cls.POSITION[idx % 4]
        idx //= 4
        block_size = 2
        while block_size < size:
            block_idx = idx % 4
            x, y = cls.get_point_in_block(x, y, block_idx, block_size)
            idx //= 4
            block_size *= 2
        return x, y
491731
function(point) {

      var halfWidth = this.get('width') / 2,
          halfHeight = this.get('height') / 2,
          centerX = this.get('left'),
          centerY = this.get('top');

      return  centerX - halfWidth < point.x &&
              centerX + halfWidth > point.x &&
              centerY - halfHeight < point.y &&
              centerY + halfHeight > point.y;
    }
1173908
def get_dpi():
    """"""

    def pxmm_2_dpi((pixels, length_mm)):
        return pixels * 25.6 / length_mm

    return map(pxmm_2_dpi, zip(wx.GetDisplaySize(), wx.GetDisplaySizeMM()))
37348
function pxToEmOrRem(breakpoints, ratio = 16, unit) {
  const newBreakpoints = {};

  for (let key in breakpoints) {
    const point = breakpoints[key];

    if (String(point).includes('px')) {
      newBreakpoints[key] = +(parseInt(point) / ratio) + unit;
      continue;
    }

    newBreakpoints[key] = point;
  }

  return newBreakpoints;
}
867527
function normalizePoint (point) {
            return {
                x: point.x * canvas.width,
                y: point.y * canvas.height
            };
        }
702445
def transform(self, m):
        """"""
        if len(m) != 6:
            raise ValueError("bad sequ. length")
        self.x, self.y = TOOLS._transform_point(self, m)
        return self
553776
function bitSize(x) {
  var j, z, w;
  for (j=x.length-1; (x[j]==0) && (j>0); j--);
  for (z=0, w=x[j]; w; (w>>=1), z++);
  z+=bpe*j;
  return z;
}
896952
function getSizeInPixels(el, value) {
    if (/px$/i.test(value)) return parseFloat(value);
    var style = el.style.left, runtimeStyle = el.runtimeStyle.left;
    el.runtimeStyle.left = el.currentStyle.left;
    el.style.left = value;
    var result = el.style.pixelLeft;
    el.style.left = style;
    el.runtimeStyle.left = runtimeStyle;
    return result;
  }
558160
function mapGptSlotSizes(aGPTSlotSizes) {
      var aSlotSizes = [];
      for (var i = 0; i < aGPTSlotSizes.length; i++) {
        try {
          aSlotSizes.push([aGPTSlotSizes[i].getWidth(), aGPTSlotSizes[i].getHeight()]);
        } catch (e) {
          utils.logWarn('slot size ' + aGPTSlotSizes[i].toString() + ' not supported by' + MODULE_NAME);
        }
      }
      return aSlotSizes;
    }