mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-12-05 12:15:32 +00:00
Merge branch 'master' of github.com:280north/cappuccino
This commit is contained in:
commit
2743fe4c0d
5 files changed
+75
-9
No files matched your search
@@ -606,7 +606,7 @@ function CGContextStrokeLineSegments(aContext, points, count)
|
||||
{
|
||||
var i = 0;
|
||||
|
||||
if (arguments["count"] == NULL)
|
||||
if (count === NULL)
|
||||
var count = points.length;
|
||||
|
||||
CGContextBeginPath(aContext);
|
||||
|
||||
@@ -144,7 +144,7 @@ function CGContextAddRects(aContext, rects, count)
|
||||
{
|
||||
var i = 0;
|
||||
|
||||
if (arguments["count"] == NULL)
|
||||
if (count === NULL)
|
||||
var count = rects.length;
|
||||
|
||||
for (; i < count; ++i)
|
||||
@@ -194,7 +194,7 @@ function CGContextFillRects(aContext, rects, count)
|
||||
{
|
||||
var i = 0;
|
||||
|
||||
if (arguments["count"] == NULL)
|
||||
if (count === NULL)
|
||||
var count = rects.length;
|
||||
|
||||
for (; i < count; ++i)
|
||||
@@ -225,7 +225,7 @@ function CGContextClipToRect(aContext, aRect)
|
||||
|
||||
function CGContextClipToRects(aContext, rects, count)
|
||||
{
|
||||
if (arguments["count"] == NULL)
|
||||
if (count === NULL)
|
||||
var count = rects.length;
|
||||
|
||||
_CGContextBeginPathCanvas(aContext);
|
||||
|
||||
@@ -29,10 +29,10 @@ kCGGradientDrawsAfterEndLocation = 1 << 1;
|
||||
|
||||
function CGGradientCreateWithColorComponents(aColorSpace, components, locations, count)
|
||||
{
|
||||
if (arguments["locations"] == NULL)
|
||||
if (locations === NULL)
|
||||
var locations = [0.0, 1.0];
|
||||
|
||||
if (arguments["count"] == NULL)
|
||||
if (count === NULL)
|
||||
var count = locations.length;
|
||||
|
||||
var colors = [];
|
||||
@@ -58,4 +58,4 @@ function CGGradientRelease()
|
||||
function CGGradientRetain(aGradient)
|
||||
{
|
||||
return aGradient;
|
||||
}
|
||||
}
|
||||
@@ -141,7 +141,7 @@ function CGPathAddLines(aPath, aTransform, points, count)
|
||||
{
|
||||
var i = 1;
|
||||
|
||||
if (arguments["count"] == NULL)
|
||||
if (count === NULL)
|
||||
var count = points.length;
|
||||
|
||||
if (!aPath || count < 2)
|
||||
@@ -224,7 +224,7 @@ function CGPathAddRects(aPath, aTransform, rects, count)
|
||||
{
|
||||
var i = 0;
|
||||
|
||||
if (arguments["count"] == NULL)
|
||||
if (count === NULL)
|
||||
var count = rects.length;
|
||||
|
||||
for (; i < count; ++i)
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
@import <AppKit/CGGradient.j>
|
||||
|
||||
@implementation CGGradientTest : OJTestCase
|
||||
|
||||
/*
|
||||
Using default values for location and count.
|
||||
*/
|
||||
- (void)testCreateWithColorComponentsDefault
|
||||
{
|
||||
var components = [ 0.2,0.2,0.4,0.4,
|
||||
0.6,0.6,0.8,0.8 ];
|
||||
|
||||
var tmp = CGGradientCreateWithColorComponents(CGColorSpaceCreateDeviceRGB(),
|
||||
components);
|
||||
[self assert:2 equals:tmp.colors.length];
|
||||
[self assert:2 equals:tmp.locations.length];
|
||||
|
||||
[self assert:0 equals:tmp.locations[0]];
|
||||
[self assert:1.0 equals:tmp.locations[1]];
|
||||
|
||||
[self assert:components.slice(4,8) equals:tmp.colors[1].components];
|
||||
[self assert:components.slice(0,4) equals:tmp.colors[0].components];
|
||||
}
|
||||
|
||||
/*
|
||||
Using location and components to specify two color stops that aren't
|
||||
evenly spread out.
|
||||
*/
|
||||
- (void)testCreateWithColorComponentsUsingTwoColorStops
|
||||
{
|
||||
var components = [ 0.2,0.2,0.4,0.4,
|
||||
0.6,0.6,0.8,0.8 ];
|
||||
var locations = [0.3,0.6];
|
||||
|
||||
var tmp = CGGradientCreateWithColorComponents(CGColorSpaceCreateDeviceRGB(),
|
||||
components,locations);
|
||||
[self assert:2 equals:tmp.colors.length];
|
||||
[self assert:2 equals:tmp.locations.length];
|
||||
|
||||
[self assert:0.3 equals:tmp.locations[0]];
|
||||
[self assert:0.6 equals:tmp.locations[1]];
|
||||
|
||||
[self assert:components.slice(4,8) equals:tmp.colors[1].components];
|
||||
[self assert:components.slice(0,4) equals:tmp.colors[0].components];
|
||||
}
|
||||
|
||||
/*
|
||||
Define three color components and ensure that the Gradient defined contains 3 color stops.
|
||||
*/
|
||||
- (void)testCanHaveMoreThanTwoColorStops
|
||||
{
|
||||
var components = [ 1,2,3,4, 5,6,7,8, 9,10,11,12 ];
|
||||
var locations = [1,2,3];
|
||||
|
||||
var tmp = CGGradientCreateWithColorComponents(CGColorSpaceCreateDeviceRGB(),
|
||||
components, locations, 3);
|
||||
[self assert:3 equals:tmp.colors.length];
|
||||
[self assert:3 equals:tmp.locations.length];
|
||||
|
||||
[self assert:1 equals:tmp.locations[0]];
|
||||
[self assert:2 equals:tmp.locations[1]];
|
||||
[self assert:3 equals:tmp.locations[2]];
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
Reference in new issue
Block a user