How to save a graphic on a card using paint tools

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Martin-HC
Posts: 16
Joined: Fri Jan 31, 2025 5:27 pm

How to save a graphic on a card using paint tools

Post by Martin-HC » Tue Oct 28, 2025 2:55 pm

Hi,
I've a script that draws a graphic (like a column chart) using the draw command. Before I start drawing I've set linesize and pencolor. The graphic draws smoothly and everything works as expected. However, when I go to another card the graphic is lost. It's also lost when I save the stack.
What am I missing here?
Martin

Klaus
Posts: 14255
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: How to save a graphic on a card using paint tools

Post by Klaus » Tue Oct 28, 2025 3:45 pm

Hi Martin,

never heard of this problem!?
Sure there is no "pre-/opencard" handler that will "clean up" the card?


Best

Klaus

Martin-HC
Posts: 16
Joined: Fri Jan 31, 2025 5:27 pm

Re: How to save a graphic on a card using paint tools

Post by Martin-HC » Tue Oct 28, 2025 3:54 pm

There's no openCard handler or any other handler that 'cleans up' the card. (If I want to draw a new graphic I use a button that cuts the rectangle of the graphic.)

Klaus
Posts: 14255
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: How to save a graphic on a card using paint tools

Post by Klaus » Tue Oct 28, 2025 4:00 pm

OK, OK, just wanted to be sure. 8)
But what do you mean by:
(If I want to draw a new graphic I use a button that cuts the rectangle of the graphic.)
Maybe you could post the script and/or stack here?

Martin-HC
Posts: 16
Joined: Fri Jan 31, 2025 5:27 pm

Re: How to save a graphic on a card using paint tools

Post by Martin-HC » Tue Oct 28, 2025 4:11 pm

Klaus wrote:
Tue Oct 28, 2025 4:00 pm
OK, OK, just wanted to be sure. 8)
But what do you mean by:
(If I want to draw a new graphic I use a button that cuts the rectangle of the graphic.)
Maybe you could post the script and/or stack here?
To delete the previously drawn graphic I use this script:
choose select tool
drag from 0,0 to 560,744
cut
choose browse tool

Klaus
Posts: 14255
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: How to save a graphic on a card using paint tools

Post by Klaus » Tue Oct 28, 2025 4:44 pm

Sorry, I meant the script to create the graphic(s).

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7403
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: How to save a graphic on a card using paint tools

Post by jacque » Tue Oct 28, 2025 6:58 pm

Check both the card and stack properties to see if the cantModify property is true. The symptoms sound like that's the case.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Klaus
Posts: 14255
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: How to save a graphic on a card using paint tools

Post by Klaus » Tue Oct 28, 2025 7:03 pm

Yes, but in that case you cannot even draw anything on a card at all!

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4190
Joined: Sun Jan 07, 2007 9:12 pm

Re: How to save a graphic on a card using paint tools

Post by bn » Tue Oct 28, 2025 7:13 pm

Martin,

I think you run afoul of an LC bug that if you use the paint tools and you do not explicitly create an image object where you "paint" then LC creates an image object for you but the problem is that that image is not "stable".

Could you try to create an image object of the size and location you want first and then do your drawing-

This is just a hunch but worth trying.
A bit of code would help to track this down.

Kind regards
Bernd

EDIT:

the bug report is here:
https://quality.livecode.com/show_bug.cgi?id=24034
It was fixed in 10.0.2 RC-1

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7403
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: How to save a graphic on a card using paint tools

Post by jacque » Tue Oct 28, 2025 8:20 pm

Klaus wrote:
Tue Oct 28, 2025 7:03 pm
Yes, but in that case you cannot even draw anything on a card at all!
I think you can, you can do almost anything but leaving the card removes all changes. Maybe something changed?
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10392
Joined: Wed May 06, 2009 2:28 pm

Re: How to save a graphic on a card using paint tools

Post by dunbarx » Tue Oct 28, 2025 8:34 pm

Bernd.

I never use paint tools, though I remember back in 1987 I doodled a lot with HC.

In a new stack I made a small "drawing" using each of the seven standard paint tools in the toolbar, rectangle, line, brush, etc.

I saved the stack and re-opened. All the doodles except for the line and polygon disappeared. I tried it again, and only the line came back. And after a third time, everything disappeared.

I think there is something wrong here.

Craig

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10392
Joined: Wed May 06, 2009 2:28 pm

Re: How to save a graphic on a card using paint tools

Post by dunbarx » Tue Oct 28, 2025 8:36 pm

Bernd.
Could you try to create an image object of the size and location you want first and then do your drawing-
Why would that be of any use, even if it worked? The whole point of paint tools, awkward as they are, is lost if you have to prep them with an image. In that case, what do you need to paint for?

Craig

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10392
Joined: Wed May 06, 2009 2:28 pm

Re: How to save a graphic on a card using paint tools

Post by dunbarx » Tue Oct 28, 2025 8:45 pm

Bernd.

Well, I see what you meant. If you import an image, and I guess that could be 100% whiteSpace that fills the card window, then any painting you do within the rect of that image sticks. Note that you can only paint within the image rect because the tools fail to paint at all outside it. They will actually stop painting if the cursor leaves the image, and start up again when you return.

Craig

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4190
Joined: Sun Jan 07, 2007 9:12 pm

Re: How to save a graphic on a card using paint tools

Post by bn » Tue Oct 28, 2025 8:49 pm

dunbarx wrote:
Tue Oct 28, 2025 8:36 pm
Bernd.
Could you try to create an image object of the size and location you want first and then do your drawing-
Why would that be of any use, even if it worked? The whole point of paint tools, awkward as they are, is lost if you have to prep them with an image. In that case, what do you need to paint for?
Craig,

An image is created on the fly if you "just" paint. And the "automatic" image has the size of the card. Actually you probably want your image to have a certain smaller dimension. On top of this it was broken up until LC 10.0.2 RC-1.
I think the cleanest solution would be to create an image object of the desired dimension and paint into that image object.

Kind regards
Bernd

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10392
Joined: Wed May 06, 2009 2:28 pm

Re: How to save a graphic on a card using paint tools

Post by dunbarx » Tue Oct 28, 2025 9:56 pm

Bernd.

I do not understand. If I paint a line on a new card, it is true that the rect of the "image" of that line fills the card window. Save that stack. It is lost if I close and reopen. An imported image, however, allows the paint to survive if that paint lies within the rect of that image.

What am I missing? :(

craig

Post Reply