Uhm, foo.
This commit is contained in:
parent
93592ee439
commit
5453ec53e9
2 changed files with 17 additions and 6 deletions
|
|
@ -1,3 +1,4 @@
|
|||
import bdflib # Used to read the bitmap font
|
||||
|
||||
# Hard timeout in seconds after which (approximately) the rendering of a single item will be cut off
|
||||
RENDERER_TIMEOUT = 20.0
|
||||
|
|
@ -8,12 +9,18 @@ DEFAULT_SCROLL_SPEED = 4
|
|||
# Pixels to leave blank between two letters
|
||||
LETTER_SPACING = 1
|
||||
|
||||
FONT = bdflib.reader.read_bdf(open('fonts/5x8.bdf').readlines())
|
||||
FONT_WIDTH = 5
|
||||
|
||||
# Computed value
|
||||
FONT_PADDED_BINARY = ('{:0'+str(FONT_WIDTH+'b}').format
|
||||
|
||||
# Display geometry
|
||||
# ┌─────────┐ ┌──┬──┬──┬ ⋯ ┬──┬──┬──┐
|
||||
# │1 o o o 5│ │ 1│ │ │ │ │ │16│
|
||||
# │6 o o o o│ ├──┼──┼──┼ ⋯ ┼──┼──┼──┤
|
||||
# │o o o o o│ │17│ │ │ │ │ │32│
|
||||
# │o o o o20│ └──┴──┴──┴ ⋯ ┴──┴──┴──┘
|
||||
# ┌─────────┐ ┌───┬───┬ ⋯ ┬───┬───┐
|
||||
# │1 o o o 5│ │ 1 │ │ │ │16 │
|
||||
# │6 o o o o│ ├───┼───┼ ⋯ ┼───┼───┤
|
||||
# │o o o o o│ │17 │ │ │ │32 │
|
||||
# │o o o o20│ └───┴───┴ ⋯ ┴───┴───┘
|
||||
# └─────────┘
|
||||
CRATE_WIDTH = 5
|
||||
CRATE_HEIGHT = 4
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ except ImportError:
|
|||
import re
|
||||
from PIL import Image
|
||||
from pixelterm import xtermcolors
|
||||
from config import *
|
||||
|
||||
default_palette = [
|
||||
(0x00, 0x00, 0x00), # 0 normal colors
|
||||
|
|
@ -72,7 +73,10 @@ class CharGenerator:
|
|||
|
||||
def generate_char(self, c, now):
|
||||
fg, bg = self.bg, self.bg if self.blink and now%1.0 < 0.3 else self.fg, self.bg
|
||||
...
|
||||
glyph = font.glyphs_by_codepoint[c]
|
||||
# Please forgive the string manipulation below.
|
||||
lookup = {'0': bg, '1': fg}
|
||||
return [ list(map(lookup.get, FONT_PADDED_BINARY(int(row, 16)))) for row in glyph.get_data() ]
|
||||
|
||||
def generate(self, now):
|
||||
chars = [self.generate_char(c, now) for c in self.text]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue