Pregunta

I have a region object, which has to be resized. It needs to be 20px smaller from every border. However the Region.nearby() function does only accept positive integer values, so the region can only become bigger, not smaller.
Is there any other function for resizing a region or a workaround to pass even negative integers to the function?

¿Fue útil?

Solución

You could define the X,Y,H,W of the new region based on the old region with something like this:

oldRegion = SomeRegionYouAlreadyDefined
oldRegion.highlight(2) 
newRegion = Region((oldRegion.getX() + 20), (oldRegion.getY() + 20), (oldRegion.getW() - 40), (oldRegion.getH() - 40))
newRegion.highlight(2)

Of course, you can remove the .highlight() lines. That's just for ease of seeing where your regions are.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top