← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #184255]: How to draw a circle or some shape using sikuli?

 

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

    Status: Open => Answered

dinev proposed the following answer:
Did you run successfully the first example? You need paint open.
Here is the video of the working script: http://screencast.com/t/39GPFv1ILTvw 
Here is the full script(triangle and rectangle draw are commented):
-------------------------------------------
import math

start_point= "start_point-1.png"

def drawRect():
    mLoc=Env.getMouseLocation().offset(100,100)
    mouseMove(mLoc)
    mouseDown(Button.LEFT)
    mouseMove(mLoc.offset(200,0))
    mouseMove(mLoc.offset(200,100))
    mouseMove(mLoc.offset(0,100))
    mouseMove(mLoc.offset(0,0))
    mouseUp()

def drawTriang():
    mLoc=Env.getMouseLocation().offset(300,300)
    mouseMove(mLoc)
    mouseDown(Button.LEFT)
    mouseMove(mLoc.offset(200,0))
    mouseMove(mLoc.offset(100,100))
    mouseMove(mLoc.offset(0,0))
    mouseUp()

def drawCircle():
    mLoc=Env.getMouseLocation().offset(250,250)
    radius=100
    for i in range(37):
        degInRad = i*math.pi/18
        pointX=int(math.cos(degInRad)*radius)
        pointY=int(math.sin(degInRad)*radius)       
        mouseMove(mLoc.offset(pointX,pointY))
        if i==0: mouseDown(Button.LEFT)
    mouseUp()
    
sleep(1)
switchApp("Paint")
mouseMove(start_point)
#drawTriang()
#mouseMove(start_point)
#drawRect()
drawCircle()

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