Skip to content

Commit

Permalink
renamed #backgroundColor => #backgroundPaint
Browse files Browse the repository at this point in the history
  • Loading branch information
syrel committed Sep 7, 2017
1 parent 5a592ed commit 25782ac
Show file tree
Hide file tree
Showing 18 changed files with 65 additions and 56 deletions.

This file was deleted.

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
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
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
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
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ onDisappear
target: self;
opacity: 0;
duration: 400.

scalingAnimation := BlScaleAnimation new
target: self;
easing: BlEasing linear;
Expand Down
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 ]
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==
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"commentStamp" : "",
"commentStamp" : "AliakseiSyrel 9/7/2017 12:01",
"super" : "Announcement",
"category" : "Bloc-MemoryGame-Events",
"classinstvars" : [ ],
Expand Down
6 changes: 6 additions & 0 deletions src/Bloc-MemoryGame.package/MgCardElement.class/README.md
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

This file was deleted.

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
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"commentStamp" : "",
"commentStamp" : "AliakseiSyrel 9/7/2017 12:01",
"super" : "BlElement",
"category" : "Bloc-MemoryGame-Elements",
"classinstvars" : [ ],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Is sent by ==MgCardModel== after the card is flipped
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"commentStamp" : "",
"commentStamp" : "AliakseiSyrel 9/7/2017 12:01",
"super" : "Announcement",
"category" : "Bloc-MemoryGame-Events",
"classinstvars" : [ ],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ initialize
super initialize.

self geometry: (BlRectangle cornerRadius: self cornerRadius).
self background: self backgroundColor.
self background: self backgroundPaint.
self layout: BlFrameLayout new.

face := BlTextElement new.
Expand Down
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
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 ] ]

0 comments on commit 25782ac

Please sign in to comment.