[Cuis-dev] Encoding a Form in a method
ken.dickey at whidbey.com
ken.dickey at whidbey.com
Fri Aug 2 11:25:08 PDT 2024
On 2024-08-02 07:27, Hilaire Fernandes via Cuis-dev wrote:
> Hi folks,
>
> What is the best practice to encode a Form within a method in a
> package file .pck.st ?
Not sure it fits your use case, but this is what I did for playing card
images in 'Morphic-Games-Solitaire'.
FYI,
-KenD
-------------- next part --------------
'From Cuis7.1 [latest update: #6541] on 2 August 2024 at 11:21:56 am'!
!CardMorph class methodsFor: 'class initialization' stamp: 'KenD 1/27/2011 00:51'!
initializeFromPNG
| imageDirNamePrefix |
ColorNames := #(Red Black).
FaceNames := #(Ace Two Three Four Five Six Seven Eight Nine Ten Jack Queen King).
SuitNames := #(Clubs Diamonds Hearts Spades).
FormsArray := Array new: 53.
imageDirNamePrefix := 'PNG-deck/'.
1 to: 13 do: [ :faceNum |
#( $c $d $h $s) do: [ :char |
FormsArray
at: ((faceNum - 1) * 4) + (#($c $d $h $s) indexOf: char)
put: ((Form fromFileNamed:
(imageDirNamePrefix, faceNum asString, char asString, '.png')) asFormOfDepth: 32)]].
FormsArray
at: 53
put: ((Form fromFileNamed: (imageDirNamePrefix , 'back.png')) asFormOfDepth: 32)! !
More information about the Cuis-dev
mailing list