Added help to README

This commit is contained in:
Roberto Alsina 2023-05-15 21:46:57 -03:00
parent 236353b555
commit 99cd270246
2 changed files with 29 additions and 11 deletions

View File

@ -12,6 +12,21 @@ This is based off code from [Tenprintcover](https://github.com/mgiraldo/tenprint
although I don't think anything survives of the original code, which has been ported although I don't think anything survives of the original code, which has been ported
to Pillow and de-c64-fied. to Pillow and de-c64-fied.
Usage:
```sh
$ python -m tapita --help
Usage: python -m tapita [OPTIONS]
Options:
-t, --title <title> Book title
-s, --subtitle <subtitle> Book subtitle
-a, --author <author> Book author
-o, --output <filename> Output file (- for stdout)
--help Show this message and exit.
```
Example usage: Example usage:
```sh ```sh

View File

@ -25,7 +25,7 @@ def _clip(value, lower, upper):
class Cover: class Cover:
def __init__(self, title, subtitle, author): def __init__(self, title, subtitle="", author=""):
self.title = title self.title = title
self.subtitle = subtitle self.subtitle = subtitle
self.author = author self.author = author
@ -49,8 +49,10 @@ class Cover:
) )
def _getFont(self, size): def _getFont(self, size):
return ImageFont.truetype(str(Path(__file__).parent / "HackNerdFont-Regular.ttf"), int(size)) return ImageFont.truetype(
str(Path(__file__).parent / "HackNerdFont-Regular.ttf"), int(size)
)
def _drawArtwork(self): def _drawArtwork(self):
artwork_start_x = 0 artwork_start_x = 0
artwork_start_y = self.cover_height - self.cover_width artwork_start_y = self.cover_height - self.cover_width
@ -101,14 +103,15 @@ class Cover:
subtitle_height = bbox[3] - bbox[1] subtitle_height = bbox[3] - bbox[1]
y = y + subtitle_height + 0.03 * self.cover_height y = y + subtitle_height + 0.03 * self.cover_height
bbox = self.image_draw.textbbox((x, y), self.author, font=author_font) if self.author:
author_height = bbox[3] - bbox[1] bbox = self.image_draw.textbbox((x, y), self.author, font=author_font)
self.image_draw.text( author_height = bbox[3] - bbox[1]
(x, self.cover_height * 0.97 - self.cover_width - author_height), self.image_draw.text(
self.author, (x, self.cover_height * 0.97 - self.cover_width - author_height),
font=author_font, self.author,
fill=self.foreground, font=author_font,
) fill=self.foreground,
)
def _processColors(self): def _processColors(self):
base_saturation = 100 base_saturation = 100