Beispiel #1
0
def paintTest():
    global canvas
    master = Tk()

    canvas_width = win_max_x
    canvas_height = win_max_y
    canvas = Canvas(master, width=win_max_x, height=win_max_y)
    canvas.pack()

    y = int(win_max_y / 2)
    #w.create_line(0, y, win_max_x, y, fill="#476042")
    img = PhotoImage(master=master, width=win_max_x, height=win_max_y)
    #img = w.create_image(0,0, state="normal")
    canvas.bind("<Button-1>", click)

    mainloop()
    return
    for x in range(0, win_max_x):
        for y in range(0, win_max_y):
            color = 128 + int(64 * sin(x * y / 16.0))
            drawColor = color_rgb(255, color, color)
            img.put(drawColor, (x, y))

    w.create_image((win_max_x / 2, win_max_y / 2), image=img, state="normal")
    #w.create_image((win_max_x/2, win_max_y/2), image=img, state="normal")

    mainloop()
    return

    WIDTH, HEIGHT = 640, 480

    window = Tk()
    canvas = Canvas(window, width=WIDTH, height=HEIGHT, bg="#000000")
    canvas.pack()
    img = PhotoImage(width=WIDTH, height=HEIGHT)
    canvas.add
    #canvas.create_image((WIDTH/2, HEIGHT/2), image=img, state="normal")

    for x in range(4 * WIDTH):
        y = int(HEIGHT / 2 + HEIGHT / 4 * sin(x / 80.0))
        img.put("#ffffff", (x // 4, y))

#win.getMouse()
    return

    img = Image.New('RGB', (255, 255), "black")  # create a new black image
    pixels = img.load()  # create the pixel map

    for i in range(img.size[0]):  # for every pixel:
        for j in range(img.size[1]):
            pixels[i, j] = (i, j, 100)  # set the colour accordingly

    img.show()

    return

    master = Tk()

    canvas = Canvas(master, width=win_max_x, height=win_max_y)
    canvas.pack()

    #img = PhotoImage(file="myimage.jpg")
    #canvas.create_image(20,20, anchor=NW, image=img)

    return

    #pixels = " ".join('#%02x%02x%02x')
    img = Image.new('RGB', (255, 255), "black")  # create a new black image
    pixels = img.load()  # create the pixel map

    for i in range(img.size[0]):  # for every pixel:
        for j in range(img.size[1]):
            pixels[i, j] = (i, j, 100)  # set the colour accordingly

    #img.Show(win)

    myImage = graphics.Image(pixels)
    myImage.draw(window)
Beispiel #2
0
from PIL import Image, ImageDraw

w, h = 600, 400

img = Image.new('RGB', (w, h), (241, 241, 241))

korea = Image.New('RGB', (h // 2, h // 2), color=(241, 241, 241))

draw = ImageDraw.Draw(korea)

draw.pieslice((0, 0, h // 2, h // 2), start=180, end=360, fill=(205, 49, 58))

draw.pieslice((0, 0, h // 2, h // 2), start=0, end=180, fill=(0, 71, 160))

draw.eclipse((0, h // 8, h // 4, h * 3 // 8), fill=(205, 49, 58))

draw.pieslice((h // 4, h // 8, h // 2, h * 3 // 8), fill=(205, 49, 58))

korea = korea.rotate(-33.69, fillcolor=(241, 241, 241))

img.paste(korea, (h // 2, h // 4))

sky = Image.New('RGB', (h // 4, h // 6), color=(14, 14, 14))

draw = ImageDraw.Draw(sky)

draw.rectangle((0, h * 2 // 48, h // 4, h * 3 // 48), fill=(241, 241, 241))

draw.rectangle((0, h * 5 // 48, h // 4, h * 6 // 48), fill=(241, 241, 241))

sky = sky.rotate(90 - 33.69, expand=True, fillcolor=(241, 241, 241))