Skip to content

Commit

Permalink
Canvas: add #restoreContextAfterPaintAlpha:with:
Browse files Browse the repository at this point in the history
  • Loading branch information
tinchodias committed May 3, 2024
1 parent 4d7d79b commit a09dde8
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/Alexandrie-Canvas/AeCanvas.class.st
Expand Up @@ -609,6 +609,20 @@ AeCanvas >> restoreContextAfter: aBlock [
cairoContext restoreStateAfter: aBlock
]

{ #category : #'API - state' }
AeCanvas >> restoreContextAfterPaintAlpha: opacity with: aBlock [
"Evaluate a block to paint with certain opacity (a value in 0.0 to 1.0 interval).
* When opacity is translucent (less than 1.0), then the paint operation in the block
closure will be performed into a 'Cairo group' (a kind of temporary surface) that
will be finally painted with such opacity.
* When opacity is 1.0, then do it more efficiently: paint directly on the target surface,
using Cairo save and restore to keep the Cairo context state untouched on return."

opacity < 1.0
ifTrue: [ self paintGroupWith: aBlock alpha: opacity ]
ifFalse: [ self restoreContextAfter: aBlock ]
]

{ #category : #private }
AeCanvas >> restoreContextOnlyIfClipAfterwards: aBlock [

Expand Down

0 comments on commit a09dde8

Please sign in to comment.