Help with pen stuff

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

Help with pen stuff

OrgmiGeek
In my spare time I decided to rite a simple paint program! I have encountered some problems:
#1 does paint stuff work in the BorderedMorph category?

#2 how would you make the program draw where your mouse pointer is? I think you do it like:
 myPen goto: 200@200. but more like: myPen goto: mouseX@mouseY

I hope you understand what I am trying to do.
Thanks so much in advance
---
Under the age of 15 so don't want to post my name
Reply | Threaded
Open this post in threaded view
|

Re: Help with pen stuff

K K Subbu
On Tuesday 05 Jun 2012 2:46:17 AM OrgmiGeek wrote:
> In my spare time I decided to rite a simple paint program!
Welcome to Squeak! Have you read the blog:

 http://billkerr2.blogspot.in/2007/09/morphic-etoys-is-superior-graphical.html

John Maloney's article in the reference listed therein is an excellent
starting point for graphical programming.

> I have
> encountered some problems:
> #1 does paint stuff work in the BorderedMorph category?
If you mean paint as in the PaintTool, then no. Painting is for sketches while
BorderedMorph is a patch of single color (or gradient of two colors) with a
border. You can change the color of a bordered morph with:

     myMorph color: Color blue.

> #2 how would you make the program draw where your mouse pointer is? I think
> you do it like:
>  myPen goto: 200@200. but more like: myPen goto: mouseX@mouseY
The 'mouse' is known as ActiveHand, so you would program it thusly:
     myPen goto: ActiveHand x @ ActiveHand y.

This can be tricky to program. If you don't have a stop condition, myPen will
keep following the mouse all the time and that can be really annoying :-(.

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

Re: Help with pen stuff

K K Subbu
In reply to this post by OrgmiGeek
On Tuesday 05 Jun 2012 2:46:17 AM OrgmiGeek wrote:
> In my spare time I decided to rite a simple paint program!
Welcome to Squeak! Have you read the blog:

 http://billkerr2.blogspot.in/2007/09/morphic-etoys-is-superior-graphical.html

John Maloney's article in the reference listed therein is an excellent
starting point for graphical programming.

> I have
> encountered some problems:
> #1 does paint stuff work in the BorderedMorph category?
If you mean paint as in the PaintTool, then no. Painting is for sketches while
BorderedMorph is a patch of single color (or gradient of two colors) with a
border. You can change the color of a bordered morph with:

     myMorph color: Color blue.

> #2 how would you make the program draw where your mouse pointer is? I think
> you do it like:
>  myPen goto: 200@200. but more like: myPen goto: mouseX@mouseY
The 'mouse' is known as ActiveHand, so you would program it thusly:
     myPen goto: ActiveHand x @ ActiveHand y.

This can be tricky to program. If you don't have a stop condition, myPen will
keep following the mouse all the time and that can be really annoying :-(.

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

Re: Help with pen stuff

Bert Freudenberg
In reply to this post by OrgmiGeek
On 05.06.2012, at 11:46, OrgmiGeek wrote:

> In my spare time I decided to rite a simple paint program! I have encountered
> some problems:
> #1 does paint stuff work in the BorderedMorph category?

With a Pen you paint on a Form (which is an picture object holding pixels). To display a Form in Morphic you can use an ImageMorph.

> #2 how would you make the program draw where your mouse pointer is? I think
> you do it like:
> myPen goto: 200@200. but more like: myPen goto: mouseX@mouseY

Your morph can receive mouse events. You need to implement the handlesMouseDown: method to return true.

This will send mouse event messages to your morph. It will receive a mouseDown: message when the mouse button is pressed, and a mouseMove: message when the mouse is moved subsequently, and finally a mouseUp: message.

The argument to these messages is a MouseEvent. It has a position, but that is in world coordinates. You need to subtract the morph's topLeft coordinate from the event's position.

It's really just a handful of lines, but see the attached example for a working version.

- Bert -


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

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

Re: Help with pen stuff

K K Subbu
In reply to this post by K K Subbu
On Tuesday 05 Jun 2012 4:04:21 PM david tennant wrote:
> > >The 'mouse' is known as ActiveHand, so you would program it thusly:
> > >      myPen goto: ActiveHand x @ ActiveHand y.
>
> thanks this is exactly what I want. and for my first question can I use
> this stuff when I make a class of bordered morph.
goTo: method is for pens. Use position: method for morphs:

     myMorph position: ActiveHand position.

John's article is about 38 pages and so fascinating that you may want to print
it and read it leisurely.

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

Re: Help with pen stuff

Bert Freudenberg
On 05.06.2012, at 14:47, K. K. Subramaniam wrote:

> On Tuesday 05 Jun 2012 4:04:21 PM david tennant wrote:
>>>> The 'mouse' is known as ActiveHand, so you would program it thusly:
>>>>     myPen goto: ActiveHand x @ ActiveHand y.
>>
>> thanks this is exactly what I want. and for my first question can I use
>> this stuff when I make a class of bordered morph.
> goTo: method is for pens. Use position: method for morphs:
>
>     myMorph position: ActiveHand position.


You really shouldn't teach beginners bad style ;)

If you're programming Morphic, use events. See my other message.

> John's article is about 38 pages and so fascinating that you may want to print
> it and read it leisurely.

That hint would be even more useful with a URL ...

- Bert -

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

Re: Help with pen stuff

OrgmiGeek
In reply to this post by Bert Freudenberg
>> In my spare time I decided to rite a simple paint program! I have encountered
>> some problems:
>> #1 does paint stuff work in the BorderedMorph category?

>With a Pen you paint on a Form (which is an picture object holding pixels). To display a Form in Morphic >you can use an ImageMorph.

>> #2 how would you make the program draw where your mouse pointer is? I think
>> you do it like:
>> myPen goto: 200@200. but more like: myPen goto: mouseX@mouseY

>Your morph can receive mouse events. You need to implement the handlesMouseDown: method to return >true.

>This will send mouse event messages to your morph. It will receive a mouseDown: message when the >mouse button is pressed, and a mouseMove: message when the mouse is moved subsequently, and >finally a mouseUp: message.

>The argument to these messages is a MouseEvent. It has a position, but that is in world coordinates. You >need to subtract the morph's topLeft coordinate from the event's position.
I will try this as soon as I have time!

>It's really just a handful of lines, but see the attached example for a working version.
I just opened it in a text editor :O that is not many lions at all!
>- Bert -

I just have one more question how do I actually file in some thing. my dad and I spent ages trying to find that out so we just exchanged Images  
thanks so much for your help!
---
Under the age of 15 so don't want to post my name
Reply | Threaded
Open this post in threaded view
|

Re: Help with pen stuff

Bert Freudenberg
On 05.06.2012, at 15:24, OrgmiGeek wrote:

>> It's really just a handful of lines, but see the attached example for a
>> working version.
>
> I just opened it in a text editor :O that is not many lions at all!

Nor other cats, really.

>> - Bert -
>
> I just have one more question how do I actually file in some thing. my dad
> and I spent ages trying to find that out so we just exchanged Images  
> thanks so much for your help!


Well, on my system, I just drag the email attachment into the Squeak window. Squeak will ask what to do with it, I choose "fileIn entire file".

Given that your email client even has trouble quoting correctly, you may have to save the attachment to a file first. If drag-and-drop of the file should not work, then open a File List tool in Squeak and navigate to the file.

To create the file out I right-clicked on the class and chose "file out".

A better way is using a ChangeSorter (google for "squeak changesorter").

The professional way for Squeak source code management is using Monticello, but you can learn that later.

- Bert -

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

Re: Help with pen stuff

OrgmiGeek


On Tue, Jun 5, 2012 at 5:38 PM, Bert Freudenberg <[hidden email]> wrote:
On 05.06.2012, at 15:24, OrgmiGeek wrote:

>> It's really just a handful of lines, but see the attached example for a
>> working version.
>
> I just opened it in a text editor :O that is not many lions at all!

Nor other cats, really.

>> - Bert -
>
> I just have one more question how do I actually file in some thing. my dad
> and I spent ages trying to find that out so we just exchanged Images
> thanks so much for your help!


Well, on my system, I just drag the email attachment into the Squeak window. Squeak will ask what to do with it, I choose "fileIn entire file".

Given that your email client even has trouble quoting correctly, you may have to save the attachment to a file first. If drag-and-drop of the file should not work, then open a File List tool in Squeak and navigate to the file.
WoW that was easy! thanks! it worked :D 

To create the file out I right-clicked on the class and chose "file out".

A better way is using a ChangeSorter (google for "squeak changesorter").

The professional way for Squeak source code management is using Monticello, but you can learn that later.

- Bert -

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



--
__________________________________________________________________________
Origamigeek


_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
---
Under the age of 15 so don't want to post my name