New covers.
[librarian.git] / src / librarian / covers / widgets / base.py
diff --git a/src/librarian/covers/widgets/base.py b/src/librarian/covers/widgets/base.py
new file mode 100644 (file)
index 0000000..15e4462
--- /dev/null
@@ -0,0 +1,21 @@
+class Widget:
+    transparency = True
+    margin_top = 0
+
+    def __init__(self, cover):
+        self.cover = cover
+        self.setup()
+
+    def setup(self):
+        pass
+        
+    def build(self, w, h):
+        raise NotImplementedError()
+
+    def apply(self, img, x, y, w=None, h=None):
+        my_img = self.build(w, h)
+        img.paste(
+            my_img,
+            (round(x), round(y - self.margin_top)),
+            my_img if self.transparency else None
+        )