Trying to externalize the target offset, the same as I have with the similarity

Asked by arminius on 2018-05-09

So this is an example that works

    mySimilarity = 0.81
    if exists(Pattern(Pattern("1519473014822.png").targetOffset(1,-13)).similar(mySimilarity)):

But I'm wanting to do the same with targetoffset

    mySimilarity = 0.81
    testtargetOffset = "1,-8"
    if exists(Pattern("1525837542502.png").targetOffset(testtargetOffset)).similar(mySimilarity)):

But no matter how many times I play aroud with the Colons it's never happy.

Question information

Language:
English Edit question
Status:
Solved
For:
Sikuli Edit question
Assignee:
No assignee Edit question
Solved by:
Manfred Hampl
Solved:
2018-05-15
Last query:
2018-05-15
Last reply:
2018-05-09
RaiMan (raimund-hocke) said : #1

the dotted attributes have to be chained to the same new Pattern:
myPattern = Pattern("1525837542502.png").targetOffset(testtargetOffset).similar(mySimilarity)
if exists(myPattern):

Best Manfred Hampl (m-hampl) said : #2

see http://sikulix-2014.readthedocs.io/en/latest/pattern.html

targetOffset needs two parameters targetOffset(dx, dy)

Try

     mySimilarity = 0.81
     testtargetOffsetX = 1
     testtargetOffsetY = -8
     if exists(Pattern("1525837542502.png").targetOffset(testtargetOffsetX,testtargetOffsetY).similar(mySimilarity)):

RaiMan (raimund-hocke) said : #3

@Manfred
... LOL, thanks - don't my own API ;-)

arminius (arminius75) said : #4

Thanks Manfred Hampl, that solved my question.