예제 #1
0
def main():
    for i in range(0, 50):
        x = random.randint(5, windowWidth - 5)
        y = random.randint(5, windowHeight - 5)
        rgb = color_rgb(255, 255, 0)
        pix = pixel(x, y, rgb)
        pixels.append(pix)
        gWindow.plotPixel(x, y, "Red")

    Util.sleep(1)
    pix1 = pixels.pop()
    pix2 = pixels.pop()
    line = GRC.Line(GRC.Point(pix1.x, pix1.y), GRC.Point(pix2.x, pix2.y))
    rndColor = random.choice(Util.Colors2)
    line.setFillColor(rndColor)
    gWindow.addItem(line)
    gWindow.redraw()
    gWindow.update()
    Util.sleep(interval)
    #print("paused")
    #Util.pause(gWindow)

    while len(pixels) > 0:
        pix1 = pix2
        pix2 = pixels.pop()
        line = GRC.Line(GRC.Point(pix1.x, pix1.y), GRC.Point(pix2.x, pix2.y))
        rndColor = random.choice(Util.Colors2)
        line.setFillColor(rndColor)
        gWindow.addItem(line)
        gWindow.redraw()
        gWindow.update()
        Util.sleep(interval)
예제 #2
0
def seconds(centerPoint, radius):

    xx = centerPoint.getX()
    yy = centerPoint.getY()

    for tick in range(1, 61, 1):

        if tick < 16:
            lineEndPoint = GRC.Point(radius + (tick * 10), tick * 10)

        if tick >= 16 and tick < 31:
            lineEndPoint = GRC.Point(300 - ((tick - 15) * 10),
                                     150 + (tick - 15) * 10)

        if tick >= 30 and tick < 46:
            lineEndPoint = GRC.Point(150 - ((tick - 30) * 10),
                                     300 - (tick - 30) * 10)

        if tick >= 46 and tick < 61:
            lineEndPoint = GRC.Point(0 + ((tick - 45) * 10),
                                     150 - (tick - 45) * 10)

        line = GRC.Line(centerPoint, lineEndPoint)
        GRC.time.sleep(interval)
        gWindow.addItem(line)
        gWindow.redraw()
예제 #3
0
def main():

    line1 = GRC.Line(GRC.Point(10, 10), GRC.Point(20, 10))
    gWindow.addItem(line1)
    gWindow.redraw()
    Util.sleep(5)
    line1.move(20, 20)

    gWindow.redraw()

    Util.pause(gWindow)
예제 #4
0
def fifteenSeconds(centerPoint, radius):

    xx = centerPoint.getX()
    yy = centerPoint.getY()

    for tick in range(1, 16, 1):

        # line.move(GRC.Point(150,150),GRC.Point(10,1))
        #gWindow.items.remove(line)
        #gWindow.redraw()
        lineEndPoint = GRC.Point(radius + (tick * 10), tick * 10)
        line = GRC.Line(centerPoint, lineEndPoint)
        GRC.time.sleep(interval)
        gWindow.addItem(line)
        gWindow.redraw()
예제 #5
0
def main():

    circlePoints = pointsOnCircle(150, 150, 100)
    HourHandcirclePoints = pointsOnCircle(150, 150, 90)
    minuteHandcirclePoints = pointsOnCircle(150, 150, 95)
    secondHandEndPoint = circlePoints[0]

    secondHand = GRC.Line(secondHandEndPoint, clockCenter)
    gWindow.addItem(secondHand)
    gWindow.setBackground("Black")

    for tick in range(0, 360, 6):
        gWindow.plotPixel(circlePoints[tick].getX(), circlePoints[tick].getY(),
                          "Yellow")

    while (True):

        hour, minute, sec = getCurrentTime()
        if hour == 12:
            hour = 0
        hourHandEndPoint = HourHandcirclePoints[hour * 30]
        minuteHandEndPoint = minuteHandcirclePoints[minute * 6]
        secondHandEndPoint = circlePoints[sec * 6]

        hourHand = clockHand(hourHandEndPoint, 3, "red", clockCenter)
        MinuteHand = clockHand(minuteHandEndPoint, 2, "Blue", clockCenter)
        secondHand = clockHand(secondHandEndPoint, 1, "White", clockCenter)

        hourHand.draw(gWindow)
        secondHand.draw(gWindow)
        MinuteHand.draw(gWindow)

        message = GRC.Text(
            GRC.Point(150, 290),
            str(hour).zfill(2) + ":" + str(minute).zfill(2) + ":" +
            str(sec).zfill(2))
        message.setFillColor("Green")
        message.draw(gWindow)
        GRC.time.sleep(interval)

        message.undraw()
        hourHand.undraw()
        secondHand.undraw()
        MinuteHand.undraw()
def main():

    #win = GRC.GraphicsWindow("test", 500, 500)

    p1 = GRC.Point(10, 20)
    p2 = GRC.Point(10, 200)

    # myLine = GRC.Line(p1, p2)
    # myLine.draw(win)
    # calcPoints(p1,p2)
    points = get_line([10,10], [20,200])
    #print (points)
    for point in points:
        print (point)
        win.plot(point[0], round(point[1]), "Black")

    line = GRC.Line(p1,p2)
    win.addItem(line)
    win.redraw()
    win.waitForKeyPress()
예제 #7
0
def clockHand(endPoint, handWidth, handColor, clockCenter):
    hourHand = GRC.Line(endPoint, clockCenter)
    hourHand.setWidth(handWidth)
    hourHand.setFillColor(handColor)
    hourHand.setArrow("first")
    return hourHand
예제 #8
0
def drawLine(startPoint, endPoint):
    myLine = GRC.Line(startPoint, endPoint)
    win.addItem(myLine)
    GRC.time.sleep(interval)
    win.redraw()
    print(startPoint, endPoint)