Merge pull request #3111 from daboe01/CPImage_Drawing

new: CPImage method drawAtPoint:fromRect: operation: fraction:
This commit is contained in:
daboe01
2025-06-25 19:26:00 +02:00
committed by GitHub
+39
View File
@@ -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