forked from Freedom-3100/pythonProject
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimage.py
68 lines (61 loc) · 2.47 KB
/
image.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import pygame
from PIL import Image, ImageOps
import Stack_List_Queue
class Picture:
def __init__(self, PNG):
self.image = Image.open(PNG)
def rotate(self):
self.rotated_img = self.image.rotate(180)
self.rotated_img.save('rotated.png')
self.rotated_png = Image.open('rotated.png')
self.rotated_png.show()
def cut(self, x, y, hight, wigth):
self.new_picture = self.image.crop((x, y, hight, wigth))
self.new_picture.save('cut.png')
def show(self):
self.image.show()
def flip(self):
self.img = ImageOps.mirror(self.new_picture)
self.img.save('mirror.png')
def add_to_queue(self, value):
self.queue = Stack_List_Queue.Queue()
self.value = value
if self.value == "flip":
self.new_pictures = Picture(PNG='worms.png')
self.new_pictures.cut(35, 0, 64, 40)
self.new_pictures.flip()
self.new_picture_new = Image.open('mirror.png')
self.new_picture_new.save('mirror_1.png')
self.queue.push('mirror_1.png')
self.new_pictures.cut(65, 0, 95, 40)
self.new_pictures.flip()
self.new_picture_new = Image.open('mirror.png')
self.new_picture_new.save('mirror_2.png')
self.queue.push('mirror_2.png')
self.new_pictures.cut(0, 0, 32, 40)
self.new_pictures.flip()
self.new_picture_new = Image.open('mirror.png')
self.new_picture_new.save('mirror_3.png')
self.queue.push('mirror_3.png')
return self.queue
elif self.value == "cut":
self.new_pictures = Picture(PNG='worms.png')
self.new_pictures.cut(35, 0, 64, 40)
self.new_picture_new = Image.open('cut.png')
self.new_picture_new.save('cut_1.png')
self.queue.push('cut_1.png')
self.new_pictures.cut(65, 0, 94, 40)
self.new_picture_new = Image.open('cut.png')
self.new_picture_new.save('cut_2.png')
self.queue.push('cut_2.png')
self.new_pictures.cut(0, 0, 32, 40)
self.new_pictures.flip()
self.new_picture_new = Image.open('cut.png')
self.new_picture_new.save('cut_3.png')
self.queue.push('cut_3.png')
return self.queue
def go_queue(self, queue):
self.queue = queue
self.value = self.queue.pop()
self.queue.push(self.value)
return self.value