Drag and dropped jpg (playing cards) - how to put in the "new morph" menu and create a PlayingCard class?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Drag and dropped jpg (playing cards) - how to put in the "new morph" menu and create a PlayingCard class?

mstram
I'm runninng squeak 3.10.2 on windows XP.

If I drag and drop a jpg onto Squeak, it creates a SketchMorph.

Specficially, I'm adding a playing card image, well 52 of them, and
I'd like to be able to add a card from the world menu / new morph
menu.

I'd also like to create a PlayingCard class, that uses the dropped jpg.

At the moment I'm doing it the "hard way", after dropping the jpg, I'm
digging through system dictionary, digging out the world objects, and
"drilling down" to the dropped object.

Any tips, info appreciated.

Mike
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Drag and dropped jpg (playing cards) - how to put in the "new morph" menu and create a PlayingCard class?

Edgar J. De Cleene



On 10/25/09 4:29 AM, "Mike Stramba" <[hidden email]> wrote:

> I'm runninng squeak 3.10.2 on windows XP.
>
> If I drag and drop a jpg onto Squeak, it creates a SketchMorph.
>
> Specficially, I'm adding a playing card image, well 52 of them, and
> I'd like to be able to add a card from the world menu / new morph
> menu.
>
> I'd also like to create a PlayingCard class, that uses the dropped jpg.
>
> At the moment I'm doing it the "hard way", after dropping the jpg, I'm
> digging through system dictionary, digging out the world objects, and
> "drilling down" to the dropped object.
>
> Any tips, info appreciated.
>
> Mike

I guess you wish do some kind of game.
So , take a look to older Squeaks when you have card games.
Also in my FunSqueak3.10alpha.7 you have the old FreCel still working.

But asking you question, if you have a directory with your .jpg could create
the morphs with this I copy from my old games.
If Spanish comments is difficult, send new mail and I try to help more.

Edgar


_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners

MisDibujos.st (2K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Drag and dropped jpg (playing cards) - how to put in the "new morph" menu and create a PlayingCard class?

Herbert König
In reply to this post by mstram
Hi Mike,

never done something like that but let me drop some thoughts you might
find useful.

MS> If I drag and drop a jpg onto Squeak, it creates a SketchMorph.

SketchMorph has a fromFile: method on the class side.

For versioning graphics some people put images into methods, so the
method returns the image (which is stored in an Array literal).

PlayingCard class side imageData returns a String literal with all the
parts of card images and class side's initialize assembles these into
the cards.

MS> Specficially, I'm adding a playing card image, well 52 of them, and
MS> I'd like to be able to add a card from the world menu / new morph
MS> menu.

I assume you don't mean new morph / from file but new morph / from
alphabetical list. This is done for you by magic. Each Morph subclass
(all down the hierarchy from there) is added to that menu. Don't know
how it's done.

World Menu, "Objects" "Games" has a FreeCell card game (as of Squeak
3.8.2 which I use) there you might get some ideas from.

MS> I'd also like to create a PlayingCard class, that uses the dropped jpg.

In a 3.8 (and older) image this class already exists. But as it is an
Object subclass it's not in the menu. But it's been dropped in 3.10.

Sorry I can't access squeak.org right now but
http://www.squeak.org/Download/ should have it.

This brings me to the thought, that you might want to have a class
which collects the the playing behaviour and has an ivar "display"
which points to a Morph subclassed object which collects the visual
behaviour.

Thanks to Smalltalk you can always do that later.

MS> At the moment I'm doing it the "hard way", after dropping the jpg, I'm
MS> digging through system dictionary, digging out the world objects, and
MS> "drilling down" to the dropped object.

 "drilling down" sounds complicated, so:
 
World submorphs select: [:each | each class == SketchMorph]



Cheers,

Herbert  

_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Drag and dropped jpg (playing cards) - how to put in the "new morph" menu and create a PlayingCard class?

Tobias Pape-2
In reply to this post by mstram
Hello —,
Am 2009-10-25 um 07:29 schrieb Mike Stramba:

> I'm runninng squeak 3.10.2 on windows XP.
>
> If I drag and drop a jpg onto Squeak, it creates a SketchMorph.

That ought to be right.

>
> Specficially, I'm adding a playing card image, well 52 of them, and
> I'd like to be able to add a card from the world menu / new morph
> menu.
>
> I'd also like to create a PlayingCard class, that uses the dropped  
> jpg.

Do you really want to create the card from _dropped_ images?
Or do you rather just want to create/reuse images (i.e., not necessarily
dropped ones)?
>
> At the moment I'm doing it the "hard way", after dropping the jpg, I'm
> digging through system dictionary, digging out the world objects, and
> "drilling down" to the dropped object.

I would use the Halo of that image to reach the actual image.
But if I do want to use Images regularly, I actualy store their Forms.
(see wiki.squeak.org/squeak/697 and your image)
To not every time create new forms, I create them once and then store  
them.
Actually, I convert an image to its base64 form, sotr this string  
inside the image
and have its Form created on Demand and then cached.

Hope that helps.

Have a nice Sunday,
        -Tobias


_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners

PGP.sig (201 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Drag and dropped jpg (playing cards) - how to put in the "new morph" menu and create a PlayingCard class?

Jerome Peace
In reply to this post by mstram
Hi Mike,

When you drop an image in not only creates a Sketch with the image it also adds the image form to the internal dictionary of forms.

Try this.
Get a Rectangle.
>From the halo menu select>fill style>bitmap fill.
 (You get the default picture)
Get the halo menu again. (needs to be a new menu)
 Select>fill style>choose new graphic.
  (you will get a selection of the internal dictionary's forms to choose from. Press prev and/or next until you see a thumbnail of your card. Press ok.)
 From the fill style menu select>change origin.
  (you get a handle that translates the form. Usually you will just want the topLeft corner of the form to be in the topLeft corner of the rectangle.)
 Once the alignment is done use the yellow halo to resize the rectangle.

If you have a jpg of the sheet of all cards, you only need to load the one picture, then use the origin changing trick to clip to the right one.
Use one Morph for assembly, then copy it each time you have a new card image.

Once I have a bitmap fill I usually copy the "change origin" and "choose new graphic" menu items so I don't have to constantly go back to the halo menu.

This trick will work with any fillable morph. So you could make a card class and then fill them with you deck.

You might also want to find the squeak Freecell application. It probably has a good lot of the stuff you are trying to do. It also comes with its own deck of cards. Older squeak images had this application in the "full" image. Or it might be in the game application. I'm not sure where currently.

Hth,

Yours in curiosity and service, --Jerome Peace



--- On Sun, 10/25/09, Mike Stramba <[hidden email]> wrote:

> From: Mike Stramba <[hidden email]>
> Subject: [Newbies] Drag and dropped jpg (playing cards) - how to put in the "new morph" menu and create a PlayingCard class?
> To: "A friendly place to get answers to even the most basic questions about Squeak." <[hidden email]>
> Date: Sunday, October 25, 2009, 2:29 AM
> I'm runninng squeak 3.10.2 on windows
> XP.
>
> If I drag and drop a jpg onto Squeak, it creates a
> SketchMorph.
>
> Specficially, I'm adding a playing card image, well 52 of
> them, and
> I'd like to be able to add a card from the world menu / new
> morph
> menu.
>
> I'd also like to create a PlayingCard class, that uses the
> dropped jpg.
>
> At the moment I'm doing it the "hard way", after dropping
> the jpg, I'm
> digging through system dictionary, digging out the world
> objects, and
> "drilling down" to the dropped object.
>
> Any tips, info appreciated.
>
> Mike
> _______________________________________________
> Beginners mailing list
> [hidden email]
> http://lists.squeakfoundation.org/mailman/listinfo/beginners
>


     
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Drag and dropped jpg (playing cards) - how to put in the "new morph" menu and create a PlayingCard class?

John McKeon
In reply to this post by mstram
Hi Mike,
Why not use code to bring in the images. SketchMorph fromFile: aFilename could be useful in a Workspace.

HTH
John


On Sun, Oct 25, 2009 at 2:29 AM, Mike Stramba <[hidden email]> wrote:
I'm runninng squeak 3.10.2 on windows XP.

If I drag and drop a jpg onto Squeak, it creates a SketchMorph.

Specficially, I'm adding a playing card image, well 52 of them, and
I'd like to be able to add a card from the world menu / new morph
menu.

I'd also like to create a PlayingCard class, that uses the dropped jpg.

At the moment I'm doing it the "hard way", after dropping the jpg, I'm
digging through system dictionary, digging out the world objects, and
"drilling down" to the dropped object.

Any tips, info appreciated.

Mike
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners



--
http://jmck.seasidehosting.st

_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Drag and dropped jpg (playing cards) - how to put in the "new morph" menu and create a PlayingCard class?

mstram
Hi John,

Thx, I didn't know about 'fromFile' (like 99% of the rest of the stuff I don't know about Squeak :) )

<quote author="John McKeon-2">
Hi Mike,
Why not use code to bring in the images. SketchMorph fromFile: aFilename
could be useful in a Workspace.

HTH
John


On Sun, Oct 25, 2009 at 2:29 AM, Mike Stramba <mikestramba@gmail.com> wrote:

> I'm runninng squeak 3.10.2 on windows XP.
>
> If I drag and drop a jpg onto Squeak, it creates a SketchMo
Reply | Threaded
Open this post in threaded view
|

Re: Drag and dropped jpg (playing cards) - how to put in the "new morph" menu and create a PlayingCard class?

mstram
In reply to this post by Jerome Peace
Hi Jerome,

Very cool, 'fill style', yatIdKAS ;)

Mike
Jerome Peace wrote
Hi Mike,

When you drop an image in not only creates a Sketch with the image it also adds the image form to the internal dictionary of forms.

Try this.
Get a Rectangle.
>From the halo menu select>fill style>bitmap fill.
 (You get the default picture)
Get the halo menu again. (needs to be a new menu)
 Select>fill style>choose new graphic.
  (you will get a selection of the internal dictionary's forms to choose from. Press prev and/or next until you see a thumbnail of your card. Press ok.)
 From the fill style menu select>change origin.
  (you get a handle that translates the form. Usually you will just want the topLeft corner of the form to be in the topLeft corner of the rectangle.)
 Once the alignment is done use the yellow halo to resize the rectangle.

If you have a jpg of the sheet of all cards, you only need to load the one picture, then use the origin changing trick to clip to the right one.
Use one Morph for assembly, then copy it each time you have a new card image.

Once I have a bitmap fill I usually copy the "change origin" and "choose new graphic" menu items so I don't have to constantly go back to the halo menu.

This trick will work with any fillable morph. So you could make a card class and then fill them with you deck.

You might also want to find the squeak Freecell application. It probably has a good lot of the stuff you are trying to do. It also comes with its own deck of cards. Older squeak images had this application in the "full" image. Or it might be in the game application. I'm not sure where currently.

Hth,

Yours in curiosity and service, --Jerome Peace



--- On Sun, 10/25/09, Mike Stramba <mikestramba@gmail.com> wrote:

> From: Mike Stramba <mikestramba@gmail.com>
> Subject: [Newbies] Drag and dropped jpg (playing cards) - how to put in the "new morph" menu and create a PlayingCard class?
> To: "A friendly place to get answers to even the most basic questions about Squeak." <beginners@lists.squeakfoundation.org>
> Date: Sunday, October 25, 2009, 2:29 AM
> I'm runninng squeak 3.10.2 on windows
> XP.
>
> If I drag and drop a jpg onto Squeak, it creates a
> SketchMorph.
>
> Specficially, I'm adding a playing card image, well 52 of
> them, and
> I'd like to be able to add a card from the world menu / new
> morph
> menu.
>
> I'd also like to create a PlayingCard class, that uses the
> dropped jpg.
>
> At the moment I'm doing it the "hard way", after dropping
> the jpg, I'm
> digging through system dictionary, digging out the world
> objects, and
> "drilling down" to the dropped object.
>
> Any tips, info appreciated.
>
> Mike
> _______________________________________________
> Beginners mailing list
> Beginners@lists.squeakfoundation.org
> http://lists.squeakfoundation.org/mailman/listinfo/beginners
>


     
_______________________________________________
Beginners mailing list
Beginners@lists.squeakfoundation.org
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Drag and dropped jpg (playing cards) - how to put in the "new morph" menu and create a PlayingCard class?

mstram
In reply to this post by Edgar J. De Cleene
Hi Edgar,

Thx, I found Freecell SqueakPoker (the start of a poker game) on squeaksource, both will be helpful, as will all the rest of tips in this thread.

Edgar J. De Cleene wrote
Also in my FunSqueak3.10alpha.7 you have the old FreCel still working.

MisDibujos elegirImagen!


"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!

MisDibujos class
        instanceVariableNames: 'current'!

!MisDibujos class methodsFor: 'as yet unclassified' stamp: 'edc 1/19/2006 11:30'!
current
^current! !

!MisDibujos class methodsFor: 'as yet unclassified' stamp: 'edc 1/19/2006 11:31'!
current: anObject
current := anObject! !

!MisDibujos class methodsFor: 'as yet unclassified' stamp: 'edc 1/24/2006 10:06'!
elegirImagen
        "could translate to chooseImage ,Lets the user choose folder with pictures  .
        Hay que hacer MisDibujos elegirImagen"
        | oldFolder newFolder listaArchivos misFotos |
        misFotos := self new.
        oldFolder := FileDirectory default.
        newFolder := FileList2 modalFolderSelector.
        FileDirectory setDefaultDirectory: newFolder pathName.
       
        listaArchivos := FileDirectory default fileNamesMatching: '*.jpg'.
        misFotos at: #Yellow put: (Form fromFileNamed: 'Yellow.gif').
        1
                to: 5
                do: [:i |
                       

misFotos at:  i  put:(  RWBinaryOrTextStream with: (StandardFileStream readOnlyFileNamed: (listaArchivos at: i))contents) .

                        ].
        FileDirectory setDefaultDirectory: oldFolder pathName.
       
        self current: misFotos
       
! !
_______________________________________________
Beginners mailing list
Beginners@lists.squeakfoundation.org
http://lists.squeakfoundation.org/mailman/listinfo/beginners