Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Little cleaning of BlCompositeBackground #412

Merged
merged 1 commit into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Bloc-Alexandrie/BlCompositeBackground.extension.st
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ Extension { #name : #BlCompositeBackground }
{ #category : #'*Bloc-Alexandrie' }
BlCompositeBackground >> aeApplyTo: aeCanvas [
"Draw all backgrounds in add order"
backgrounds do:[ :b | b aeApplyTo: aeCanvas ].

self backgrounds do: [ :background | background aeApplyTo: aeCanvas ]
]
27 changes: 13 additions & 14 deletions src/Bloc/BlCompositeBackground.class.st
Original file line number Diff line number Diff line change
@@ -1,27 +1,30 @@
"
I provide composition ability of multiple `=BlBackground`=.
I provide composition ability of multiple `BlBackground`.
I am useful when an Element should have both paint and image backgrounds.

Note: composed backgrounds are rendered in the same order they are defined in a composition. So for example if I was created as follows:

```
BlCompositeBackground withAll: {
BlPaintBackground paint: Color red.
BlImageBackground image: PolymorphSystemSettings pharoLogoForm
}
```

then image background will appear on top of paint background.
Then image background will appear on top of paint background.

It is more convenient to create a composite background using `=BlBackgroundBuilder`=
It is more convenient to create a composite background using `BlBackgroundBuilder`.

Opacity example:

```
BlCompositeBackground new
opacity: 0.5;
withAll: {
BlPaintBackground paint: Color red.
BlImageBackground image: PolymorphSystemSettings pharoLogoForm
}

```
"
Class {
#name : #BlCompositeBackground,
Expand All @@ -34,6 +37,7 @@ Class {

{ #category : #'instance creation' }
BlCompositeBackground class >> withAll: aCollectionOfBackground [

^ self new withAll: aCollectionOfBackground
]

Expand All @@ -44,28 +48,23 @@ BlCompositeBackground >> backgrounds [
^ backgrounds
]

{ #category : #initialization }
BlCompositeBackground >> initialize [

super initialize.
backgrounds := Array new
]

{ #category : #testing }
BlCompositeBackground >> isTransparent [

^ (self opacity closeTo: 0.0) or: [ backgrounds allSatisfy: #isTransparent ]
^ (self opacity closeTo: 0.0) or: [ self backgrounds allSatisfy: #isTransparent ]
]

{ #category : #geometry }
BlCompositeBackground >> matchExtent: anExtent [
backgrounds do: [ :aBackground | aBackground matchExtent: anExtent ]
self backgrounds do: [ :aBackground | aBackground matchExtent: anExtent ]
]

{ #category : #initialization }
BlCompositeBackground >> withAll: aCollectionOfBackgrounds [
"Return a composite background based on the collection of background pass as argument.
This collection of backgrounds must not be empty"

backgrounds := aCollectionOfBackgrounds asArray copy
backgrounds := aCollectionOfBackgrounds isArray
ifTrue: [ aCollectionOfBackgrounds copy ]
ifFalse: [ aCollectionOfBackgrounds asArray ]
]