From 2f8dd8c0885945e192d1d33433f81e2a19e7ec48 Mon Sep 17 00:00:00 2001 From: daboe01 Date: Wed, 11 Jun 2025 14:14:30 +0200 Subject: [PATCH 1/2] new: drawAtPoint:(CPPoint)point fromRect:(CPRect)fromRect operation:(CPCompositingOperation)op fraction:(CGFloat)delta --- AppKit/CPImage.j | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/AppKit/CPImage.j b/AppKit/CPImage.j index 0199c8b17..74a7d3ace 100644 --- a/AppKit/CPImage.j +++ b/AppKit/CPImage.j @@ -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:(CPInteger)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 From 98a539657c02e2dd20605f5ddfac3cbab8fad2c1 Mon Sep 17 00:00:00 2001 From: daboe01 Date: Thu, 19 Jun 2025 09:15:08 +0200 Subject: [PATCH 2/2] fixed: type CGBlendMode missing --- AppKit/CPImage.j | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AppKit/CPImage.j b/AppKit/CPImage.j index 74a7d3ace..fc32f5ebf 100644 --- a/AppKit/CPImage.j +++ b/AppKit/CPImage.j @@ -780,7 +780,7 @@ var CPImageCSSDictionaryKey = @"CPImageCSSDictionaryKey", @implementation CPImage (Drawing) -- (void)drawAtPoint:(CGPoint)point fromRect:(CPRect)fromRect operation:(CPInteger)op fraction:(float)delta +- (void)drawAtPoint:(CGPoint)point fromRect:(CPRect)fromRect operation:(CGBlendMode)op fraction:(float)delta { if (_loadStatus !== CPImageLoadStatusCompleted) return;