How to add a gif or an image to a Morph

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

How to add a gif or an image to a Morph

FrankBz
Hi, how can one insert an animated gif or any type of image to a Morph?

Thanks in advance
Reply | Threaded
Open this post in threaded view
|

Re: How to add a gif or an image to a Morph

Bert Freudenberg
On 15.03.2010, at 12:54, FrankBz wrote:
>
>
> Hi, how can one insert an animated gif or any type of image to a Morph?

Drag the picture file from the file system (Finder on Mac, Explorer on Windows, Nautilus in Gnome, etc.) into the Squeak window. Use the halo to embed into your morph.

- Bert -

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

Re: How to add a gif or an image to a Morph

FrankBz
It works fine, except that animated gifs are shown statically. Any idea on how to keep them animated?  
Reply | Threaded
Open this post in threaded view
|

Re: How to add a gif or an image to a Morph

Bert Freudenberg
On 15.03.2010, at 13:14, FrankBz wrote:
>
>
> It works fine, except that animated gifs are shown statically. Any idea on
> how to keep them animated?  

Hmm, seems to be bug that does not happen automatically.

But this works: open a File List, navigate to the GIF, click the first "open" button (the one with ballon help "open a GIF graphic file as a morph"). That one will create an AnimatedImage whereas the other "open" button creates just a not-animated Sketch.

- Bert -


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

Re: How to add a gif or an image to a Morph

FrankBz
it works perfectly. just curios, how can I refer to the added image from the browser?
Suppose I'm in the situation where I want to have a morph that includes the image by default (i.e. at each instantiation of that object I have a morph with that image as background), how can I do that?
The problem is that I'm writing a a morph that should change background image accordingly to user action..

Just to be more precise, I would like to have something that in Java would look as follow:
ImageIcon img = new ImageIcon("./myimagepath");
Then I need to use this image in my morph.
Sorry for the Java example, but it's the easiest thing I could think of to explain the concept.

Thanks in advance
Reply | Threaded
Open this post in threaded view
|

Re: How to add a gif or an image to a Morph

K. K. Subramaniam
On Thursday 18 March 2010 04:56:13 pm FrankBz wrote:
> The problem is that I'm writing a a morph that should change background
> image accordingly to user action..
What exactly are you trying to do? Create a button? Create a scenic animated
background? Do you need to scale/rotate your background image before display?

See ThreePhaseButtonMorph for a morph which changes its background depending
on mouse gestures.

PasteUpMorph has a  backgroundMorph that can be changed using backgroundForm:
or backgroundSketch:

You can embed your morph into a SketchMorph that displays your background form
after scale/rotation transforms.

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

Re: How to add a gif or an image to a Morph

Bert Freudenberg
On 18.03.2010, at 14:30, K. K. Subramaniam wrote:
>
> On Thursday 18 March 2010 04:56:13 pm FrankBz wrote:
>> The problem is that I'm writing a a morph that should change background
>> image accordingly to user action..
> What exactly are you trying to do? Create a button? Create a scenic animated
> background? Do you need to scale/rotate your background image before display?
>
> See ThreePhaseButtonMorph for a morph which changes its background depending
> on mouse gestures.

Right. Also see the class side of ThreePhaseButtonMorph to see how it gets its images, e.g. in #checkBox.

You can use the same mechanism. Once you imported the image, store the form in the ScriptingSystem's formDictionary. Just open an inspector on the image morph and call

        ScriptingSystem saveForm: aForm atKey: 'myImageName'.

Later you can retrieve that form by

        ScriptingSystem formAtKey: 'myImageName'.

It would be more usual to implement this "resources dictionary" in your own class. That is, just have a class variable with a dictionary to hold the forms. Or, if there are very few forms, simply have a class variable for each (like class Cursor does).

- Bert -

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

Re: How to add a gif or an image to a Morph

FrankBz
Hi, when I insert the image as background of the PasteUpMorph its position is centered, while I want it on the left upper corner.. how can I position sketchs used as background?

regards
Reply | Threaded
Open this post in threaded view
|

Re: How to add a gif or an image to a Morph

Jerome Peace


--- On Sat, 3/27/10, FrankBz <[hidden email]> wrote:

> From: FrankBz <[hidden email]>
> Subject: [Newbies] Re: How to add a gif or an image to a Morph
> To: [hidden email]
> Date: Saturday, March 27, 2010, 1:04 PM
>
> Hi, I tried with PasteUpMorph.. it worked fine, but I can't
> drag this kind of
> morph and I need to..
> how can I enable dragging property of a PasteUpMorph?
>
> regards
> --
Ha. I remember running into this one early on. The trick is you can embed a pastup morph in another morph say a rectangle. The rectangle is draggable.

Ah. Just checked. You can use the red menu from the halo.
Uncheck the "resists being picked up" box. Much simpler than my first try.

hth,

Yours in curiosity and service, --Jerome Peace


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

Re: How to add a gif or an image to a Morph

FrankBz
thanks jerome, it works perfectly.. now I'm trying to change the image accordingly to certain events..
when a just do again backgroundSketch: on my PasteUpMorph, it just remove the previous content without substituting it with the new image..
I have tried to call deleteBackgroundPainting before backgroundSketch: but nothing's changed.

so now the question is, how can I substitute the background image properly?
Reply | Threaded
Open this post in threaded view
|

Re: How to add a gif or an image to a Morph

Jerome Peace


--- On Sun, 3/28/10, FrankBz <[hidden email]> wrote:

> From: FrankBz <[hidden email]>
> Subject: [Newbies] Re: How to add a gif or an image to a Morph
> To: [hidden email]
> Date: Sunday, March 28, 2010, 8:03 AM
>
> thanks jerome, it works perfectly.. now I'm trying to
> change the image
> accordingly to certain events..
> when a just do again backgroundSketch: on my PasteUpMorph,
> it just remove
> the previous content without substituting it with the new
> image..
> I have tried to call deleteBackgroundPainting before
> backgroundSketch: but
> nothing's changed.
>
> so now the question is, how can I substitute the background
> image properly?
>
Ah. You've found a way I never tried. I did try to play with it. Looks like it is an invention of Scott Wallace.

What I do for background is use a btimap fill and then select a background.

To do this (for any morph)
red handle menu>fill style>bitmap fill.

Then again
red handle menu>fill style>(you are now presented with bitmap fill options)
select from:
grab new graphic -- this allows you to copy an area of the screen into the bitmap fill.
choose new graphic -- this allows you to choose from graphics that the system knows about. Your sketches graphic should be amoung them somewhere.

once you have choosen your graphic you may need to adjust it:
red handle menu>fill style>
change origin -- this allows you to move the background around until its located correctly in relation to your morph.

change direction -- This allows you to tilt and scale the background.

I suggest you play around with all the fill options. They are fairly interesting.

hth,

Yours in curiosity and service, --Jerome Peace





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