oop CGContextConvertPointToDeviceSpace_wrap(CGContextRef c, float x, float y) { CGPoint p = CGContextConvertPointToDeviceSpace(c, CGPointMake(x, y)); objVectorOop r = Memory->objVectorObj->cloneSize(2); r->obj_at_put(0, as_floatOop(p.x), false); r->obj_at_put(1, as_floatOop(p.y), false); return r; }
//----------------------------------------------------------------------------- CGPoint CGDrawContext::pixelAlligned (const CGPoint& p) const { CGPoint result = CGContextConvertPointToDeviceSpace (cgContext, p); result.x = std::round (result.x); result.y = std::round (result.y); result = CGContextConvertPointToUserSpace (cgContext, result); return result; }
static CGPoint alignPointToUserSpace(CGContextRef context, CGPoint p) { // Compute the coordinates of the point in device space. p = CGContextConvertPointToDeviceSpace(context, p); // Ensure that coordinates are at exactly the corner // of a device pixel. p.x = floor(p.x); p.y = floor(p.y); // Convert the device aligned coordinate back to user space. return CGContextConvertPointToUserSpace(context, p); }