Пример #1
0
oop CGContextConvertRectToUserSpace_wrap(CGContextRef c, float xin, float y, float w, float h) {
  CGRect x = CGContextConvertRectToUserSpace(c, CGRectMake(xin, y, w, h));
  objVectorOop r = Memory->objVectorObj->cloneSize(4);
  r->obj_at_put(0, as_floatOop(x.origin.x), false);
  r->obj_at_put(1, as_floatOop(x.origin.y), false);
  r->obj_at_put(2, as_floatOop(x.size.width), false);
  r->obj_at_put(3, as_floatOop(x.size.height), false);
  return r;
}
Пример #2
0
//-----------------------------------------------------------------------------
CGRect CGDrawContext::pixelAlligned (const CGRect& r) const
{
    CGRect result = CGContextConvertRectToDeviceSpace (cgContext, r);
    result.origin.x = std::round (result.origin.x);
    result.origin.y = std::round (result.origin.y);
    result.size.width = std::round (result.size.width);
    result.size.height = std::round (result.size.height);
    result = CGContextConvertRectToUserSpace (cgContext, result);
    return result;
}
static CGRect alignRectToUserSpace(CGContextRef context, CGRect r)
{
    // Compute the coordinates of the rectangle in device space.
    r = CGContextConvertRectToDeviceSpace(context, r);
    // Ensure that the x and y coordinates are at a pixel corner.
    r.origin.x = floor(r.origin.x);
    r.origin.y = floor(r.origin.y);
    // Ensure that the width and height are an integer number of
    // device pixels. Note that this produces a width and height
    // that is less than or equal to the original width. Another
    // approach is to use ceil to ensure that the new rectangle
    // encloses the original one.
    r.size.width = floor(r.size.width);
    r.size.height = floor(r.size.height);
    
    // Convert back to user space.
    return CGContextConvertRectToUserSpace(context, r);
}