forked from myrlund/salabim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
imagetest.py
45 lines (37 loc) · 1.09 KB
/
imagetest.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
import PIL
from PIL import Image
from PIL import ImageDraw
from PIL import ImageFont
import math
radius=60
linewidth=0
fillcolor=(255,0,0,255)
nsteps = int(math.sqrt(radius) * 6)
tangle = 2 * math.pi / nsteps
sint = math.sin(tangle)
cost = math.cos(tangle)
p = []
x = radius
y = 0
for i in range(nsteps + 1):
x, y = (x * cost - y * sint, x * sint + y * cost)
p.append(x + radius + linewidth)
p.append(y + radius + linewidth)
image = Image.new('RGBA', (int(radius * 2 + 2 * linewidth),
int(radius * 2 + 2 * linewidth)), (0, 0, 0, 0))
print (type(image))
draw = ImageDraw.Draw(image)
if fillcolor[3] != 0:
draw.polygon(p, fill=fillcolor)
if (linewidth > 0) and (linecolor[3] != 0):
draw.line(p, fill=linecolor, width=int(linewidth))
del draw
image.save('1.png')
redimage=Image.open('red.png')
redimage=redimage.convert('RGBA')
blueimage=Image.open('blue.png')
blueimage=blueimage.convert('RGBA')
if (redimage,1) == (blueimage,1):
print('ok')
print (type(redimage))
print(isinstance(redimage,PIL.Image.Image))