Example #1
0
def main(Colors):

    windowWidth = 300
    windowHeight = 300

    padding = 3

    Color = random.choice(Colors)
    gWindow = GRC.GraphicsWindow("Rectangles", windowWidth, windowHeight)

    sq = []
    rect = GRC.Rectangle(GRC.Point(10, 10), GRC.Point(290, 290))
    rect1 = GRC.Rectangle(GRC.Point(20, 20), GRC.Point(280, 280))
    for i in range(1, 30):
        #rect = GRC.Rectangle(GRC.Point(padding * i, padding * i), GRC.Point(windowWidth - (padding * i),  + windowHeight - (padding * i)))
        gWindow.addItem(
            GRC.Rectangle(
                GRC.Point(padding * i, padding * i),
                GRC.Point(windowWidth - (padding * i),
                          +windowHeight - (padding * i))))
        gWindow.autoflush
        gWindow.update()

    gWindow.redraw()
    gWindow.waitForKeyPress()
def drawRectanglBox():

    # set boarder Color of box object
    boarderColor = "Black"

    # set boarder Color of box object
    fillColor = "Yellow"

    # define a polygon object as a box
    box = GRC.Rectangle(GRC.Point(0, 0), GRC.Point(25, 25))
    box.setBoarderColor(boarderColor)
    box.setFillColor(fillColor)
    p1 = GRC.Point(10, 10)
    p2 = GRC.Point(20, 20)

    #mybox = GRC.BBox(p1,p2)
    #mybox.draw(gWindow)

    # Pass graphic window object to the box object; call draw method.
    box.draw(gWindow)
    box.jumpTo(GRC.Point(270, 0))
    gWindow.waitForClick()

    status = True
    while status:
        mp = gWindow.checkForClick()
        if mp != None:
            box.jumpTo(mp)
            #print (mp)

    box.move(0, 50)
    #xx = box.getCenter().x
    #yy = box.getCenter().y
    p1 = box.p1
    p2 = box.p2

    xx = box.p1.x
    yy = box.p1.y

    #print (xx,yy,p1,p2)
    gWindow.waitForClick()

    #box.p2 = GRC.Point(p2.x+10,p2.y+10)
    print(box.p1.x, box.p1.y, box.p1, box.p2)

    box.jumpTo(GRC.Point(0, 100))

    # click on window to close\exit
    gWindow.waitForClick()