Skip to content

Commit

Permalink
sizing nyan to 80x25
Browse files Browse the repository at this point in the history
looking good
  • Loading branch information
diekmann committed Nov 24, 2024
1 parent 8d5f3ba commit b640ab6
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 9 deletions.
30 changes: 30 additions & 0 deletions nyan/parse.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env python3

import re
import sys

def parsecolor(line: str) -> str:
m = re.match(r'.*<TD +BGCOLOR=#(?P<rgb>[0-9a-f]*)>.*', line)
if not m:
raise Exception(f"did not parse: {line}")
return m['rgb']

assert(parsecolor('<TD BGCOLOR=#aabbcc>') == 'aabbcc')

with open(sys.argv[1], 'r') as f:
lines = f.readlines()

html = [parsecolor(line) for line in lines if 'BGCOLOR' in line]

translate = {
'000000': 'Black',
'0200ff': 'Blue',
'ff99ff': 'LightMagenta',
'999999': 'LightGray',
'ffcc99': 'Brown',
'ff9999': 'LightRed',
'ff3399': 'Magenta',
'ffffff': 'White'
}

print(", ".join([translate[rgb] for rgb in html]))
8 changes: 2 additions & 6 deletions nyan/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,10 @@ fn main() -> Status {
info!("supported mode {}: {} {}", m.index(), m.columns(), m.rows());
}

for (i, color) in nyan::NYAN_40X25.iter().enumerate() {
stdout.set_color(*color, background)?;
for color in nyan::NYAN_80X25 {
stdout.set_color(color, background)?;
let mut s = uefi::CString16::new();
s.push(BLOCKELEMENT_FULL_BLOCK);
if i % 40 == 0 {
s.push(CARRIAGE_RET);
s.push(NEWLINE);
}
stdout.output_string(&s)?;
}
Ok(())
Expand Down
4 changes: 3 additions & 1 deletion nyan/src/nyan.rs

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions putting_together/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,10 @@ But let me take a note for later:
The proportions of those two nyan cats look quite good.
The `BLOCKELEMENT_FULL_BLOCK` is not a perfect square.
When downsizing nyan cat, we assumed we are drawing it as pixels.
But `BLOCKELEMENT_FULL_BLOCK` **TODO**
But `BLOCKELEMENT_FULL_BLOCK` **TODO** 8x19 on qemu or 16x31 on my Thinkpad.
For simplicity, let's assume the ratio is 1:2.
**TODO** scale original image, without preserving aspect ratio to 80x25! 80x49 would be preserving aspect ratio.
Start over.
Can do animation while at it.

[back](../)
[back](../)

0 comments on commit b640ab6

Please sign in to comment.