Page 1 of 1
Paint Into Existing Image
Posted: Wed Oct 12, 2011 2:45 pm
by WaltBrown
Hi! Relative to my last conversation here, I have a small scrolling group window over a very large existing image. Is there a way to use paint tools via script on that image? In my case, the image itself is a very large map (5k x 3k) on which I wish to place dots and lines using the brush tool, via script, not user action. Everything I have tried ends up creating a new image on top of the card and drawing into that instead.
This is what I have tried:
Code: Select all
select img "iMapView" of grp "grpMap"
drag from tXa, tYa to tXb, tYb
Effectively what I want is:
Code: Select all
drag from tXa, tYa to tXb, tYb on img "iMapView" of grp "grpMap"
while the image is still under the group window.
The only option I saw was to lockScreen, copy the image up to a new image object, draw on it, copy it back, then unlock screen. I am hoping I just missed something in the docs, but they all describe all painting in terms of actual or script simulated user interaction via mouse. The only other option I saw was doing it bit by bit on the imageData, which complexity I am hoping to avoid.
Thanks, Walt
Re: Paint Into Existing Image
Posted: Wed Oct 12, 2011 2:56 pm
by Klaus
Hi Walt,
no need to select the image you want to paint on, but you must select the right tool!

...
select pencil tool
## or any of the paint tools: brush, eraser, bucket etc...
drag from tXa, tYa to tXb, tYb
...
Check tool, brush, brushsize, pencil etc. in the dictionary.
Dont forget to "reset" the tool after you are done!
Hint: this will only work on imported (not referenced) images.
Best
Klaus
Re: Paint Into Existing Image
Posted: Wed Oct 12, 2011 3:28 pm
by WaltBrown
Nope. Here's the stack, it creates a blank map within the map group, then plots the selected number of dots. Click on New Map, then on Plot Cities, and it dots the entire stack, not just the image. The code is in the Plot Cities button. I have reduced the code in there to your suggestion. If the dots stay wthin the window on your machine, then it's something here.
Walt
Re: Paint Into Existing Image
Posted: Wed Oct 12, 2011 3:49 pm
by Klaus
Hi Walt,
yep
OK, you did not tell me that you were using an only partly visible image inside of a group.
And you are using absolute card coords instead of relative to the image you want to paint on!
When you start "painting" in an area where there is currently NO image object, LiveCode will create
a new and empty image object in the size of the current card as one can see in your stack.
Some quick thoughts:
Maybe you need to scroll the group accordingly and compute the correct offset for painting or use an extra
stack/card where the image fits 1:1, do the painting there and put it back intop your scrolling group after that.
Best
Klaus
Re: Paint Into Existing Image
Posted: Wed Oct 12, 2011 4:03 pm
by WaltBrown
Sorry, I guess I wasn't clear - that's what I meant by "I have a small scrolling group window over a very large existing image".
OK, one of my experiments was lockScreen, resize the stack to the full desired image size, let LC create a new image, plot into it, copy the new imageData back to the map, delete the temp image, resize the stack back to it's original size, then unlock the screen. I was hoping to let the drawing process be visible within the scrolling window though.
I see that drag is stack relative, not object relative. I guess then add to my original question - can I draw in an existing image object that is not the same size of the stack or not visible, the answer is no, I have to go through the steps in the paragraph above.
Thanks.
Re: Paint Into Existing Image
Posted: Wed Oct 12, 2011 6:56 pm
by WaltBrown
On this note, I just added feature requests 9805 (Separate view window from stack window to allow, say, bidirectional scrolling of a card/display surface independent of stack settings), 9806 (Allow painting/drawing directly into image objects independent of the stack window or screen), and 9807 (allow object oriented graphics, as in Powerpoint, so graphical elements can be dynamically added, changed, moved independent of the bitmap without resorting to the baggage of custom graphic buttons).