Skip to content

Commit

Permalink
Cairo context: introduce #maskContext: which paints at 0@0
Browse files Browse the repository at this point in the history
  • Loading branch information
tinchodias committed Nov 29, 2024
1 parent 27e60e6 commit ef5e1b1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ AeCairoExamplesRenderTest >> surfaceWithColoredIcons [
do: [ :eachColor |
outputContext
sourceColor: eachColor;
maskSurface: inputSurface x: 0 y: 0 ]
maskSurface: inputSurface ]
separatedBy: [
outputContext
translateByX: inputSurface width
Expand Down
12 changes: 10 additions & 2 deletions src/Alexandrie-Cairo/AeCairoContext.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -1059,9 +1059,17 @@ AeCairoContext >> maskGroupWith: aBlockClosure [
]

{ #category : #'API - painting' }
AeCairoContext >> maskSurface: anAeCairoImageSurface at: aPoint [
AeCairoContext >> maskSurface: aSurface [
"Paint the current source using the alpha channel of surface as a mask, at 0@0."

self maskSurface: anAeCairoImageSurface x: aPoint x y: aPoint y
self maskSurface: aSurface x: 0.0 x y: 0.0
]

{ #category : #'API - painting' }
AeCairoContext >> maskSurface: aSurface at: aPoint [
"Paint the current source using the alpha channel of surface as a mask, at the specified Point."

self maskSurface: aSurface x: aPoint x y: aPoint y
]

{ #category : #'API - painting' }
Expand Down
2 changes: 1 addition & 1 deletion src/Alexandrie-Cairo/AeCairoImageSurface.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ AeCairoImageSurface >> asAlphaChannelGrayscaleImage [
sourceColorR: 1.0 g: 1.0 b: 1.0;
paint;
sourceColorR: 0.0 g: 0.0 b: 0.0;
maskSurface: self x: 0.0 y: 0.0.
maskSurface: self.

^ aSurface

Expand Down

0 comments on commit ef5e1b1

Please sign in to comment.