forked from pharo-graphics/Tutorials
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
renamed #backgroundColor => #backgroundPaint
- Loading branch information
Showing
18 changed files
with
65 additions
and
56 deletions.
There are no files selected for viewing
3 changes: 0 additions & 3 deletions
3
src/Bloc-MemoryGame-Demo.package/MgdCardElement.class/instance/backgroundColor.st
This file was deleted.
Oops, something went wrong.
8 changes: 8 additions & 0 deletions
8
src/Bloc-MemoryGame-Demo.package/MgdCardElement.class/instance/backgroundPaint.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
visual properties | ||
backgroundPaint | ||
"Return a BlPaint that should be used as a background (fill) | ||
of both back and face sides of the card. Color is polymorphic | ||
with BlPaint and therefore can be used too" | ||
<return: #BlPaint or: #Color> | ||
|
||
^ Color lightGray |
12 changes: 10 additions & 2 deletions
12
src/Bloc-MemoryGame-Demo.package/MgdCardElement.class/instance/card..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,13 @@ | ||
accessing | ||
card: aMgCard | ||
card := aMgCard. | ||
card: aMgdCardModel | ||
"Attach a card model and subscribe to its announcements. | ||
aMgdCardModel must not be nil" | ||
|
||
self | ||
assert: [ aMgdCardModel isNotNil ] | ||
description: [ 'Card model must not be nil' ]. | ||
|
||
card := aMgdCardModel. | ||
|
||
card announcer when: MgdCardFlippedAnnouncement send: #onFlipped to: self. | ||
card announcer when: MgdCardDisappearAnnouncement send: #onDisappear to: self |
3 changes: 3 additions & 0 deletions
3
src/Bloc-MemoryGame-Demo.package/MgdCardElement.class/instance/card.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
accessing | ||
card | ||
"Return a card model assigned to this card element" | ||
<return: #MgdCardModel> | ||
|
||
^ card |
2 changes: 1 addition & 1 deletion
2
src/Bloc-MemoryGame-Demo.package/MgdCardElement.class/instance/cornerRadius.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
visual properties | ||
cornerRadius | ||
"Return a number representing a corner radius" | ||
"Return a number representing a corner radius of the card element" | ||
<return: #Number> | ||
|
||
^ 12 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
src/Bloc-MemoryGame-Demo.package/MgdCardElement.class/instance/onFlipped.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
announcement - handling | ||
onFlipped | ||
"Is sent after the card is flipped in the model" | ||
|
||
self card isFlipped | ||
ifTrue: [ self onFlippedFace ] | ||
ifFalse: [ self onFlippedBack ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Is sent by ==MgCardModel== after the card is removed from the ==MgGameModel== |
2 changes: 1 addition & 1 deletion
2
src/Bloc-MemoryGame.package/MgCardDisappearAnnouncement.class/properties.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
I am a visual card modelled by ==MgCardModel== | ||
|
||
A model should be attached by sending #card: to the card element. | ||
Card element reacts on model events such as MgCardFlippedAnnouncement and MgCardDisappearAnnouncement after card is flipped or disappeared. | ||
|
||
By default I do not have a visual representations of the face and back |
3 changes: 0 additions & 3 deletions
3
src/Bloc-MemoryGame.package/MgCardElement.class/instance/backgroundColor.st
This file was deleted.
Oops, something went wrong.
8 changes: 8 additions & 0 deletions
8
src/Bloc-MemoryGame.package/MgCardElement.class/instance/backgroundPaint.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
visual properties | ||
backgroundPaint | ||
"Return a BlPaint that should be used as a background (fill) | ||
of both back and face sides of the card. Color is polymorphic | ||
with BlPaint and therefore can be used too" | ||
<return: #BlPaint or: #Color> | ||
|
||
^ Color lightGray |
2 changes: 1 addition & 1 deletion
2
src/Bloc-MemoryGame.package/MgCardElement.class/properties.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Is sent by ==MgCardModel== after the card is flipped |
2 changes: 1 addition & 1 deletion
2
src/Bloc-MemoryGame.package/MgCardFlippedAnnouncement.class/properties.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 6 additions & 24 deletions
30
src/Bloc-MemoryGame.package/MgRawCardElement.class/instance/drawBacksideOnSpartaCanvas..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,16 @@ | ||
drawing | ||
drawBacksideOnSpartaCanvas: aCanvas | ||
| radius radiusOffset | | ||
|
||
radius := self cornerRadius. | ||
radiusOffset := radius/Float pi. | ||
|
||
aCanvas stroke | ||
paint: Color paleBlue; | ||
path: (aCanvas shape | ||
line: radiusOffset@radiusOffset | ||
to: (self width-radiusOffset)@(self height-radiusOffset)); | ||
line: 0@0 | ||
to: self extent); | ||
draw. | ||
|
||
aCanvas stroke | ||
paint: Color paleBlue; | ||
path: (aCanvas shape | ||
line: (self width-radiusOffset)@radiusOffset | ||
to: radiusOffset@(self height-radiusOffset)); | ||
draw | ||
|
||
"aCanvas stroke | ||
paint: Color paleBlue; | ||
path: ((BlLine new | ||
from: radiusOffset@radiusOffset; | ||
to: (self width-radiusOffset)@(self height-radiusOffset)) | ||
buildPathOnSpartaCanvas: aCanvas within: self boundsInLocal); | ||
draw. | ||
aCanvas stroke | ||
paint: Color paleBlue; | ||
path: ((BlLine new | ||
from: (self width-radiusOffset)@radiusOffset; | ||
to: radiusOffset@(self height-radiusOffset)) | ||
buildPathOnSpartaCanvas: aCanvas within: self boundsInLocal); | ||
draw." | ||
line: self width @ 0 | ||
to: 0@self height); | ||
draw |
32 changes: 14 additions & 18 deletions
32
src/Bloc-MemoryGame.package/MgRawCardElement.class/instance/drawOnSpartaCanvas..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,19 @@ | ||
drawing | ||
drawOnSpartaCanvas: aCanvas | ||
| radius | | ||
|
||
radius := self cornerRadius. | ||
| roundedRectangle | | ||
|
||
aCanvas fill | ||
paint: self backgroundColor; | ||
path: (aCanvas shape | ||
roundedRectangle := aCanvas shape | ||
roundedRectangle: self boundsInLocal | ||
radii: (BlCornerRadii radius: radius)); | ||
draw. | ||
radii: (BlCornerRadii radius: self cornerRadius). | ||
|
||
"aCanvas fill | ||
paint: Color lightGray; | ||
path: ((BlRectangle new | ||
cornerRadius: 12) | ||
buildPathOnSpartaCanvas: aCanvas within: self boundsInLocal); | ||
draw." | ||
|
||
self card isFlipped | ||
ifTrue: [ self drawFlippedSideOnSpartaCanvas: aCanvas ] | ||
ifFalse: [ self drawBacksideOnSpartaCanvas: aCanvas ] | ||
aCanvas clip | ||
by: roundedRectangle | ||
during: [ | ||
aCanvas fill | ||
paint: self backgroundPaint; | ||
path: self boundsInLocal; | ||
draw. | ||
|
||
self card isFlipped | ||
ifTrue: [ self drawFlippedSideOnSpartaCanvas: aCanvas ] | ||
ifFalse: [ self drawBacksideOnSpartaCanvas: aCanvas ] ] |