Drawing on a Grouped Image Object

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
bushi
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 2
Joined: Sat Mar 30, 2013 12:03 am

Drawing on a Grouped Image Object

Post by bushi » Sat Mar 30, 2013 12:35 am

I'm developing a stack to calculate distances of foothill trails in satellite images. I'm using it to find the actual distances between geocaches in the undeveloped areas near where I live. I'm using a satellite image in a group so that I can have horizontal and vertical scrollbars since some of the images are quite large. I have the basics of the stack working fine except for one issue.

I have the satellite image in an image object and over that I'm placing another image object. This is so that I can draw line segments along the trails in the the sat image. The stack accumulates the lengths of the line segments and applies a scale factor base on the scale of the satellite image to derive a distance for the line segment.

With the sat image grouped, I can't find a way to access the image layer to draw the line segments. If I place an image object over the grouped sat image, I can draw the lines fine but if I scroll the sat image, the image that contains the line segments is no longer registered correctly. It doesn't move with the sat image. I can have the sat image and the line segment image in the group and they will move together properly when scrolled but I can't get at the line segment layer to draw the lines. Is there a way to draw lines (I'm using drag) on an image layer that's in a group?

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

Re: Drawing on a Grouped Image Object

Post by dunbarx » Sat Mar 30, 2013 12:58 am

Hi.

Can't you simply group the drawing image which overlies the map image? You know you can group a single object, correct? And so just set the scroll of one group to the scroll of the other, perhaps with the scrollDrag message. If the rects of the two groups are the same, they should scroll in sync. You would add the lines you draw to the drawing image group after they are completed.

Or do I misunderstand completely?

Craig Newman

bushi
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 2
Joined: Sat Mar 30, 2013 12:03 am

Re: Drawing on a Grouped Image Object

Post by bushi » Sat Mar 30, 2013 5:01 am

I've pared this down to what appears to be main problem and included code to illustrate. I initially created an image object then grouped it to include the scrollbars then sized the group smaller so the scrollbars would work. The code is set up as a button script. Here's the code:

Code: Select all

on mouseUp
   lock screen
   if exists(image "image1" of group "mapGroup") then 
      delete image "image1" of group "mapGroup"
   end if
   
   set the rect of the templateImage to 0,0,400,400
   create image "image1" in group "mapGroup"
   choose brush tool
   set the brush to 32
   set the brushColor to red
   set the dragSpeed to 0
   drag from 50,50 to 200,200
   choose browse tool
   unlock screen
end mouseUp
On executing the button script, instead of having a line drawn on "image1" a new image the size of the card and separate from the group is created. The line is drawn on the card-sized image. The docs state that a new image is created if you try to use the brush tool on a card that doesn't have an image object so it amounts to how to tell the brush that "image1" is the target image for drawing the line.

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Drawing on a Grouped Image Object

Post by Simon » Sat Mar 30, 2013 6:22 am

Not sure if I understand everything but try this:

Code: Select all

on mouseUp
   lock screen
   if exists(image "image1" of group "mapGroup") then 
      delete image "image1" of group "mapGroup"
   end if
   start editing group "mapGroup" --Add
   set the rect of the templateImage to 0,0,400,400
   create image "image1" --in group "mapGroup" removed this
   choose brush tool
   set the brush to 32
   set the brushColor to red
   set the dragSpeed to 0
   drag from 50,50 to 200,200
   choose browse tool
   stop editing group "mapGroup" --Add
   unlock screen
end mouseUp
With the start editing the new image1 is placed inside the mapGroup. mapGroup has locked size and position.

Maybe I didn't get the question.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

Post Reply