aboutsummaryrefslogtreecommitdiff
path: root/src/components/text.py
diff options
context:
space:
mode:
authortassaron2017-08-07 21:03:01 -0400
committertassaron2017-08-07 21:03:01 -0400
commit060a7dc2d263c0fd0e36e162943b8946df937bbd (patch)
tree46d08e9583b0bdda4c3e404fedb99cda367c4af9 /src/components/text.py
parent998f74149553ac7a9e27d7c85cebceda2ef32c64 (diff)
dropshadow option for Text component
Diffstat (limited to 'src/components/text.py')
-rw-r--r--src/components/text.py16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/components/text.py b/src/components/text.py
index f88f373..c50c812 100644
--- a/src/components/text.py
+++ b/src/components/text.py
@@ -1,4 +1,4 @@
-from PIL import Image, ImageDraw
+from PIL import ImageEnhance, ImageFilter, ImageChops
from PyQt5.QtGui import QColor, QFont
from PyQt5 import QtGui, QtCore, QtWidgets
import os
@@ -153,7 +153,19 @@ class Component(Component):
image.setFont(font)
image.setPen(self.textColor)
image.drawText(x, y, self.title)
- return image.finalize()
+
+ # turn QImage into Pillow frame
+ frame = image.finalize()
+ if self.shadow:
+ shadImg = ImageEnhance.Contrast(frame).enhance(0.0)
+ shadImg = shadImg.filter(ImageFilter.GaussianBlur(self.shadBlur))
+ shadImg = ImageChops.offset(shadImg, self.shadX, self.shadY)
+ shadImg.paste(frame, box=(0, 0), mask=frame)
+ frame = shadImg
+
+ return frame
+
+
def commandHelp(self):
print('Enter a string to use as centred white text:')