Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Geometry Methods! #160

Open
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

hewentto
Copy link

@hewentto hewentto commented Apr 29, 2023

Fixes OSR-29
Fixes 119

Added the following methods
Rectangle.scale()
RuneliteObject.scale()
Rectangle.get_center_left
RuneliteObject.distance_from_rect_left
RuneliteObject.distance_from_top_left()

Added the following methods
Rectangle.scale()
RuneliteObject.scale()
Rectangle.get_center_left
RuneliteObject.distance_from_rect_left
RuneliteObject.distance_from_top_left()
@hewentto
Copy link
Author

Examples
https://imgur.com/a/ijxCs8Q

returns new objects instead of modifying existing ones
created a copy, then scaled
@hewentto
Copy link
Author

hewentto commented Apr 29, 2023

This is now done, one point to note is the RuneliteObject loses its "shape" with the scaling method, now instead of axis containing all the points within it's bounding color-box, it has all the points within its new corners. This can be revisited another time but without sucking all the processing and taking seconds this was the fastest way. When scaling it's a given that we lose accuracy anyways, but there could be a better way.

@hewentto
Copy link
Author

hewentto commented Apr 29, 2023

Another alternative and quicker processing is to use the check for axis in the random_point() method only check if a rectangle is not scaled. Maybe when we scale a rectangle set a boolean to true

@hewentto
Copy link
Author

#119

@kelltom
Copy link
Owner

kelltom commented Apr 30, 2023

I added some additional methods for sorting based on arbitrary points. Haven't had time to review the rest but will hopefully get at it this week.

@kelltom kelltom added the type: enhancement This issue or pull request enhances existing code label May 1, 2023
@kelltom
Copy link
Owner

kelltom commented May 1, 2023

I think the solution for the random_point thing will be to have a parameter to toggle whether we should only return a random point that exists within the outline bounds (axis). The is_scaled flag idea you bring up is also good... That might make more sense -- people are going to scale them literally to increase the click box.

With all that said, since I added that sort key method that allows any point as input, should we get rid of the other hardcoded ones? Probably not necessary to have them, as sorting code is typically only written once, so it's not like it's added work to add the extra parameter. That way, we can also implement sorting for tile-based movement based on the direction the player has to travel (and thus, any point along the edges of the game view). This would result in possibly more accurate results.

And last, I think I might add some translate methods as well, so you can shift a rectangle a bit. In this case, I think the random_point should still return a point that is truly within the shape; the main use case being that we can shift a rectangle toward the position of the mouse slightly to make clicks gravitate closer to the edge of the object where the mouse is coming from. Basically a realism thing. I think I saw that translation was kinda possible in your scale method, but if scaling is going to set that "is_scaled" flag, then maybe it can be separate -- idk just spitballing.

Will look at this with fresh eyes tomorrow <-- this was a lie

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement This issue or pull request enhances existing code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants