-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathpython_gauge.py
More file actions
27 lines (20 loc) · 752 Bytes
/
Copy pathpython_gauge.py
File metadata and controls
27 lines (20 loc) · 752 Bytes
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
"""
Copyright (C) 2018 FireEye, Inc., created by Andrew Shay. All Rights Reserved.
"""
import PIL
from PIL import Image
percent = 70 # Percent for gauge
output_file_name = 'new_gauge.png'
# X and Y coordinates of the center bottom of the needle starting from the top left corner
# of the image
x = 825
y = 825
loc = (x, y)
percent = percent / 100
rotation = 180 * percent # 180 degrees because the gauge is half a circle
rotation = 90 - rotation # Factor in the needle graphic pointing to 50 (90 degrees)
dial = Image.open('needle.png')
dial = dial.rotate(rotation, resample=PIL.Image.BICUBIC, center=loc) # Rotate needle
gauge = Image.open('gauge.png')
gauge.paste(dial, mask=dial) # Paste needle onto gauge
gauge.save(output_file_name)