What is the point???

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: 10305
Joined: Wed May 06, 2009 2:28 pm

What is the point???

Post by dunbarx » Wed Jun 12, 2024 2:37 pm

I made a simple test stack to show how one can snap a particular point of one control, like its corner, to another "point" of interest, like a corner or the midpoint of a side, on another control. Works fine, though I do not expect to be able to create another SolidWorks out of LC.

But there is something amiss, and it has to do with my LC understanding of the bounds of a control. In the stack, with the optionKey down, one may drag the small field around the card, and if its botLeft gets near the topRight of the larger field, it will snap to that point.

But release the optionKey to leave the small field in place, and there is a gap visible between the two controls at what should be their shared point. The topRight of the larger field is the same as the botLeft of the smaller, but they do not visually coincide.

What is the point?

There is a similar handler in the small field script that allows one to set the botLeft of the small field to the midpoint of the right side of the larger. Same issue there.

Craig
Poor man's snap.livecode.zip
(1.16 KiB) Downloaded 94 times
Last edited by dunbarx on Wed Jun 12, 2024 3:23 pm, edited 1 time in total.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10078
Joined: Fri Feb 19, 2010 10:17 am

Re: What is the point???

Post by richmond62 » Wed Jun 12, 2024 3:15 pm

I didn't look at your stack, but made my own. 8)
-
SShot 2024-06-12 at 17.09.47.png
SShot 2024-06-12 at 17.09.47.png (4.33 KiB) Viewed 3687 times
-
The Bottom Right of the field is 150, 90

The Top Left of the button is 150, 90

And, Yes: there is an extremely visible gap between them.

LC Community 9.6.3

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

Re: What is the point???

Post by dunbarx » Wed Jun 12, 2024 3:21 pm

Richmond.

I am wondering if this is some sort of optical illusion, based on the fact that a screen can only do so much to render and locate objects on itself accurately.

With a loupe on my monitor I see many more pixels, about twice the pixel density, than what typically is the resolution of "one pixel" that we are used to when manipulating objects with the several programs we all use every day. Maybe this is all a rounding error?

Craig

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10078
Joined: Fri Feb 19, 2010 10:17 am

Re: What is the point???

Post by richmond62 » Wed Jun 12, 2024 3:34 pm

Here's another silly picture:
-
SShot 2024-06-12 at 17.31.26.png
SShot 2024-06-12 at 17.31.26.png (4.96 KiB) Viewed 3677 times
-
What I notice is that the selection handles are "fatter' on the outside of an object than inside.

So this tells me that those points are "off".

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

Re: What is the point???

Post by dunbarx » Wed Jun 12, 2024 4:17 pm

Richmond.

The selection handles are not considered any part of the geometry of the objects, rather only temporary aids. Only the rect of an object matters.

Craig

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10078
Joined: Fri Feb 19, 2010 10:17 am

Re: What is the point???

Post by richmond62 » Wed Jun 12, 2024 4:30 pm

Only the rect of an object matters.
You'd have thought so, wouldn't you.

But there is something a bit odd when the same set of points result in 2 things being separated by an empty patch.
-
terry-thomas.jpg
terry-thomas.jpg (22.73 KiB) Viewed 3662 times
-
There's no gap between his 2 front teeth: honest! 8)

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

Re: What is the point???

Post by dunbarx » Wed Jun 12, 2024 4:56 pm

Richmond.

A "point" is not a mathematical point, but rather a blotch. It has a length and width, based on the measurable pixels that form the display. So where do we "locate" the, er, loc of such a smear?

At the center? Likely it is instead at the "outer" extreme. In CAD programs that have adjustable line widths, the outermost portion of a line sets the value of its thickness. I am sure LC does the same.

So again, Is there really a gap, or is it an illusion caused by the screen doing its best with not-infinitely-small pixels?

Craig

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

Re: What is the point???

Post by dunbarx » Wed Jun 12, 2024 4:59 pm

Richmond.

Terry-Thomas looks SO British; the gap only helps. Even the dash in his name screams that out.

Craig

andresdt
Posts: 156
Joined: Fri Aug 16, 2019 7:51 pm
Contact:

Re: What is the point???

Post by andresdt » Wed Jun 12, 2024 5:26 pm

Maybe it's just an optical effect. Because if you change the background color of the fields and set the showBorder property to false. It is seen that they are indeed where they should be.
Attachments
Screenshot_6.png
Screenshot_6.png (5.36 KiB) Viewed 3643 times
Screenshot_5.png
Screenshot_5.png (4.68 KiB) Viewed 3643 times
Be kind, we all have our own wars.
https://torocruzand.com/

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

Re: What is the point???

Post by dunbarx » Wed Jun 12, 2024 5:31 pm

Andresdt.

AHA.

So it is just screen rendering doing its best in a clunky world.

Craig

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10078
Joined: Fri Feb 19, 2010 10:17 am

Re: What is the point???

Post by richmond62 » Wed Jun 12, 2024 6:16 pm

a clunky world
Indeed: ROFL.

Just upgraded my 2018 Mac Mini to MacOS 15 Sequoia . . .

stam
Posts: 3061
Joined: Sun Jun 04, 2006 9:39 pm

Re: What is the point???

Post by stam » Wed Jun 12, 2024 11:07 pm

I suspect it’s because borderwith of either object has not been taken into account…

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

Re: What is the point???

Post by dunbarx » Thu Jun 13, 2024 2:47 am

Stam.

If I read your post correctly, that would cause the two objects to appear to overlap, not (appear to) fail to meet, no?

Craig

stam
Posts: 3061
Joined: Sun Jun 04, 2006 9:39 pm

Re: What is the point???

Post by stam » Thu Jun 13, 2024 11:03 am

Yeah that's right. I mean, they either overlap on 1 dot, or there is a gap, which if I understood correctly, is what you were trying to solve.

this modification to your code seems to make it work well, but is not generalisable (ie assumes we're only talking about the bottomLeft->topRight and that the borderWidth of both objects is 1)

Code: Select all

on mousemove --to the corner
   if the optionKey is down then set the loc of me to the mouseLoc
   
   if abs(item 1 of the botLeft of fld "F1" - item 1 of the topRight of fld "F2") < 8 and \
         abs(item 2 of the botLeft of fld "F1" - item 2 of the topRight of fld "F2") < 8 then \
            set the botleft of fld 1 to right of fld "f2" - 1, the top of fld "f2" + 1
end mousemove
This makes it look like this:
Screenshot 2024-06-13 at 13.02.44.png
Screenshot 2024-06-13 at 13.02.44.png (9.98 KiB) Viewed 3546 times

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4163
Joined: Sun Jan 07, 2007 9:12 pm

Re: What is the point???

Post by bn » Thu Jun 13, 2024 11:16 am

I think this has somehow to do with the cartesian coordinates that start at 0,0. TopLeft is within the rect, botRight is outside.

Code: Select all

on mouseUp
   put the rect of field 1 into tRect
   put item 1 of tRect, item 2 of tRect into tTopLeft
   put item 3 of tRect, item 4 of tRect into tBotRight
   put "topLeft is within: " & (tTopLeft is within tRect) & cr & "botRight is within: " & (tBotRight is within tRect)
end mouseUp
Kind regards
Bernd

Post Reply