the polygon tool

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
windowsLC
Posts: 26
Joined: Sat Dec 16, 2017 5:58 am

the polygon tool

Post by windowsLC » Thu Jan 04, 2018 11:03 pm

The polygon tool has the dashed edit thing around it (editmode I think it has to do with) as you click the points to form the polygon. Is there a way to not have that around it. I am using a button that chooses polygon tool and the user needs to draw the polygon but having that editmode thing around it while they do, doesn't look right. I know the polygon paint tool doesn't have it, but this needs to be a graphic.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9663
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: the polygon tool

Post by dunbarx » Fri Jan 05, 2018 12:58 am

Hi.

I don't think so. LC is not a CAD program, though I wish it was. In that world, generally only the handles of an object are "hilited", available for dragging or for a command line instruction, and I think this is what you want.

I bet it is just the way LC rolls.

Craig Newman

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: the polygon tool

Post by Mark » Fri Jan 05, 2018 2:45 am

You could ask the user to click on the card, record the points and save them in a variable, and set the points of a new polygon to that variable.
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9663
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: the polygon tool

Post by dunbarx » Fri Jan 05, 2018 5:50 am

Mark.

Sometimes the points have to be precise. You idea would work if "fairly close" was adequate.

In a CAD program, the cursor snaps to a handle when it gets to within a few pixels of the actual point. LC does not have that feature, though it can be scripted.

Craig

windowsLC
Posts: 26
Joined: Sat Dec 16, 2017 5:58 am

Re: the polygon tool

Post by windowsLC » Fri Jan 05, 2018 7:09 pm

the correct title of this thread should have been Polygon Graphic tool as the Polygon tool for paint drawing doesn't have the problem.

Seems odd that it needs to be there while "drawing" or clicking the points of the polygon as it has no purpose until all the polygons points are set, and after it is set they are not visible unless in edit (and that can be changed with a property I think). I'd call it a bug

dunbarx, I'm not looking to change functionality, I just don't like the look and confusion of the dashed lines edit thingy around the polygon cursor and points as you click the points it is confusing looking and useless.

Hmmm Mark your suggestion is interesting, perhaps I can roll my own graphic tool. Maybe if I drop a marker image over each location and use a line to first connect to the mouse pointer then the next point etc, and eventually set a polygon with all the points as mark suggests. This could make something that approximates the LC polygon graphic tool. Sound feasible? Has this been done before?

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9663
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: the polygon tool

Post by dunbarx » Fri Jan 05, 2018 9:12 pm

Hi.

I can see how the rect that encloses the burgeoning polygon might be considered clutter.

It does however have use as a guide to the overall extent of the control. Know that if one clicks on a point within that rect, even though that point is "outside" what appears to be the visible "interior" of the graphic, LC considers that click to be within the rect of the graphic. This is important, and has engendered many threads, because you can set the opaque of the graphic to "true" and then set a backGround fill. You will get only the "interior" filled. But the rect still rules.

Anyway, Try a feature request to QCC, to be able to turn the phantom rect off.

Craig

windowsLC
Posts: 26
Joined: Sat Dec 16, 2017 5:58 am

Re: the polygon tool

Post by windowsLC » Fri Jan 05, 2018 9:58 pm

Dont think it will be needed, I'm trying my hand at rolling my own polygon graphic tool

I create a graphic called Polygon and then this in the card script works well to draw the polygon

Code: Select all

local drawing, closeit

on mouseUp pButtonNumber
   put true into drawing
   set the points of grc "draw" to the points of grc "draw" & cr & the mouseLoc   
end mouseUp

on mouseDoubleUp pButtonNumber
   get line 1 of the points of graphic "draw"
   set the points of grc "draw" to points of grc "draw" & cr & it
   put false into drawing
end mouseDoubleUp
My tool is actually better in that it closes the polygon

If I can figure out a way to have a line from last point to the mouse cursor while setting the points I think it will be perfect

windowsLC
Posts: 26
Joined: Sat Dec 16, 2017 5:58 am

Re: the polygon tool

Post by windowsLC » Fri Jan 05, 2018 10:31 pm

Ok got my better polygon graphic tool with the line to the mouse working. Needs a little code for the cross mouse cursor and to move on to the next polygon if needed, but I have to say I'm happy with the result.

Code: Select all

local drawing, closeit

on mouseUp pButtonNumber
   put true into drawing
   set the points of grc "draw" to the points of grc "draw" & cr & the mouseLoc   
end mouseUp

on mouseDoubleUp pButtonNumber
   get line 1 of the points of grc "draw"
   set the points of grc "draw" to points of grc "draw" & cr & it
   put false into drawing
end mouseDoubleUp

on mouseMove pNewMouseH, pNewMouseV
   if drawing contains true then
   get last line of the points of grc "draw"
   set the points of grc "lastpoint" to it & cr & the mouseLoc
else
   exit mouseMove
      end if
end mouseMove

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”