Page 1 of 1

Drawing help

Posted: Thu Oct 09, 2008 12:56 pm
by Matt9537
After reading a previous post I have learnt how the user can draw shapes in a picture field using the following code:

Code: Select all

on mouseUp
choose pencil tool 
set the pencolor to "black" 
end mouseUp
I have assigned the code to a button. However, once the button is clicked the cursor will always be a pencil tool and you cannot select another button on the stack.

I have also tried using the 'Mouseenter' and 'Mouseexit' on the image to change the tools from the pencil tool to a cursor...but no success.

So, how would I be able to get the user to draw an image and be able to use buttons (say to change the pen colour or something?)

Posted: Thu Oct 09, 2008 1:12 pm
by Klaus
Hi Matt,

the only soluton is to create a palette window with your "tools", just like in the Rev IDE.

Once you have set another "tool", no "mouse" events are being sent, that's why you got stuck with the pencil tool.


Best

Klaus

Posted: Thu Oct 09, 2008 1:40 pm
by bn
Hi Matt,

depending on what you want you probably have a image object to which you paint. You could set the script of the image object to

Code: Select all

on mouseLeave
    choose browse tool
end mouseLeave
That way you choose the pencil tool (or whatever) with your button, paint in the image, as soon as you move out of the image the cursor reverts to the browse tool.

This may or may not be what you want, give it a try.

cheers

bernd

Posted: Thu Oct 09, 2008 1:48 pm
by bn
Hi Matt,

as an aside: a button with

Code: Select all

on mouseUp 
    set the text of image "myImage" to ""
end mouseUp
erases the image. It took me a while to pick that up, so it might be handy
regards
bernd

Posted: Thu Oct 09, 2008 1:50 pm
by Klaus
Or simply (a little less semantically challenging) ;-)
...
put empty into img "your_image"
...

Posted: Thu Oct 09, 2008 2:50 pm
by Matt9537
Klaus wrote:Or simply (a little less semantically challenging) ;-)
...
put empty into img "your_image"
...
Thanks BN for the prompt help and thanks Klaus! Havent had a chance to try it yet - maybe tomorrow.

I was actually going to ask how you would delete an image....so thanks for that!

Posted: Thu Oct 09, 2008 7:24 pm
by bn
Hi Klaus,
Or simply (a little less semantically challenging)
...
put empty into img "your_image"
...
how easy, thank you,
somehow the "semantic challenges" seem to attract me :) isn't the "semantic challenge" what makes a 'real' programming language? :wink:
cheers
bernd

Posted: Fri Oct 10, 2008 9:45 am
by Matt9537
Hi Bn and Klaus (again)

The script works perfectly! However, after a good hour of trying, reading manuals and searching the forum...can anyone tell me how I could export the image drawn in the image area as a picture file? Such as a .jpg or a .bmp or something?

(on a mac BTW)

Posted: Fri Oct 10, 2008 9:58 am
by Klaus
Hi Matt,

you can export images and screenshots in PNG, GIF or JPG format.

Please check these terms in the docs:
export
export snapshot
jpegquality

As always, it's pretty easy :-)

Code: Select all

...
export img "my wonderful image" to file "path/to/file.jpg" as JPEG
...
Best

Klaus

Posted: Sun Jun 07, 2009 4:11 pm
by Dondi
Klaus wrote:Hi Matt,

the only soluton is to create a palette window with your "tools", just like in the Rev IDE. ...

Klaus
Hi Klaus, can you elaborate on implementation of the palette? I tried implementing this approach by placing the "canvas" on a card in the mainstack and the palette on a card on a substack.

However, the create graphics command places the selected tool on the palette card and I can't figure out how to specify that the graphic should be created on the "canvas" on the mainstack. Any ideas on how to remedy this?

Posted: Mon Jun 08, 2009 5:43 pm
by Klaus
Hi Dondi,

I was referring to PAINT tools which will only work sufficiently in a palette!

You can "set the defaultstack" first before creating graphics:
...
set the defaultstack to "stack where the graphic should appear"
create graphic "new_graphic1"
...

Is that what you wanted to know?


Best

Klaus

Posted: Fri Jun 12, 2009 11:15 pm
by Dondi
Thanks Klaus. I am using vector objects on an image object used as a canvas. I will try your defaultstack suggestion and see where it leads.