Greetings,
I have a ColorForm create from : (Form fromFileNamed: cards). It's an 840x504x8 png file of a deck of playing cards, i.e. showing all the cards. I want to create individual ColorForms, each representing one playing card from the 'master' colorform. So I guess I need to (in a loop) extract a rectangular area of pixels from the original ColorForm and then create a new colorform from those extracted pixels. I'm looking at the ColorForm, ImageMorph, Form .. and other superlcasses methods, but haven't figured out which combination of methods I need to use. Mike |
On Mon, Mar 2, 2009 at 12:48 PM, mstramba <[hidden email]> wrote:
eachCard := masterForm copy: (0@0 corner: 840@504). You'll need to replace 0@0 and 804@504 with the coordinates you need. Also, this is fun: (Display copy: (0@0 corner: 1024@768)) asMorph openInWindow It makes a partial screen-shot :-). Gulik. -- http://gulik.pbwiki.com/ _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
In reply to this post by mstram
On Mon, Mar 2, 2009 at 12:48 PM, mstramba <[hidden email]> wrote:
Oh, and generally you'd want to avoid pixel-by-pixel operations. They're very, very slow. Gulik. -- http://gulik.pbwiki.com/ _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
In reply to this post by Michael van der Gulik-2
Gulik,
Thanks ! That works great ! I was hoping there was a nice simple little method / incantation like that :) Next problem ... ;) ImageMorph doesn't seem to be resizable. I tried sending the width:, height: messages:, but they have no effect. I also tried adding the 'eachCard' as a submorph to a "table" morph : table : Morph new openInWorld table addMorph: eachCard .. then tried resizing the 'table' morph either interactively with the halos or by sending table width:. Is there a way to make the ImageMorph resizeable ? ... or by using some other type of morph ? Mike
|
On Mon, Mar 2, 2009 at 2:38 PM, mstramba <[hidden email]> wrote:
That's because an ImageMorph is based on a bit map, which is stuck pixel-for-pixel with whatever display you're using. You can do this: (myImageMorph addFlexShell scale: 5.2) openInWorld. However, this is voodoo to me, and I don't even want to know how or why it works. I don't particularly like the design of Morphic because there is too much voodoo in it. Gulik. -- http://gulik.pbwiki.com/ _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
In reply to this post by mstram
Hi mstramba, If you want a deck of playing cards from a master form consider using bitmap fill. It is fast and flexible and you do not need to deal with things on the bit level. Basicly: Drag and drop the picture on the image that gives you a sketch. The sketch's form will be your master image. Now make a card prototype. Usually a rectangle or a polygon will do. For a rectangle set its extent to the size of a particular card. protoCard := RectangleMorph new extent: cardWidth @ cardHeight. protoFill := BitmapFillStyle from: masterImage . protoCard fillStyle: protoFill . cardOrigins := OrderedCollection new . ( 0 to: masterForm width -1 by: cardWidth ) do: [ :eachCol | ( 0 to: masterForm height -1 by: cardHeight ) do: [ :eachRow | cardOrigins add: eachCol@eachRow ] . cards := cardOrigins collect: [ :each | protoCard copy fillStyle: (protoFill copy origin: each) ] . or alternately, cards := cardOrigins collect: [ :each | protoCard copy position: each ; fillStyle: protoFill copy ] . This code is unchecked. You may need to do some light debugging. Browse the classes involve to learn their methods. If you need separate forms you can always do cardForms := cards collect: [ :each | each imageForm ] . I don't know offhand if that will give you colorForms. If this doesn't work you you look at BitBlt and figure out how to copy rectangles from your master form. Good luck. hth, Yours in curiosity and service, --Jerome Peace --- On Sun, 3/1/09, mstramba <[hidden email]> wrote: > From: mstramba <[hidden email]> > Subject: [Newbies] how to create multiple colorforms from a master colorform > To: [hidden email] > Date: Sunday, March 1, 2009, 6:48 PM > Greetings, > > I have a ColorForm create from : (Form fromFileNamed: > cards). > > It's an 840x504x8 png file of a deck of playing cards, > i.e. showing all the > cards. > > I want to create individual ColorForms, each representing > one playing card > from the 'master' colorform. > > So I guess I need to (in a loop) extract a rectangular area > of pixels from > the original ColorForm and then create a new colorform from > those extracted > pixels. > > I'm looking at the ColorForm, ImageMorph, Form .. and > other superlcasses > methods, but haven't figured out which combination of > methods I need to use. > > Mike > -- _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
In reply to this post by mstram
Hi mstamba SketchMorphs can be resized. SketchMorph new form: cardForm . --- On Sun, 3/1/09, mstramba <[hidden email]> wrote: > From: mstramba <[hidden email]> > Subject: Re: [Newbies] how to create multiple colorforms from a master colorform > To: [hidden email] > Date: Sunday, March 1, 2009, 8:38 PM > Gulik, > > Thanks ! That works great ! > > I was hoping there was a nice simple little method / > incantation like that > :) > > Next problem ... ;) > > ImageMorph doesn't seem to be resizable. > > I tried sending the width:, height: messages:, but they > have no effect. > > I also tried adding the 'eachCard' as a submorph to > a "table" morph : > > table : Morph new openInWorld > table addMorph: eachCard > > .. then tried resizing the 'table' morph either > interactively with the > halos or by sending table width:. > > Is there a way to make the ImageMorph resizeable ? ... or > by using some > other type of morph ? > > Mike > > > Michael van der Gulik-2 wrote: > > > > > > eachCard := masterForm copy: (0@0 corner: 840@504). > > > > > > Gulik. > > > > -- > > http://gulik.pbwiki.com/ > > > > _______________________________________________ > > Beginners mailing list > > [hidden email] > > > http://lists.squeakfoundation.org/mailman/listinfo/beginners > > > > > > -- > View this message in context: > http://www.nabble.com/how-to-create-multiple-colorforms-from-a-master-colorform-tp22276928p22280664.html > Sent from the Squeak - Beginners mailing list archive at > Nabble.com. > > _______________________________________________ > Beginners mailing list > [hidden email] > http://lists.squeakfoundation.org/mailman/listinfo/beginners _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
In reply to this post by Michael van der Gulik-2
Thanks again ! ... that does the trick !
There seems to be some issues with redrawing the resized cards .. but I'll see if I can figure it out ;) Mike
|
Free forum by Nabble | Edit this page |