mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-08-30 15:33:35 +00:00
+8
-8
@@ -96,12 +96,12 @@ function CPRectIntegral(aRect)
|
||||
function CPRectIntersection(lhsRect, rhsRect)
|
||||
{
|
||||
var intersection = CPRectMake(
|
||||
Math.max(CPRectGetMinX(lhsRect), CPRectGetMinX(rhsRect)),
|
||||
Math.max(CPRectGetMinY(lhsRect), CPRectGetMinY(rhsRect)),
|
||||
MAX(CPRectGetMinX(lhsRect), CPRectGetMinX(rhsRect)),
|
||||
MAX(CPRectGetMinY(lhsRect), CPRectGetMinY(rhsRect)),
|
||||
0, 0);
|
||||
|
||||
intersection.size.width = Math.min(CPRectGetMaxX(lhsRect), CPRectGetMaxX(rhsRect)) - CPRectGetMinX(intersection);
|
||||
intersection.size.height = Math.min(CPRectGetMaxY(lhsRect), CPRectGetMaxY(rhsRect)) - CPRectGetMinY(intersection);
|
||||
intersection.size.width = MIN(CPRectGetMaxX(lhsRect), CPRectGetMaxX(rhsRect)) - CPRectGetMinX(intersection);
|
||||
intersection.size.height = MIN(CPRectGetMaxY(lhsRect), CPRectGetMaxY(rhsRect)) - CPRectGetMinY(intersection);
|
||||
|
||||
return CPRectIsEmpty(intersection) ? CPRectMakeZero() : intersection;
|
||||
}
|
||||
@@ -179,10 +179,10 @@ function CPRectStandardize(aRect)
|
||||
*/
|
||||
function CPRectUnion(lhsRect, rhsRect)
|
||||
{
|
||||
var minX = Math.min(CPRectGetMinX(lhsRect), CPRectGetMinX(rhsRect)),
|
||||
minY = Math.min(CPRectGetMinY(lhsRect), CPRectGetMinY(rhsRect)),
|
||||
maxX = Math.max(CPRectGetMaxX(lhsRect), CPRectGetMaxX(rhsRect)),
|
||||
maxY = Math.max(CPRectGetMaxY(lhsRect), CPRectGetMaxY(rhsRect));
|
||||
var minX = MIN(CPRectGetMinX(lhsRect), CPRectGetMinX(rhsRect)),
|
||||
minY = MIN(CPRectGetMinY(lhsRect), CPRectGetMinY(rhsRect)),
|
||||
maxX = MAX(CPRectGetMaxX(lhsRect), CPRectGetMaxX(rhsRect)),
|
||||
maxY = MAX(CPRectGetMaxY(lhsRect), CPRectGetMaxY(rhsRect));
|
||||
|
||||
return CPRectMake(minX, minY, maxX - minX, maxY - minY);
|
||||
}
|
||||
|
||||
+1
-1
@@ -61,7 +61,7 @@
|
||||
_blurRadius = aBlurRadius;
|
||||
_color = aColor;
|
||||
|
||||
_cssString = [_color cssString] + " " + Math.round(anOffset.width) + @"px " + Math.round(anOffset.height) + @"px " + Math.round(_blurRadius) + @"px";
|
||||
_cssString = [_color cssString] + " " + ROUND(anOffset.width) + @"px " + ROUND(anOffset.height) + @"px " + ROUND(_blurRadius) + @"px";
|
||||
}
|
||||
|
||||
return self;
|
||||
|
||||
+2
-2
@@ -144,8 +144,8 @@
|
||||
minSize = _CGSizeMake(upSize.width, upSize.height + downSize.height),
|
||||
frame = _CGRectMakeCopy(aFrame);
|
||||
|
||||
frame.size.width = Math.max(minSize.width, frame.size.width);
|
||||
frame.size.height = Math.max(minSize.height, frame.size.height);
|
||||
frame.size.width = MAX(minSize.width, frame.size.width);
|
||||
frame.size.height = MAX(minSize.height, frame.size.height);
|
||||
[super setFrame:frame];
|
||||
}
|
||||
|
||||
|
||||
@@ -323,7 +323,7 @@ function CGContextTranslateCTM(aContext, tx, ty)
|
||||
|
||||
#define rotate_scale(a, b, c, d) \
|
||||
var sign = (a * d < 0.0 || b * c > 0.0) ? -1.0 : 1.0;\
|
||||
a1 = (Math.atan2(sign * b, sign * a) + Math.atan2(-c, d)) / 2.0,\
|
||||
a1 = (ATAN2(sign * b, sign * a) + ATAN2(-c, d)) / 2.0,\
|
||||
cos = COS(a1),\
|
||||
sin = SIN(a1);\
|
||||
\
|
||||
|
||||
@@ -255,7 +255,7 @@ var CPCharacterSetInvertedKey = @"CPCharacterSetInvertedKey";
|
||||
// FIXME: range is undefined... don't know what's supposed to be going on here.
|
||||
// the highest Unicode plane we reach.
|
||||
// (There are 65536 code points in each plane.)
|
||||
var maxPlane = Math.floor((range.start + range.length - 1) / 65536); // FIXME: should iterate _ranges
|
||||
var maxPlane = FLOOR((range.start + range.length - 1) / 65536); // FIXME: should iterate _ranges
|
||||
|
||||
return (plane <= maxPlane);
|
||||
}
|
||||
|
||||
@@ -64,6 +64,7 @@ GLOBAL(SQRT) = Math.sqrt;
|
||||
GLOBAL(E) = Math.E;
|
||||
GLOBAL(LN2) = Math.LN2;
|
||||
GLOBAL(LN10) = Math.LN10;
|
||||
GLOBAL(LOG) = Math.log;
|
||||
GLOBAL(LOG2E) = Math.LOG2E;
|
||||
GLOBAL(LOG10E) = Math.LOG10E;
|
||||
|
||||
|
||||
@@ -131,8 +131,8 @@
|
||||
},
|
||||
|
||||
"rotation" : {
|
||||
testdata: CGAffineTransformConcat(CGAffineTransformMakeRotation(Math.PI),
|
||||
CGAffineTransformMakeRotation(-Math.PI)),
|
||||
testdata: CGAffineTransformConcat(CGAffineTransformMakeRotation(PI),
|
||||
CGAffineTransformMakeRotation(-PI)),
|
||||
expdata: CGAffineTransformMakeIdentity()
|
||||
},
|
||||
};
|
||||
@@ -234,8 +234,8 @@
|
||||
},
|
||||
|
||||
"rotation" : {
|
||||
testdata: CGAffineTransformConcat(CGAffineTransformMakeRotation(-Math.PI),
|
||||
CGAffineTransformMakeRotation(Math.PI)),
|
||||
testdata: CGAffineTransformConcat(CGAffineTransformMakeRotation(-PI),
|
||||
CGAffineTransformMakeRotation(PI)),
|
||||
},
|
||||
|
||||
};
|
||||
@@ -262,12 +262,12 @@
|
||||
},
|
||||
|
||||
"rotation" : {
|
||||
testdata: CGAffineTransformMakeRotation(Math.PI),
|
||||
testdata: CGAffineTransformMakeRotation(PI),
|
||||
},
|
||||
|
||||
// TODO a two-pi rotation is actually identity
|
||||
"2PI rotation is NOT identity?" : {
|
||||
testdata: CGAffineTransformMakeRotation(Math.PI * 2),
|
||||
testdata: CGAffineTransformMakeRotation(PI * 2),
|
||||
},
|
||||
|
||||
};
|
||||
@@ -300,8 +300,8 @@
|
||||
},
|
||||
|
||||
"rotation" : {
|
||||
lhs: CGAffineTransformMakeRotation(Math.PI),
|
||||
rhs: CGAffineTransformMakeRotation(Math.PI),
|
||||
lhs: CGAffineTransformMakeRotation(PI),
|
||||
rhs: CGAffineTransformMakeRotation(PI),
|
||||
expdata: YES
|
||||
},
|
||||
|
||||
@@ -373,22 +373,22 @@
|
||||
},
|
||||
|
||||
"rotation - pi" : {
|
||||
testdata: CGAffineTransformMakeRotation(Math.PI),
|
||||
testdata: CGAffineTransformMakeRotation(PI),
|
||||
expdata: "{-1, 1.2246467991473532e-16, -1.2246467991473532e-16, -1, 0, 0}"
|
||||
},
|
||||
|
||||
"rotation - 2pi" : {
|
||||
testdata: CGAffineTransformMakeRotation(2 * Math.PI),
|
||||
testdata: CGAffineTransformMakeRotation(2 * PI),
|
||||
expdata: "{1, -2.4492935982947064e-16, 2.4492935982947064e-16, 1, 0, 0}"
|
||||
},
|
||||
|
||||
"rotation - 3pi" : {
|
||||
testdata: CGAffineTransformMakeRotation(3 * Math.PI),
|
||||
testdata: CGAffineTransformMakeRotation(3 * PI),
|
||||
expdata: "{-1, 3.6739403974420594e-16, -3.6739403974420594e-16, -1, 0, 0}"
|
||||
},
|
||||
|
||||
"scale and translation and rotate" : {
|
||||
testdata: CGAffineTransformRotate(CGAffineTransformTranslate(CGAffineTransformMakeScale(3,4),5,6),Math.PI),
|
||||
testdata: CGAffineTransformRotate(CGAffineTransformTranslate(CGAffineTransformMakeScale(3,4),5,6),PI),
|
||||
expdata: "{-3, 4.898587196589413e-16, -3.6739403974420594e-16, -4, 15, 24}"
|
||||
},
|
||||
};
|
||||
@@ -401,7 +401,7 @@
|
||||
|
||||
- (void)testAffineTransformRotate
|
||||
{
|
||||
var ang = Math.PI + 0.5 * Math.PI,
|
||||
var ang = PI + 0.5 * PI,
|
||||
transform = CGAffineTransformMake( 1,2,3,4, 5,6 ),
|
||||
cos = COS(ang),
|
||||
sin = SIN(ang);
|
||||
@@ -417,7 +417,7 @@
|
||||
},
|
||||
|
||||
"rotation negation" : {
|
||||
testdata: CGAffineTransformRotate(CGAffineTransformRotate(CGAffineTransformMakeScale(3,4),Math.PI),-Math.PI),
|
||||
testdata: CGAffineTransformRotate(CGAffineTransformRotate(CGAffineTransformMakeScale(3,4),PI),-PI),
|
||||
expdata: CGAffineTransformMakeScale(3,4)
|
||||
}
|
||||
};
|
||||
@@ -428,7 +428,7 @@
|
||||
|
||||
- (void)testAffineTransformInvert
|
||||
{
|
||||
var transform = CGAffineTransformRotate(CGAffineTransformTranslate(CGAffineTransformMakeScale(3,4),5,6),Math.PI),
|
||||
var transform = CGAffineTransformRotate(CGAffineTransformTranslate(CGAffineTransformMakeScale(3,4),5,6),PI),
|
||||
determinant = 1 / (transform.a * transform.d - transform.b * transform.c),
|
||||
invertedtransform = CGAffineTransformMake(determinant * transform.d,
|
||||
-determinant * transform.b,
|
||||
@@ -451,8 +451,8 @@
|
||||
},
|
||||
|
||||
"rotation" : {
|
||||
testdata: CGAffineTransformMakeRotation(-Math.PI),
|
||||
expdata: CGAffineTransformMakeRotation(Math.PI),
|
||||
testdata: CGAffineTransformMakeRotation(-PI),
|
||||
expdata: CGAffineTransformMakeRotation(PI),
|
||||
},
|
||||
|
||||
"translation" : {
|
||||
@@ -483,7 +483,7 @@
|
||||
},
|
||||
|
||||
"rotation 90 degrees" : {
|
||||
testdata: CGRectApplyAffineTransform(rect, CGAffineTransformMakeRotation(Math.PI/2)),
|
||||
testdata: CGRectApplyAffineTransform(rect, CGAffineTransformMakeRotation(PI/2)),
|
||||
expdata: CGRectMake( -10,3.0000000000000004,6,5 )
|
||||
},
|
||||
|
||||
@@ -498,7 +498,7 @@
|
||||
},
|
||||
|
||||
"rotate, translate and scale" : {
|
||||
testdata: CGRectApplyAffineTransform(rect, CGAffineTransformRotate(CGAffineTransformTranslate(CGAffineTransformMakeScale(3,4),5,6),Math.PI)),
|
||||
testdata: CGRectApplyAffineTransform(rect, CGAffineTransformRotate(CGAffineTransformTranslate(CGAffineTransformMakeScale(3,4),5,6),PI)),
|
||||
expdata: CGRectMake( -9.000000000000004, -16,
|
||||
15.000000000000002, 24.000000000000004 )
|
||||
},
|
||||
|
||||
@@ -15,10 +15,10 @@
|
||||
{
|
||||
var rgbaColour = [CPColor colorWithCSSString:@"rgba(32, 64, 128, 0.5)"];
|
||||
|
||||
[self assert:32 equals:Math.round([rgbaColour redComponent] * 255) message:"red component"];
|
||||
[self assert:64 equals:Math.round([rgbaColour greenComponent] * 255) message:"green component"];
|
||||
[self assert:128 equals:Math.round([rgbaColour blueComponent] * 255) message:"blue component"];
|
||||
[self assert:128 equals:Math.round([rgbaColour alphaComponent] * 255) message:"alpha component"];
|
||||
[self assert:32 equals:ROUND([rgbaColour redComponent] * 255) message:"red component"];
|
||||
[self assert:64 equals:ROUND([rgbaColour greenComponent] * 255) message:"green component"];
|
||||
[self assert:128 equals:ROUND([rgbaColour blueComponent] * 255) message:"blue component"];
|
||||
[self assert:128 equals:ROUND([rgbaColour alphaComponent] * 255) message:"alpha component"];
|
||||
}
|
||||
|
||||
- (void)testIsEqual_
|
||||
|
||||
@@ -193,7 +193,7 @@
|
||||
{
|
||||
var view = allViews[i],
|
||||
column = i % 2,
|
||||
row = startingRow + Math.floor(i / 2); // Two columns per row.
|
||||
row = startingRow + FLOOR(i / 2); // Two columns per row.
|
||||
//CPLog.error([view stringValue] + " frame: " + CPStringFromRect([tableView convertRect:[view frame] toView:nil]));
|
||||
[self assert:("R" + row + "C" + column) equals:[view stringValue] message:"(" + row + ", " + column + ") string value"];
|
||||
[self assert:"CustomTextView" + column equals:[[view class] description] message:"(" + row + ", " + column + ") data view"];
|
||||
@@ -205,11 +205,11 @@
|
||||
var allViews = AssertCorrectCellsVisible(0),
|
||||
visibleHeight = [tableView visibleRect].size.height,
|
||||
fullRowHeight = [tableView rowHeight] + [tableView intercellSpacing].height,
|
||||
visibleRows = Math.ceil(visibleHeight / fullRowHeight);
|
||||
visibleRows = CEIL(visibleHeight / fullRowHeight);
|
||||
[self assert:2 * visibleRows equals:[allViews count] message:"only as many data views as necessary should be present"];
|
||||
|
||||
// Now if we scroll down, new views should come in and others should go out.
|
||||
var rowTwentyFiveAndAHalfY = Math.floor(25.5 * fullRowHeight);
|
||||
var rowTwentyFiveAndAHalfY = FLOOR(25.5 * fullRowHeight);
|
||||
[tableView scrollPoint:CGPointMake(0, rowTwentyFiveAndAHalfY)];
|
||||
[[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode];
|
||||
|
||||
|
||||
@@ -85,7 +85,7 @@
|
||||
expectedMinute = 31,
|
||||
offset = -date.getTimezoneOffset(),
|
||||
offsetPositive = offset >= 0,
|
||||
offsetHours = offsetPositive ? Math.floor(offset / 60) : Math.ceil(offset / 60),
|
||||
offsetHours = offsetPositive ? FLOOR(offset / 60) : CEIL(offset / 60),
|
||||
offsetMinutes = offset - offsetHours * 60,
|
||||
expectedString;
|
||||
expectedHour += offsetHours;
|
||||
|
||||
@@ -17,7 +17,7 @@ var RecordData = [
|
||||
|
||||
var randomFromTo = function(from, to)
|
||||
{
|
||||
return Math.floor(Math.random() * (to - from + 1) + from);
|
||||
return FLOOR(RAND() * (to - from + 1) + from);
|
||||
};
|
||||
|
||||
@implementation AppController : CPObject
|
||||
|
||||
@@ -42,12 +42,12 @@
|
||||
launchAvg /= data.length;
|
||||
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
loadStdev += Math.pow(data[i][0] - loadAvg, 2);
|
||||
launchStdev += Math.pow(data[i][1] - launchAvg, 2);
|
||||
loadStdev += POW(data[i][0] - loadAvg, 2);
|
||||
launchStdev += POW(data[i][1] - launchAvg, 2);
|
||||
}
|
||||
|
||||
loadStdev = Math.sqrt(loadStdev / data.length);
|
||||
launchStdev = Math.sqrt(launchStdev / data.length);
|
||||
loadStdev = SQRT(loadStdev / data.length);
|
||||
launchStdev = SQRT(launchStdev / data.length);
|
||||
|
||||
if (window.parent.BCOMM) {
|
||||
window.parent.BCOMM.finishTest({
|
||||
@@ -63,7 +63,7 @@
|
||||
|
||||
var label = [[CPTextField alloc] initWithFrame:CGRectMakeZero()];
|
||||
|
||||
[label setStringValue:"load avg="+Math.round(loadAvg)+" (stdev="+Math.round(loadStdev)+"); launch avg="+Math.round(launchAvg)+" (stdev="+Math.round(launchStdev)+")"];
|
||||
[label setStringValue:"load avg="+ROUND(loadAvg)+" (stdev="+ROUND(loadStdev)+"); launch avg="+ROUND(launchAvg)+" (stdev="+ROUND(launchStdev)+")"];
|
||||
[label setFont:[CPFont boldSystemFontOfSize:24.0]];
|
||||
|
||||
[label sizeToFit];
|
||||
|
||||
@@ -59,13 +59,13 @@
|
||||
|
||||
- (void)changeBorderWidth:(id)sender
|
||||
{
|
||||
[standardBox setBorderWidth:ROUND(Math.random() * 7)];
|
||||
[standardBox setBorderWidth:ROUND(RAND() * 7)];
|
||||
}
|
||||
|
||||
- (void)changeBorderColor:(id)sender
|
||||
{
|
||||
[customBox setBorderColor:[CPColor randomColor]];
|
||||
[customBox setCornerRadius:ROUND(Math.random() * 10)];
|
||||
[customBox setCornerRadius:ROUND(RAND() * 10)];
|
||||
}
|
||||
|
||||
- (void)changeContentView:(id)sender
|
||||
|
||||
@@ -86,7 +86,7 @@
|
||||
|
||||
- (IBAction)randomTitle:(id)aSender
|
||||
{
|
||||
[theWindow setTitle:@"Window random number " + Math.random(1000)];
|
||||
[theWindow setTitle:@"Window random number " + RAND(1000)];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
- (CPNumber)sqrt:(CPNumber)operand
|
||||
{
|
||||
return Math.sqrt(operand);
|
||||
return SQRT(operand);
|
||||
}
|
||||
|
||||
- (CPNumber)multiply:(CPNumber)firstOperand with:(CPNumber)secondOperand
|
||||
|
||||
Reference in New Issue
Block a user