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

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

Need clean image

Post by dunbarx » Tue May 17, 2022 8:24 pm

I need an image that looks like this, but can not be anything beyond the extent of the shape shown. Right now I I always get some blank space outside the actual shape.
Screen Shot 2022-05-17 at 2.54.49 PM.png
Screen Shot 2022-05-17 at 2.54.49 PM.png (5.78 KiB) Viewed 2983 times
And I will need to expand and shorten the width of this image under script control, but keep the line width of the small "ends" the same. Currently they thin out as I reduce the width of the whole.

I know LC is not intended to be a drawing or CAD program. How do I make an image but only "grab" the actual lines?

Craig

Klaus
Posts: 13829
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Need clean image

Post by Klaus » Tue May 17, 2022 8:41 pm

Hi Craig,

not sure I fullly understand your problem, but check the image property CenterRect in the dictionary.
This lets you define a region of the image which should be streched when resizing the image instead of streching the complete image.
Sounds like this could be a solution.


Best

Klaus

SparkOut
Posts: 2852
Joined: Sun Sep 23, 2007 4:58 pm

Re: Need clean image

Post by SparkOut » Tue May 17, 2022 9:22 pm

I am not sure what your requirements are either, but wouldn't it be much simpler and cleaner to make a line graphic to draw the shape with a simple set of points? You can very easily script the length of the main width, and adjust the points of the vertical "ends" appropriately.
Otherwise, what Klausimausi said.

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

Re: Need clean image

Post by dunbarx » Tue May 17, 2022 9:40 pm

@Sparkout

The problem with a polygon graphic is that if I set its opaque then LC closes the shape into a rectangle. I cannot use a rectangle. The user changes the width of the graphic dynamically by keeping the pointer within the rect of the graphic and sending "mouseStillDown" messages. With the opaque cleared, LC does not know what the target is.

@ Klaus. Will check out that property. Watch this space...

Craig

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9837
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Need clean image

Post by FourthWorld » Tue May 17, 2022 10:04 pm

dunbarx wrote:
Tue May 17, 2022 9:40 pm
@Sparkout

The problem with a polygon graphic is that if I set its opaque then LC closes the shape into a rectangle.
Mark Waddingham provided a nifty trick for creating polygons that avoid the closed shape:
https://forums.livecode.com/viewtopic.p ... 06#p215281
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

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

Re: Need clean image

Post by dunbarx » Tue May 17, 2022 10:11 pm

Richard.

Thank you.

I am an idiot. And you can see my happy congratulations to Mark for that very solution in the next post.

Problem solved.

Idiot.

Craig

SparkOut
Posts: 2852
Joined: Sun Sep 23, 2007 4:58 pm

Re: Need clean image

Post by SparkOut » Tue May 17, 2022 10:13 pm

Aha.
Notwithstanding the trick from Mark W, I would personally have done something like using an opaque rectangle graphic with no border, and as that is resized, then adjust the points of the (3 segment) line graphic to match the corners. There's not even any calculation involved then, just steal the coordinates from the other object.

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

Re: Need clean image

Post by dunbarx » Tue May 17, 2022 10:25 pm

All

Interestingly, if you run Mark's gadget, but then flip the graphic, the shape closes.

No problem for me, I will just make the several orientation options I need from scratch. But I cannot make them all from a single "template".

Craig

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

Re: Need clean image

Post by dunbarx » Tue May 17, 2022 10:30 pm

Sparkout.

I tried to adjust the points of such a polygon early on. When I set the opaque, LC happily adds the new line in the points property. But deleting that last line does not change anything in the graphic itself. And of course, deleting the last two lines will make a closed triangle, essentially "maintaining" that last closed line.

Craig

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

Re: Need clean image

Post by dunbarx » Tue May 17, 2022 10:47 pm

Mark is still a lifesaver.

But know that if one changes the points of such a manhandled polygon the shape closes. It does not if the shape is adjusted in edit mode with the mouse, only if properties are changed in the inspector or under script control.

Note that one can change the width or height of such a graphic using any method, just not the points.

Craig

SparkOut
Posts: 2852
Joined: Sun Sep 23, 2007 4:58 pm

Re: Need clean image

Post by SparkOut » Tue May 17, 2022 10:48 pm

I meant having two objects, one a resizable graphic rectangle with no border to handle the scaling, and another line graphic of 3 segments that you update the points on the fly to match (3 sides of) the separate rectangle as it resizes.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9837
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Need clean image

Post by FourthWorld » Wed May 18, 2022 12:17 am

If MW's solution doesn't do what you need, I'd just put a poly and a rect in a group and keep moving forward.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

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

Re: Need clean image

Post by dunbarx » Wed May 18, 2022 1:33 am

Richard.

Did that too. I may yet again if what I think are fragile polygons fall apart after being manhandled, stretched and shrunk.

Craig

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9837
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Need clean image

Post by FourthWorld » Wed May 18, 2022 1:49 am

"fall apart"?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

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

Re: Need clean image

Post by richmond62 » Wed May 18, 2022 9:17 am

Oh, Look! It's Richmond's shovel:
-
shovel.jpg
shovel.jpg (3.39 KiB) Viewed 2834 times
-
Screen Shot 2022-05-18 at 11.14.06 AM.png
-

Code: Select all

on mouseDown
   grab me
end mouseDown

on mouseStillDown
   set the top of me to 10
   put the right of img "RV" into RITE
   put the left of me into LLL
   put (RITE - LLL) into LENF
   set the width of img "HOR" to LENF
   set the left of img "HOR" to LLL
   set the right of img "HOR" to RITE
end mouseStillDown

on mouseUp
   set the top of me to 10
   put the right of img "RV" into RITE
   put the left of me into LLL
   put (RITE - LLL) into LENF
   set the width of img "HOR" to LENF
   set the left of img "HOR" to LLL
   set the right of img "HOR" to RITE
end mouseUp
Attachments
WIDE.livecode.zip
Stack.
(1.27 KiB) Downloaded 72 times

Post Reply

Return to “Talking LiveCode”