mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-09-27 12:47:42 +00:00
Merge pull request #3111 from daboe01/CPImage_Drawing
new: CPImage method drawAtPoint:fromRect: operation: fraction:
This commit is contained in:
@@ -31,6 +31,7 @@
|
||||
|
||||
@import "CGGeometry.j"
|
||||
@import "CPCompatibility.j"
|
||||
@import "CPGraphicsContext.j"
|
||||
|
||||
@class CPColor
|
||||
@global document
|
||||
@@ -774,6 +775,44 @@ var CPImageCSSDictionaryKey = @"CPImageCSSDictionaryKey",
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Drawing
|
||||
|
||||
@implementation CPImage (Drawing)
|
||||
|
||||
- (void)drawAtPoint:(CGPoint)point fromRect:(CPRect)fromRect operation:(CGBlendMode)op fraction:(float)delta
|
||||
{
|
||||
if (_loadStatus !== CPImageLoadStatusCompleted)
|
||||
return;
|
||||
|
||||
var context = [CPGraphicsContext currentContext].graphicsPort;
|
||||
|
||||
if (!context)
|
||||
return;
|
||||
|
||||
CGContextSaveGState(context);
|
||||
|
||||
CGContextSetBlendMode(context, op);
|
||||
CGContextSetAlpha(context, delta);
|
||||
|
||||
context.drawImage(
|
||||
_image,
|
||||
fromRect.origin.x,
|
||||
fromRect.origin.y,
|
||||
fromRect.size.width,
|
||||
fromRect.size.height,
|
||||
point.x,
|
||||
point.y,
|
||||
fromRect.size.width,
|
||||
fromRect.size.height
|
||||
);
|
||||
|
||||
CGContextRestoreGState(context);
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
#pragma mark -
|
||||
|
||||
@implementation _CPMaterialIconImage : CPImage
|
||||
|
||||
Reference in New Issue
Block a user