← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #142168]: Unexpected result of Region.right()

 

Question #142168 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/142168

RaiMan posted a new comment:
Oh yes, we Sikulist's need a bunch of these utility functions in our
daily Sikuli life ;-)

Your utility function:
your intention seems to be, to stay with the modified region inside the borders of the old one (the left and top borders are moved, but the right and bottom stay fixed).

You are running the risk to get a negative width and or height in cases
where (whatever reason) dx is greater than w+dw (same for h).

I have a similar function and always prefer to create a new region (more
flexible in usage).

def regInside(reg, left, right, top=0, bottom=0):
	return Region(max(reg.x, reg.x+left), max(reg.y, reg.y+top), max(1,reg.w-left-right), max(1,reg.h-top-bottom))

I mainly use it to cut off left and right portion of a region in text
recognition cases (therefor the top and bottom 0 default)

Normally you only need to change the region itself, if you have attached
attributes like error handling and observers that you want to keep or in
some looping constructions.

-- 
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.