Need clean image

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4003
Joined: Sun Jan 07, 2007 9:12 pm
Location: Bochum, Germany

Re: Need clean image

Post by bn » Wed May 18, 2022 9:50 am

Craig,

you could move an open polygon with a bit of cheating. It involves an image at 99% transparency that gets the mouse events and passes them to an enclosing group. Script is in the group.

grabDragNonclosedPolygon.livecode.zip
(1.18 KiB) Downloaded 74 times

Kind regards
Bernd

PS I immensely enjoyed your flash-talk at the 2022 developer conference. Wow.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9388
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Need clean image

Post by richmond62 » Wed May 18, 2022 10:04 am

You could, of course, do what I did with 3 graphics in a group, and a script in the group.

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4003
Joined: Sun Jan 07, 2007 9:12 pm
Location: Bochum, Germany

Re: Need clean image

Post by bn » Wed May 18, 2022 10:55 am

richmond62 wrote:
Wed May 18, 2022 10:04 am
You could, of course, do what I did with 3 graphics in a group, and a script in the group.
No I could not. One of many reasons would be that it is hard to grab (relatively small width)

If I would do that though I would change the code e.g. for image "RV" to

Code: Select all

local sRunning, sXDiff, sYLoc

on mouseDown
   put the clickLoc into tClick
   put the loc of me into tLoc
   put item 1 of tClick - item 1 of tLoc into sXDiff
   put item 2 of tLoc into sYLoc
   put true into sRunning
end mouseDown

on mouseMove x,y
   if not sRunning then exit mouseMove
   lock screen
   put x - sXDiff into tNewX
   set the loc of me to tNewX, sYLoc
   put the right of me into RITE
   put the left of img "LV" into LLL
   put (RITE - LLL) into LENF
   set the width of img "HOR" to LENF
   set the left of img "HOR" to LLL
   unlock screen
end mouseMove

on mouseUp
   lock screen
   put false into sRunning
end mouseUp
Can you spot the difference?

Kind regards
Bernd

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9388
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Need clean image

Post by richmond62 » Wed May 18, 2022 11:21 am

No I could not.
Of course you COULD, but you WILL NOT.

A group would NOT have a small width to grab,

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

Re: Need clean image

Post by dunbarx » Wed May 18, 2022 2:31 pm

Lots of hubbub.

I use this in the card script to dynamically adjust the width/height of these thin "brackets", which are used to annotate the locations and extents of various circuits in a drawing. For the horizontal versions:

Code: Select all

on mouseStillDown
   if the controlKey is down then set the width of the target to the width of the target + 3
   else if the commandKey is down then set the width of the target to the width of the target - 3
end mouseStillDown

on mouseMove
   if the mouse is down then set the loc of me to the mouseLoc
end mouseMove
Works fine. The actual handlers only work if the target has certain custom properties set. The user can "grab" these objects, place them as required, then adjust their dimensions by eye.

That was never the problem. I rarely use images or graphics, but I am getting by fairly well with the new graphic gadgets tweaked by Mark W. The issue I had with images is that the line widths varied as the dimensions did. Polygons are constant.

Craig

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9388
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Need clean image

Post by richmond62 » Wed May 18, 2022 2:35 pm

Lots of hubbub.
Healthy Hubbub can be an education in itself.

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

Re: Need clean image

Post by dunbarx » Wed May 18, 2022 2:37 pm

Richard.

Yes, fall apart.

In development at least, the polygons are a bit fragile, in that after playing with them I have inadvertently done things that close that last side. I am putting in defenses against that happening. It is possible that once these things are built and only users, er, use them, and my meddling stops, they will likely be stable.

Craig

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

Re: Need clean image

Post by dunbarx » Wed May 18, 2022 2:40 pm

Bernd.

Thanks for the compliment.
you could move an open polygon with a bit of cheating. It involves an image at 99% transparency that gets the mouse events and passes them to an enclosing group. Script is in the group.
I have played with such "compound" controls but am going to try my best to make simple polygon graphics do the job. They seem to hold their line widths better when stretched or compressed.

Craig

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

Re: Need clean image

Post by dunbarx » Wed May 18, 2022 3:01 pm

@LCMark.

Changing a polygon to a curve and setting its opaque works just fine. I do not need to revert back to a polygon. The shape stays stable when its dimensions are changed.

Craig

Post Reply

Return to “Talking LiveCode”