PageRenderTime 26ms CodeModel.GetById 20ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/Frameworks/Debug/AppKit/browser.platform/CGGeometry.j

http://github.com/jfahrenkrug/MapKit-HelloWorld
Unknown | 122 lines | 121 code | 1 blank | 0 comment | 0 complexity | 743bb352230a412e937f1b0fca0e31c3 MD5 | raw file
  1c;7658;CGPointMake= function(x, y) { return { x:x, y:y }; }
  2CGPointMakeZero= function() { return { x:0.0, y:0.0 }; }
  3CGPointMakeCopy= function(aPoint) { return { x:aPoint.x, y:aPoint.y }; }
  4CGPointCreateCopy= function(aPoint) { return { x:aPoint.x, y:aPoint.y }; }
  5CGPointEqualToPoint= function(lhsPoint, rhsPoint) { return (lhsPoint.x == rhsPoint.x && lhsPoint.y == rhsPoint.y); }
  6CGStringFromPoint= function(aPoint) { return ("{" + aPoint.x + ", " + aPoint.y + "}"); }
  7CGSizeMake= function(width, height) { return { width:width, height:height }; }
  8CGSizeMakeZero= function() { return { width:0.0, height:0.0 }; }
  9CGSizeMakeCopy= function(aSize) { return { width:aSize.width, height:aSize.height }; }
 10CGSizeCreateCopy= function(aSize) { return { width:aSize.width, height:aSize.height }; }
 11CGSizeEqualToSize= function(lhsSize, rhsSize) { return (lhsSize.width == rhsSize.width && lhsSize.height == rhsSize.height); }
 12CGStringFromSize= function(aSize) { return ("{" + aSize.width + ", " + aSize.height + "}"); }
 13CGRectMake= function(x, y, width, height) { return { origin: { x:x, y:y }, size: { width:width, height:height } }; }
 14CGRectMakeZero= function() { return { origin: { x:0.0, y:0.0 }, size: { width:0.0, height:0.0 } }; }
 15CGRectMakeCopy= function(aRect) { return { origin: { x:aRect.origin.x, y:aRect.origin.y }, size: { width:aRect.size.width, height:aRect.size.height } }; }
 16CGRectCreateCopy= function(aRect) { return { origin: { x:aRect.origin.x, y:aRect.origin.y }, size: { width:aRect.size.width, height:aRect.size.height } }; }
 17CGRectEqualToRect= function(lhsRect, rhsRect) { return ((lhsRect.origin.x == rhsRect.origin.x && lhsRect.origin.y == rhsRect.origin.y) && (lhsRect.size.width == rhsRect.size.width && lhsRect.size.height == rhsRect.size.height)); }
 18CGStringFromRect= function(aRect) { return ("{" + ("{" + aRect.origin.x + ", " + aRect.origin.y + "}") + ", " + ("{" + aRect.size.width + ", " + aRect.size.height + "}") + "}"); }
 19CGRectOffset= function(aRect, dX, dY) { return { origin: { x:aRect.origin.x + dX, y:aRect.origin.y + dY }, size: { width:aRect.size.width, height:aRect.size.height } }; }
 20CGRectInset= function(aRect, dX, dY) { return { origin: { x:aRect.origin.x + dX, y:aRect.origin.y + dY }, size: { width:aRect.size.width - 2 * dX, height:aRect.size.height - 2 * dY } }; }
 21CGRectGetHeight= function(aRect) { return (aRect.size.height); }
 22CGRectGetMaxX= function(aRect) { return (aRect.origin.x + aRect.size.width); }
 23CGRectGetMaxY= function(aRect) { return (aRect.origin.y + aRect.size.height); }
 24CGRectGetMidX= function(aRect) { return (aRect.origin.x + (aRect.size.width) / 2.0); }
 25CGRectGetMidY= function(aRect) { return (aRect.origin.y + (aRect.size.height) / 2.0); }
 26CGRectGetMinX= function(aRect) { return (aRect.origin.x); }
 27CGRectGetMinY= function(aRect) { return (aRect.origin.y); }
 28CGRectGetWidth= function(aRect) { return (aRect.size.width); }
 29CGRectIsEmpty= function(aRect) { return (aRect.size.width <= 0.0 || aRect.size.height <= 0.0); }
 30CGRectIsNull= function(aRect) { return (aRect.size.width <= 0.0 || aRect.size.height <= 0.0); }
 31CGRectContainsPoint= function(aRect, aPoint) { return (aPoint.x >= (aRect.origin.x) && aPoint.y >= (aRect.origin.y) && aPoint.x < (aRect.origin.x + aRect.size.width) && aPoint.y < (aRect.origin.y + aRect.size.height)); }
 32CGInsetMake= function(top, right, bottom, left) { return { top:(top), right:(right), bottom:(bottom), left:(left) }; }
 33CGInsetMakeZero= function() { return { top:(0), right:(0), bottom:(0), left:(0) }; }
 34CGInsetMakeCopy= function(anInset) { return { top:(anInset.top), right:(anInset.right), bottom:(anInset.bottom), left:(anInset.left) }; }
 35CGInsetIsEmpty= function(anInset) { return ((anInset).top === 0 && (anInset).right === 0 && (anInset).bottom === 0 && (anInset).left === 0); }
 36CGRectContainsRect= function(lhsRect, rhsRect)
 37{
 38    var union = CGRectUnion(lhsRect, rhsRect);
 39    return ((union.origin.x == lhsRect.origin.x && union.origin.y == lhsRect.origin.y) && (union.size.width == lhsRect.size.width && union.size.height == lhsRect.size.height));
 40}
 41CGRectIntersectsRect= function(lhsRect, rhsRect)
 42{
 43    var intersection = CGRectIntersection(lhsRect, rhsRect);
 44    return !(intersection.size.width <= 0.0 || intersection.size.height <= 0.0);
 45}
 46CGRectIntegral= function(aRect)
 47{
 48    aRect = CGRectStandardize(aRect);
 49    var x = FLOOR((aRect.origin.x)),
 50        y = FLOOR((aRect.origin.y));
 51    aRect.size.width = CEIL((aRect.origin.x + aRect.size.width)) - x;
 52    aRect.size.height = CEIL((aRect.origin.y + aRect.size.height)) - y;
 53    aRect.origin.x = x;
 54    aRect.origin.y = y;
 55    return aRect;
 56}
 57CGRectIntersection= function(lhsRect, rhsRect)
 58{
 59    var intersection = { origin: { x:MAX((lhsRect.origin.x), (rhsRect.origin.x)), y:MAX((lhsRect.origin.y), (rhsRect.origin.y)) }, size: { width:0, height:0 } };
 60    intersection.size.width = MIN((lhsRect.origin.x + lhsRect.size.width), (rhsRect.origin.x + rhsRect.size.width)) - (intersection.origin.x);
 61    intersection.size.height = MIN((lhsRect.origin.y + lhsRect.size.height), (rhsRect.origin.y + rhsRect.size.height)) - (intersection.origin.y);
 62    return (intersection.size.width <= 0.0 || intersection.size.height <= 0.0) ? { origin: { x:0.0, y:0.0 }, size: { width:0.0, height:0.0 } } : intersection;
 63}
 64CGRectStandardize= function(aRect)
 65{
 66    var width = (aRect.size.width),
 67        height = (aRect.size.height),
 68        standardized = aRect;
 69    if (width < 0.0)
 70    {
 71        if (standardized == aRect)
 72            standardized = { origin: { x:aRect.origin.x, y:aRect.origin.y }, size: { width:aRect.size.width, height:aRect.size.height } };
 73        standardized.origin.x += width;
 74        standardized.size.width = -width;
 75    }
 76    if (height < 0.0)
 77    {
 78        if (standardized == aRect)
 79            standardized = { origin: { x:aRect.origin.x, y:aRect.origin.y }, size: { width:aRect.size.width, height:aRect.size.height } };
 80        standardized.origin.y += height;
 81        standardized.size.height = -height;
 82    }
 83    return standardized;
 84}
 85CGRectUnion= function(lhsRect, rhsRect)
 86{
 87    var minX = MIN((lhsRect.origin.x), (rhsRect.origin.x)),
 88        minY = MIN((lhsRect.origin.y), (rhsRect.origin.y)),
 89        maxX = MAX((lhsRect.origin.x + lhsRect.size.width), (rhsRect.origin.x + rhsRect.size.width)),
 90        maxY = MAX((lhsRect.origin.y + lhsRect.size.height), (rhsRect.origin.y + rhsRect.size.height));
 91    return { origin: { x:minX, y:minY }, size: { width:maxX - minX, height:maxY - minY } };
 92}
 93CGPointFromString= function(aString)
 94{
 95    var comma = aString.indexOf(',');
 96    return { x:parseInt(aString.substr(1, comma - 1)), y:parseInt(aString.substring(comma + 1, aString.length)) };
 97}
 98CGSizeFromString= function(aString)
 99{
100    var comma = aString.indexOf(',');
101    return { width:parseInt(aString.substr(1, comma - 1)), height:parseInt(aString.substring(comma + 1, aString.length)) };
102}
103CGRectFromString= function(aString)
104{
105    var comma = aString.indexOf(',', aString.indexOf(',') + 1);
106    return { origin:CGPointFromString(aString.substr(1, comma - 1)), size:CGSizeFromString(aString.substring(comma + 2, aString.length)) };
107}
108CGPointFromEvent= function(anEvent)
109{
110    return { x:anEvent.clientX, y:anEvent.clientY };
111}
112CGInsetFromString= function(aString)
113{
114    var numbers = aString.substr(1, aString.length - 2).split(',');
115    return { top:(parseFloat(numbers[0])), right:(parseFloat(numbers[1])), bottom:(parseFloat(numbers[2])), left:(parseFloat(numbers[3])) };
116}
117CGInsetFromCPString = CGInsetFromString;
118CPStringFromCGInset= function(anInset)
119{
120    return '{' + anInset.top + ", " + anInset.left + ", " + anInset.bottom + ", " + anInset.right + '}';
121}
122