-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
76 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
source "https://rubygems.org" | ||
|
||
gem "live" | ||
gem "lively", path: "../../" | ||
|
||
gem "activerecord", "~> 7.1" | ||
gem "sqlite3", "~> 1.4" | ||
gem "markly" | ||
|
||
gem "base64" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
require 'zlib' | ||
|
||
module PNG | ||
def self.greyscale(width, height, data) | ||
# PNG file signature | ||
png_signature = "\x89PNG\r\n\x1a\n".b | ||
|
||
# IHDR chunk | ||
bit_depth = 8 # 8 bits per pixel | ||
color_type = 0 # Greyscale | ||
compression_method = 0 | ||
filter_method = 0 | ||
interlace_method = 0 | ||
|
||
ihdr_data = [width, height, bit_depth, color_type, compression_method, filter_method, interlace_method].pack('N2C5') | ||
ihdr_crc = Zlib.crc32("IHDR" + ihdr_data) | ||
ihdr_chunk = [ihdr_data.bytesize].pack('N') + "IHDR" + ihdr_data + [ihdr_crc].pack('N') | ||
|
||
# IDAT chunk | ||
raw_data = "" | ||
height.times do |y| | ||
row = data.get_string(y * width, width) | ||
raw_data << "\x00" + row | ||
end | ||
|
||
# Compress data with no compression (just to fit PNG structure) | ||
compressed_data = Zlib::Deflate.deflate(raw_data, Zlib::NO_COMPRESSION) | ||
idat_crc = Zlib.crc32("IDAT" + compressed_data) | ||
idat_chunk = [compressed_data.bytesize].pack('N') + "IDAT" + compressed_data + [idat_crc].pack('N') | ||
|
||
# IEND chunk | ||
iend_crc = Zlib.crc32("IEND") | ||
iend_chunk = [0].pack('N') + "IEND" + [iend_crc].pack('N') | ||
|
||
# Combine all parts into the final PNG | ||
return png_signature + ihdr_chunk + idat_chunk + iend_chunk | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* Center the table in the page */ | ||
|
||
body { | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
height: 100vh; | ||
margin: 0; | ||
} | ||
|
||
/* Make a table display as a regular size 10px x 10px per cell */ | ||
|
||
table { | ||
border-collapse: collapse; | ||
border-spacing: 0; | ||
} | ||
|
||
td { | ||
width: 2rem; | ||
height: 2rem; | ||
padding: 0; | ||
margin: 0; | ||
border: 1px solid black; | ||
|
||
/* Center the character in the cell */ | ||
text-align: center; | ||
vertical-align: middle; | ||
} |