mstramba | 2 Mar 2009 00:48
Picon

how to create multiple colorforms from a master colorform


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
--

-- 
View this message in context: http://www.nabble.com/how-to-create-multiple-colorforms-from-a-master-colorform-tp22276928p22276928.html
Sent from the Squeak - Beginners mailing list archive at Nabble.com.
Michael van der Gulik | 2 Mar 2009 01:38
Picon

Re: how to create multiple colorforms from a master colorform



On Mon, Mar 2, 2009 at 12:48 PM, mstramba <mikestramba <at> gmail.com> wrote:

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.


eachCard := masterForm copy: (0 <at> 0 corner: 840 <at> 504).

You'll need to replace 0 <at> 0 and 804 <at> 504 with the coordinates you need.

Also, this is fun:

(Display copy: (0 <at> 0 corner: 1024 <at> 768)) asMorph openInWindow

It makes a partial screen-shot :-).

Gulik.

--
http://gulik.pbwiki.com/
_______________________________________________
Beginners mailing list
Beginners <at> lists.squeakfoundation.org
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Michael van der Gulik | 2 Mar 2009 01:39
Picon

Re: how to create multiple colorforms from a master colorform



On Mon, Mar 2, 2009 at 12:48 PM, mstramba <mikestramba <at> gmail.com> wrote:


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.


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
Beginners <at> lists.squeakfoundation.org
http://lists.squeakfoundation.org/mailman/listinfo/beginners
mstramba | 2 Mar 2009 02:38
Picon

Re: how to create multiple colorforms from a master colorform


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 <at> 0 corner: 840 <at> 504).
> 
> 
> Gulik.
> 
> -- 
> http://gulik.pbwiki.com/
> 
> _______________________________________________
> Beginners mailing list
> Beginners <at> lists.squeakfoundation.org
> 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.
Michael van der Gulik | 2 Mar 2009 02:58
Picon

Re: how to create multiple colorforms from a master colorform



On Mon, Mar 2, 2009 at 2:38 PM, mstramba <mikestramba <at> gmail.com> wrote:

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.


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
Beginners <at> lists.squeakfoundation.org
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Jerome Peace | 2 Mar 2009 06:21
Picon
Favicon

Re: how to create multiple colorforms from a master colorform


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  <at>  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 <at> 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 <mikestramba <at> gmail.com> wrote:

> From: mstramba <mikestramba <at> gmail.com>
> Subject: [Newbies] how to create multiple colorforms from a master colorform
> To: beginners <at> lists.squeakfoundation.org
> 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
> -- 
Jerome Peace | 2 Mar 2009 06:39
Picon
Favicon

Re: how to create multiple colorforms from a master colorform


Hi mstamba

SketchMorphs can be resized.

SketchMorph new form: cardForm .

--- On Sun, 3/1/09, mstramba <mikestramba <at> gmail.com> wrote:

> From: mstramba <mikestramba <at> gmail.com>
> Subject: Re: [Newbies] how to create multiple colorforms from a master colorform
> To: beginners <at> lists.squeakfoundation.org
> 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 <at> 0 corner: 840 <at> 504).
> > 
> > 
> > Gulik.
> > 
> > -- 
> > http://gulik.pbwiki.com/
> > 
> > _______________________________________________
> > Beginners mailing list
> > Beginners <at> lists.squeakfoundation.org
> >
> 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
> Beginners <at> lists.squeakfoundation.org
> http://lists.squeakfoundation.org/mailman/listinfo/beginners
mstramba | 2 Mar 2009 06:46
Picon

Re: how to create multiple colorforms from a master colorform


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

Michael van der Gulik-2 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.
> 
> -- 
> http://gulik.pbwiki.com/
> 
> _______________________________________________
> Beginners mailing list
> Beginners <at> lists.squeakfoundation.org
> 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-tp22276928p22282422.html
Sent from the Squeak - Beginners mailing list archive at Nabble.com.
Steinar Bang | 2 Mar 2009 23:09
Picon
Picon
Favicon

Unable to create pong game setup script in Etoys 3.0

Hi,

I'm trying to follow the tutorial here:
	http://billkerr2.blogspot.com/2007/11/making-pong-in-etoys.html

Creating the move script went fine, but I have problems creating the
setup script.

What I did to create the move script, was click on the eye, and got up a
window, where I set the name of the ball object to ball.  Then I dragged
an empty script on the Etoys window and dropped it.

Then I selected the category "motion" in the lower half of the ball
window, and dragged and dropped "ball forward by" and "ball bounce" on
the new script, which I've named move.

I then dragged the empty script and dropped it on the background to
create a new script.  But here I've been unsuccessful in dragging
"ball's heading" from the "motion" category.

That's is: I've been successful in dragging it, but not dropping it and
having it connect to the script.  I've tried hovering over the script,
I've tried touching it all edges of the script.  I've looked at menu
entries. 

But no luck yet.

Does anyone know what I'm doing wrong?

Thanx!

- Steinar
Bert Freudenberg | 2 Mar 2009 23:21
Picon
Gravatar

Re: Unable to create pong game setup script in Etoys 3.0

On 02.03.2009, at 23:09, Steinar Bang wrote:

> Hi,
>
> I'm trying to follow the tutorial here:
> 	http://billkerr2.blogspot.com/2007/11/making-pong-in-etoys.html
>
> Creating the move script went fine, but I have problems creating the
> setup script.
>
> What I did to create the move script, was click on the eye, and got  
> up a
> window, where I set the name of the ball object to ball.  Then I  
> dragged
> an empty script on the Etoys window and dropped it.
>
> Then I selected the category "motion" in the lower half of the ball
> window, and dragged and dropped "ball forward by" and "ball bounce" on
> the new script, which I've named move.
>
> I then dragged the empty script and dropped it on the background to
> create a new script.  But here I've been unsuccessful in dragging
> "ball's heading" from the "motion" category.
>
> That's is: I've been successful in dragging it, but not dropping it  
> and
> having it connect to the script.  I've tried hovering over the script,
> I've tried touching it all edges of the script.  I've looked at menu
> entries.
>
> But no luck yet.
>
> Does anyone know what I'm doing wrong?

Make sure you grab the "assignment" arrow, not the name of the tile.

The viewer lets you get two kinds of tiles for properties such as  
heading: one to access the heading, and one to set it. If you hover  
the mouse pointer to the left and right across the tile, different  
parts are highlighted. This indicates which tile you will get.

- Bert -

Gmane