1 # This file is part of Librarian, licensed under GNU Affero GPLv3 or later.
2 # Copyright © Fundacja Wolne Lektury. See NOTICE for more information.
5 from .base import Widget
8 class Marquise(Widget):
11 def __init__(self, cover, edge_top):
12 self.edge_top = edge_top
13 super().__init__(cover)
16 self.slope_w = self.cover.m.width / self.segments / 2
17 self.segment_h = self.cover.m.margin
18 self.title_box_position = (
20 self.cover.m.title_box_top
23 def get_points(self, w):
24 tip_y = self.edge_top + self.segment_h
30 for i in range(self.segments - 1, 0, -1):
32 ((2 * i + 1) * self.slope_w, self.edge_top),
33 (2 * i * self.slope_w, tip_y)
36 (self.slope_w, self.edge_top),
41 def build(self, w, h):
42 img = PIL.Image.new('RGBA', (
43 round(w), round(self.edge_top + self.segment_h)
45 draw = PIL.ImageDraw.ImageDraw(img)
47 self.get_points(w), fill=self.cover.color_scheme['rgb'])