+
+ def image(self):
+ img = super(LogoWLCover, self).image()
+ metr = Metric(self, self.scale)
+ if self.has_gradient_logos:
+ img = self.add_gradient_logos(img, metr)
+ return img
+
+
+class LegimiCover(LogoWLCover):
+ width = 210
+ height = 297
+ bar_width = 0
+ # Other bar
+
+ author_font_ttf = get_resource('fonts/Lora-Regular.ttf')
+ author_font_size = 15
+ author_lineskip = 19.5
+ author_centering = False
+ title_font_ttf = get_resource('fonts/Lora-Bold.ttf')
+ title_font_size = 15
+ title_lineskip = 19.5
+ title_centering = False
+
+ title_box_width = 210
+
+ box_bottom_margin = 20
+ box_padding_x = 20
+ box_padding_y = 10 # do baseline
+ box_above_line = 6
+ box_below_line = 0
+ box_line_left = 0
+ box_line_right = 0
+
+ box_line_width = 0
+
+ box_bar_width = 20
+
+ #logo_top = 15
+ #logo_width = 140
+
+ bar_color = '#000'
+ box_position = 'bottom'
+ background_color = '#444'
+ author_color = '#000'
+ title_color = '#000'
+ set_title_color = False
+
+ kind_box_position = {}
+
+ box_bottom_margin_logos_add = 10
+ gradient_height = 30
+ gradient_easing = 0
+ gradient_logo_height = 20
+ gradient_logo_max_width = 200
+ gradient_logo_margin_right = 10
+ gradient_logo_spacing = 20
+ gradient_color = '#000'
+ gradient_opacity = .5
+ gradient_logos = [
+ 'res/wl-logo-white.png',
+ ]
+ logos_right = False
+ gradient_logo_centering = True
+
+ genre_colors = {
+ 'Artykuł': '#bf001a',
+ 'Artykuł naukowy': '#bf001a',
+ 'Dziennik': '#bf001a',
+ 'Esej': '#bf001a',
+ 'Felieton': '#bf001a',
+ 'Kronika': '#bf001a',
+ 'List': '#bf001a',
+ 'Manifest': '#bf001a',
+ 'Odczyt': '#bf001a',
+ 'Pamiętnik': '#bf001a',
+ 'Poradnik': '#bf001a',
+ 'Praca naukowa': '#bf001a',
+ 'Publicystyka': '#bf001a',
+ 'Reportaż': '#bf001a',
+ 'Reportaż podróżniczy': '#bf001a',
+ 'Rozprawa': '#bf001a',
+ 'Rozprawa polityczna': '#bf001a',
+ 'Traktat': '#bf001a',
+ }
+ kind_colors = {
+ 'Epika': '#9bbb2b',
+ 'Liryka': '#3e626f',
+ 'Dramat': '#ecbe00',
+ }
+
+ def __init__(self, *args, **kwargs):
+ super().__init__(*args, **kwargs)
+ if self.has_gradient_logos:
+ self.box_bottom_margin += self.box_bottom_margin_logos_add
+
+ def pretty_authors(self):
+ return self.authors
+
+ def get_variable_color(self, book_info):
+ for genre in book_info.genres:
+ if genre in self.genre_colors:
+ return self.genre_colors[genre]
+ for kind in book_info.kinds:
+ if kind in self.kind_colors:
+ return self.kind_colors[kind]
+
+class LegimiCornerCover(LegimiCover):
+ gradient_logos = []
+ corner_width = 120
+ corner_image = get_resource('res/book-band.png')
+
+ def image(self):
+ image = super().image()
+ metr = Metric(self, self.scale)
+
+ if self.corner_image:
+ corner = Image.open(self.corner_image).convert('RGBA')
+ corner = corner.resize(
+ (
+ int(round(metr.corner_width)),
+ int(round(corner.size[1] / corner.size[0] * metr.corner_width))
+ )
+ )
+ image.paste(corner, (
+ metr.width - int(round(metr.corner_width)),
+ 0,
+ ), corner)
+ return image
+
+class LegimiAudiobookCover(LegimiCornerCover):
+ corner_width = 82.5
+ corner_image = get_resource('res/audiobook-sticker.png')
+ height = 210