Oh, i see. I do commonly use the tables for storing images and its position. How can I create and use a lookup table (dictionary)? Can you provide a code example for implementing and utilizing a lookup table in this context?BrotSagtMist wrote: ↑Tue Sep 19, 2023 12:38 pm There are a few other methods, but they are all highly situation dependent.
This if its in range check is the best option to use usually.
So whats wrong with it? Where is your complain?
This is easy to write and fast to execute and there is nothing to improve.
Unless you have to deal with say a few thousand images at once where instead you can map the screen to a lookup table.
A lookup table has almost zero check time but a high creation cost. So there is that.
Efficient Mouse Interaction and Event Handling for Objects
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
-
- Prole
- Posts: 7
- Joined: Mon Sep 18, 2023 6:46 pm
- Contact:
Re: Efficient Mouse Interaction and Event Handling for Objects
Re: Efficient Mouse Interaction and Event Handling for Objects
There is no way around having lag when dragging something.Athrikesha wrote: ↑Fri Sep 22, 2023 8:38 am No this is still quite buggy, unless i am mistaken. Moreover i think that it is slower, than one might expect. One improvement would be to lock the active rectangle and release the lock only when mouse is released, but i dont know. Slower in the sense, the speed when we drag a rectangle is dubious.
viewtopic.php?p=195509#p195509
-
- Prole
- Posts: 7
- Joined: Mon Sep 18, 2023 6:46 pm
- Contact:
Re: Efficient Mouse Interaction and Event Handling for Objects
One other thing, that is relatively off-topic.
I have seen browsers rendering css more effectively. Say for instance even the hover function looks like it relatively effortless. Does this mean lua over love2d, has an inherent shortcoming to implement such sort of. Or am i so unaware of some fundamentals. I explect a non out of box solution to place, and track images on screen.
https://drive.google.com/file/d/1-jMGAX ... sp=sharing
There are two aspects to my question
1. Easy coding - manageability of multiple images, with less fuss on images and their position tracking.
2. Efficiency - i can implement a solution where i onload a few images within a table. And then proceed with iterating though the table for image/object that matches the mouse x,y. But wont it slow down and induce a drag?.
What i expect as a solution (This could sound a bit silly but be with me on this):
a library like function that handles a lot of images and tracks their position and implement best means (algorithm) for detecting the images that are active. cost wise and manageability wise.
Tanks
I have seen browsers rendering css more effectively. Say for instance even the hover function looks like it relatively effortless. Does this mean lua over love2d, has an inherent shortcoming to implement such sort of. Or am i so unaware of some fundamentals. I explect a non out of box solution to place, and track images on screen.
https://drive.google.com/file/d/1-jMGAX ... sp=sharing
There are two aspects to my question
1. Easy coding - manageability of multiple images, with less fuss on images and their position tracking.
2. Efficiency - i can implement a solution where i onload a few images within a table. And then proceed with iterating though the table for image/object that matches the mouse x,y. But wont it slow down and induce a drag?.
What i expect as a solution (This could sound a bit silly but be with me on this):
a library like function that handles a lot of images and tracks their position and implement best means (algorithm) for detecting the images that are active. cost wise and manageability wise.
Tanks
Re: Efficient Mouse Interaction and Event Handling for Objects
As far as I know, Love doesn't have anything to help with this, probably because this isn't a difficult problem to solve, nor is it particularly slow. (Brot will probably complain) but my instinctual response for making it easy to make an image/button class.Athrikesha wrote: ↑Fri Sep 22, 2023 1:01 pm One other thing, that is relatively off-topic.
I have seen browsers rendering css more effectively. Say for instance even the hover function looks like it relatively effortless. Does this mean lua over love2d, has an inherent shortcoming to implement such sort of. Or am i so unaware of some fundamentals. I explect a non out of box solution to place, and track images on screen.
https://drive.google.com/file/d/1-jMGAX ... sp=sharing
There are two aspects to my question
1. Easy coding - manageability of multiple images, with less fuss on images and their position tracking.
2. Efficiency - i can implement a solution where i onload a few images within a table. And then proceed with iterating though the table for image/object that matches the mouse x,y. But wont it slow down and induce a drag?.
What i expect as a solution (This could sound a bit silly but be with me on this):
a library like function that handles a lot of images and tracks their position and implement best means (algorithm) for detecting the images that are active. cost wise and manageability wise.
Tanks
As for efficiency, it doesn't get much more efficient than iterating through a table and checking if the mouse is within a rectangle - I think if you implemented it yourself, you would find that it also looks effortless. As long as the calculation can be done in less time than it takes to render to the screen, you generally won't notice anything. If you really want to make it more efficient, then I guess you could make it so that it only does the check when either the mouse moves, or the one of the image's position changes, though to me that sounds like overkill.
tldr: Don't worry too much about efficiency until it's actually a problem
Dragon
-
- Prole
- Posts: 7
- Joined: Mon Sep 18, 2023 6:46 pm
- Contact:
Re: Efficient Mouse Interaction and Event Handling for Objects
yeah, this needs to be said, thanksBobble68 wrote: ↑Sat Sep 23, 2023 8:17 pmAs far as I know, Love doesn't have anything to help with this, probably because this isn't a difficult problem to solve, nor is it particularly slow. (Brot will probably complain) but my instinctual response for making it easy to make an image/button class.Athrikesha wrote: ↑Fri Sep 22, 2023 1:01 pm One other thing, that is relatively off-topic.
I have seen browsers rendering css more effectively. Say for instance even the hover function looks like it relatively effortless. Does this mean lua over love2d, has an inherent shortcoming to implement such sort of. Or am i so unaware of some fundamentals. I explect a non out of box solution to place, and track images on screen.
https://drive.google.com/file/d/1-jMGAX ... sp=sharing
There are two aspects to my question
1. Easy coding - manageability of multiple images, with less fuss on images and their position tracking.
2. Efficiency - i can implement a solution where i onload a few images within a table. And then proceed with iterating though the table for image/object that matches the mouse x,y. But wont it slow down and induce a drag?.
What i expect as a solution (This could sound a bit silly but be with me on this):
a library like function that handles a lot of images and tracks their position and implement best means (algorithm) for detecting the images that are active. cost wise and manageability wise.
Tanks
As for efficiency, it doesn't get much more efficient than iterating through a table and checking if the mouse is within a rectangle - I think if you implemented it yourself, you would find that it also looks effortless. As long as the calculation can be done in less time than it takes to render to the screen, you generally won't notice anything. If you really want to make it more efficient, then I guess you could make it so that it only does the check when either the mouse moves, or the one of the image's position changes, though to me that sounds like overkill.
tldr: Don't worry too much about efficiency until it's actually a problem
Who is online
Users browsing this forum: Ahrefs [Bot] and 6 guests