I’m using the Geomerative library, but the RShape.contains(RShape) doesn’t seem to be working for me. It always seems to return false, no matter what. Heres a sketch that accurately describes the problem - the small rectangle should turn red when inside the larger one, but it never does, despite intersecting with it, and then not intersecting with it after it goes inside.
The geomerative tutorial example on contains finds whether a RPoint is contained within an RShape, and works OK for me, may’be you could get that to work for you?
Hey, that looks really good, thank you!! I tried the RShape.contains(RPoint[]) and it didn’t work. I didn’t think to just check each of them manually in my own function. Dumb of me, in retrospect. XD
Hmm. This is only vaguely related, but how would you suggest I put a buffer zone between the shapes? Should I just make a bounding box with the increased space and text against that? Or is there a better way?
I’m quite fond of the geomerative library which is why I answered your original question. It seems that there a few glitches unfinished things as you found with not working contains(RPoint[] pts). I have come up with neater workaround for your original boundary test see this gist.
That actually seems less sophisticated though. It only checks against the bounding rectangle, which means that if you’re dealing with fitting things inside a hexagon, for example, you will occasionally have cases where symbols get invalidated by their corners when they shouldn’t be. Fitting an o against a sloped wall, for example. It’s probably more efficient, but as I only need to run this code when generating graphics, I’m not super concerned about that.