Пример #1
0
def main():

    filepath = '.\\Content\\randomColors.pkle'

    #background1.draw(gWindow1)
    background2.draw(gWindow2)
    # gWindow1.redraw()
    # gWindow2.redraw()
    pixels = []

    for y in range(0, windowHeight - 3):
        for x in range(0, windowWidth):
            # red, green, blue = background1.getPixel(x,y)
            red = random.randint(0, 255)
            green = random.randint(0, 255)
            blue = random.randint(0, 255)

            rgb = color_rgb(red, green, blue)
            onePixel = pixel(x, y, rgb)
            pixels.append(onePixel)
            #print(onePixel.x,onePixel.y,onePixel.rgb)

            background2.setPixel(x, y, rgb)
            gWindow2.update()

            # print (y)
    print("pausing")
    Util.pause(gWindow2)
    print("saving")
    background2.save(".\\Content\\randomPixelsbackground3.png")
Пример #2
0
def main():
    windowWidth = 300
    windowHeight = 300

    Color = random.choice(Colors)
    gWindow = GRC.GraphicsWindow("Box", windowWidth, windowHeight)
    interval = .25
    #gWindow.setCoords(0, 0, 100, 100)
    # text = GRC.Text(GRC.Point(150, 50), "Centered Text")
    # text.setTextColor("Blue")
    # text.setSize(5)
    # gWindow.addItem(text)
    # for fontSize in range(5,25):
    #     text.setSize(fontSize)
    #     gWindow.redraw()
    #     GRC.time.sleep(interval)
    #
    # for fontSize in range(25, 8):
    #     text.setSize(fontSize)
    #     gWindow.redraw()
    #     GRC.time.sleep(interval)

    polygon1 = GRC.Polygon(GRC.Point(10, 10), GRC.Point(125, 10),
                           GRC.Point(125, 125), GRC.Point(10, 125))
    polygon1.draw(gWindow)
    Util.pause(gWindow)
Пример #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 TextScroll():

    scrollText = GRC.Text(GRC.Point(500, 290),
                          "Scroll Demo.... ABCDEFGHIJKLMNOPQRSTUVWXYZ")
    scrollText.setTextColor("Blue")
    scrollText.setFontSize(12)
    gWindow.addItem(scrollText)
    gWindow.update()

    for moveX in range(1, 700, 1):
        scrollText.move(-1, 0)
        gWindow.update()
        GRC.time.sleep(.01)

    Util.pause(gWindow)
Пример #5
0
def main():

    # background1.draw(gWindow1)
    background2.draw(gWindow1)
    # gWindow1.redraw()
    # gWindow2.redraw()
    pixels = []

    # for y in range(0,windowHeight -  3):
    #     for x in range (0,windowWidth):
    #         red, green, blue = background1.getPixel(x,y)
    #         rgb = color_rgb(red, green, blue)
    #         onePixel = pixel(x,y,rgb)
    #         pixels.append(onePixel)
    #         # print(onePixel.x,onePixel.y,onePixel.rgb)
    #         # Util.pause(gWindow2)
    #         # background2.setPixel(x, y, rgb)
    #         # print (y)

    # The first argument is a string containing the filename. The second argument is another string containing a few
    # characters describing the way in which the file will be used. mode can be 'r' when the file will only be read, 'w'
    # for only writing (an existing file with the same name will be erased), and 'a' opens the file for appending; any
    # data written to the file is automatically added to the end. 'r+' opens the file for both reading and writing. The
    # mode argument is optional; 'r' will be assumed if it’s omitted.

    # On Windows, 'b' appended to the mode opens the file in binary mode, so there are also modes like 'rb', 'wb', and
    # 'r+b'. Python on Windows makes a distinction between text and binary files; the end-of-line characters in text
    # files are automatically altered slightly when data is read or written. This behind-the-scenes modification to
    # file data is fine for ASCII text files, but it’ll corrupt binary data like that in JPEG or EXE files. Be very
    # careful to use binary mode when reading and writing such files. On Unix, it doesn’t hurt to append a 'b' to the
    # mode, so you can use it platform-independently for all binary files.

    file = open('.\\Content\\icecave.pkle', 'rb+')
    #json.dump(pixels, file)
    #pickle.dump(pixels, file)
    pixels2 = pickle.load(file)

    #pixels2 = json.dump(file)

    file.close()

    random.shuffle(pixels2)

    while len(pixels2) > 0:
        pix = pixels2.pop()
        background2.setPixel(pix.x, pix.y, pix.rgb)
        gWindow1.update()
    Util.pause(gWindow1)
Пример #6
0
Color = random.choice(Util.Colors)
gWindow1 = GRC.GraphicsWindow("Image Window-1", windowWidth, windowHeight)
background2 = GRC.Image(GRC.Point(251, 134), ".\\Content\\whitebackground.png")


def main():

    background2.draw(gWindow1)

    file = open('.\\Content\\icecave.pkle', 'rb+')
    pixels2 = pickle.load(file)
    file.close()

    random.shuffle(pixels2)

    while len(pixels2) > 0:
        pix = pixels2.pop()
        background2.setPixel(pix.x, pix.y, pix.rgb)
        gWindow1.update()


def color_rgb(r, g, b):
    """r,g,b are intensities of red, green, and blue in range(256)
    Returns color specifier string for the resulting color"""
    return "#%02x%02x%02x" % (r, g, b)


main()

Util.pause(gWindow1)
Пример #7
0
        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()


Util.pause(gWindow)


def clockHand(endPoint, handWidth, handColor, clockCenter):
    hourHand = GRC.Line(endPoint, clockCenter)
    hourHand.setWidth(handWidth)
    hourHand.setFillColor(handColor)
    hourHand.setArrow("first")
    return hourHand


def pointsOnCircle(x, y, radius):
    center = GRC.Point(x, y)
    center = [x, y]
    angles = []
    for angle in range(0, 360):
Пример #8
0
background1 = GRC.Image(GRC.Point(251, 134), ".\Content\\bwdock.png")
background2 = GRC.Image(GRC.Point(251, 134), ".\\Content\\blackbackground.png")


def main():

    background1.draw(gWindow1)
    background2.draw(gWindow2)
    gWindow1.redraw()
    gWindow2.redraw()

    for y in range(0, windowHeight - 5):
        for x in range(0, windowWidth - 5):
            red, green, blue = background1.getPixel(x, y)
            rgb = color_rgb(red, green, blue)
            background2.setPixel(x, y, rgb)

        gWindow2.redraw()


def color_rgb(r, g, b):
    """r,g,b are intensities of red, green, and blue in range(256)
    Returns color specifier string for the resulting color"""
    return "#%02x%02x%02x" % (r, g, b)


main()

Util.pause(gWindow2)