mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-12-06 20:55:32 +00:00
Added test for linear/radial gradient
This commit is contained in:
1 parent
de4e28b5cc
commit
22d66438fb
4 files changed
+820
-283
No files matched your search
@@ -11,6 +11,7 @@
|
||||
{
|
||||
@outlet CPWindow window1;
|
||||
@outlet CPWindow window2;
|
||||
@outlet CPWindow window3;
|
||||
|
||||
@outlet CustomDrawView view1;
|
||||
@outlet CustomDrawView view2;
|
||||
@@ -24,6 +25,9 @@
|
||||
|
||||
@outlet CustomDrawView pathView0;
|
||||
@outlet CustomDrawView pathView1;
|
||||
|
||||
@outlet CustomDrawView linearGradientView;
|
||||
@outlet CustomDrawView radialGradientView;
|
||||
}
|
||||
|
||||
- (void)awakeFromCib
|
||||
@@ -185,6 +189,34 @@
|
||||
[starPath stroke];
|
||||
[CPGraphicsContext restoreGraphicsState];
|
||||
}
|
||||
// else
|
||||
else if (aView == linearGradientView)
|
||||
{
|
||||
var linearRect = dirtyRect,
|
||||
gradientColors = CGGradientCreateWithColorComponents(CGColorSpaceCreateDeviceRGB(), [1, 0, 0, 1 , 0, 0, 1, 1], [0,1], 2);
|
||||
|
||||
CGContextSaveGState(context);
|
||||
CGContextAddEllipseInRect(context, linearRect);
|
||||
CGContextClip(context);
|
||||
|
||||
var startPoint = CGPointMake(CGRectGetMidX(linearRect), CGRectGetMinY(linearRect)),
|
||||
endPoint = CGPointMake(CGRectGetMidX(linearRect), CGRectGetMaxY(linearRect));
|
||||
|
||||
CGContextDrawLinearGradient(context, gradientColors, startPoint, endPoint, 0);
|
||||
CGContextRestoreGState(context);
|
||||
}
|
||||
else if(aView == radialGradientView)
|
||||
{
|
||||
var gradientRect = dirtyRect,
|
||||
gradientColors = CGGradientCreateWithColorComponents(CGColorSpaceCreateDeviceRGB(), [1, 0, 0, 1 , 0, 0, 1, 1], [0,1], 2);
|
||||
|
||||
CGContextSaveGState(context);
|
||||
CGContextAddEllipseInRect(context, gradientRect);
|
||||
CGContextClip(context);
|
||||
|
||||
CGContextDrawRadialGradient(context, gradientColors, CGPointMake(CGRectGetMidX(gradientRect), CGRectGetMidY(gradientRect)), 0, CGPointMake(CGRectGetMidX(gradientRect), CGRectGetMidY(gradientRect)), 50,0);
|
||||
CGContextRestoreGState(context);
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 14 KiB |
File diff suppressed because it is too large.
Load diff
Binary file not shown.
|
After Width: | Height: | Size: 34 KiB |
Reference in new issue
Block a user