Add fancy new easter egg drawings
Drawn by Lilith, Sina, and myself.
BIN
showbits-assets/data/egg/cover_00.png
Normal file
|
After Width: | Height: | Size: 20 KiB |
BIN
showbits-assets/data/egg/cover_01.png
Normal file
|
After Width: | Height: | Size: 20 KiB |
BIN
showbits-assets/data/egg/cover_02.png
Normal file
|
After Width: | Height: | Size: 24 KiB |
BIN
showbits-assets/data/egg/cover_03.png
Normal file
|
After Width: | Height: | Size: 27 KiB |
BIN
showbits-assets/data/egg/cover_04.png
Normal file
|
After Width: | Height: | Size: 25 KiB |
BIN
showbits-assets/data/egg/cover_05.png
Normal file
|
After Width: | Height: | Size: 30 KiB |
BIN
showbits-assets/data/egg/cover_06.png
Normal file
|
After Width: | Height: | Size: 63 KiB |
BIN
showbits-assets/data/egg/ei.kra
Normal file
BIN
showbits-assets/data/egg/pattern_00.png
Normal file
|
After Width: | Height: | Size: 4.2 KiB |
BIN
showbits-assets/data/egg/pattern_01.png
Normal file
|
After Width: | Height: | Size: 7.2 KiB |
BIN
showbits-assets/data/egg/pattern_02.png
Normal file
|
After Width: | Height: | Size: 8.8 KiB |
BIN
showbits-assets/data/egg/pattern_03.png
Normal file
|
After Width: | Height: | Size: 8.6 KiB |
BIN
showbits-assets/data/egg/pattern_04.png
Normal file
|
After Width: | Height: | Size: 12 KiB |
BIN
showbits-assets/data/egg/pattern_05.png
Normal file
|
After Width: | Height: | Size: 8.1 KiB |
BIN
showbits-assets/data/egg/pattern_06.png
Normal file
|
After Width: | Height: | Size: 16 KiB |
BIN
showbits-assets/data/egg/pattern_07.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
showbits-assets/data/egg/pattern_08.png
Normal file
|
After Width: | Height: | Size: 9.5 KiB |
BIN
showbits-assets/data/egg/pattern_09.png
Normal file
|
After Width: | Height: | Size: 7.6 KiB |
BIN
showbits-assets/data/egg/pattern_10.png
Normal file
|
After Width: | Height: | Size: 13 KiB |
BIN
showbits-assets/data/egg/pattern_11.png
Normal file
|
After Width: | Height: | Size: 13 KiB |
BIN
showbits-assets/data/egg/pattern_12.png
Normal file
|
After Width: | Height: | Size: 14 KiB |
BIN
showbits-assets/data/egg/pattern_13.png
Normal file
|
After Width: | Height: | Size: 13 KiB |
BIN
showbits-assets/data/egg/pattern_14.png
Normal file
|
After Width: | Height: | Size: 9.7 KiB |
BIN
showbits-assets/data/egg/pattern_15.png
Normal file
|
After Width: | Height: | Size: 6.3 KiB |
BIN
showbits-assets/data/egg/pattern_16.png
Normal file
|
After Width: | Height: | Size: 9.6 KiB |
BIN
showbits-assets/data/egg/pattern_17.png
Normal file
|
After Width: | Height: | Size: 14 KiB |
BIN
showbits-assets/data/egg/pattern_18.png
Normal file
|
After Width: | Height: | Size: 12 KiB |
BIN
showbits-assets/data/egg/pattern_19.png
Normal file
|
After Width: | Height: | Size: 6.5 KiB |
BIN
showbits-assets/data/egg/pattern_20.png
Normal file
|
After Width: | Height: | Size: 14 KiB |
BIN
showbits-assets/data/egg/pattern_21.png
Normal file
|
After Width: | Height: | Size: 8 KiB |
BIN
showbits-assets/data/egg/pattern_22.png
Normal file
|
After Width: | Height: | Size: 7.6 KiB |
BIN
showbits-assets/data/egg/pattern_23.png
Normal file
|
After Width: | Height: | Size: 8.6 KiB |
BIN
showbits-assets/data/egg/pattern_24.png
Normal file
|
After Width: | Height: | Size: 14 KiB |
BIN
showbits-assets/data/egg/pattern_25.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
showbits-assets/data/egg/pattern_26.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
showbits-assets/data/egg/pattern_27.png
Normal file
|
After Width: | Height: | Size: 15 KiB |
BIN
showbits-assets/data/egg/pattern_28.png
Normal file
|
After Width: | Height: | Size: 9.6 KiB |
BIN
showbits-assets/data/egg/pattern_29.png
Normal file
|
After Width: | Height: | Size: 13 KiB |
BIN
showbits-assets/data/egg/pattern_30.png
Normal file
|
After Width: | Height: | Size: 13 KiB |
BIN
showbits-assets/data/egg/pattern_31.png
Normal file
|
After Width: | Height: | Size: 10 KiB |
BIN
showbits-assets/data/egg/pattern_32.png
Normal file
|
After Width: | Height: | Size: 12 KiB |
BIN
showbits-assets/data/egg/pattern_33.png
Normal file
|
After Width: | Height: | Size: 9.1 KiB |
BIN
showbits-assets/data/egg/pattern_34.png
Normal file
|
After Width: | Height: | Size: 7.4 KiB |
BIN
showbits-assets/data/egg/pattern_35.png
Normal file
|
After Width: | Height: | Size: 9.3 KiB |
BIN
showbits-assets/data/egg/pattern_36.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
showbits-assets/data/egg/pattern_37.png
Normal file
|
After Width: | Height: | Size: 12 KiB |
BIN
showbits-assets/data/egg/pattern_38.png
Normal file
|
After Width: | Height: | Size: 9.3 KiB |
BIN
showbits-assets/data/egg/pattern_39.png
Normal file
|
After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 3.3 KiB |
|
Before Width: | Height: | Size: 673 B After Width: | Height: | Size: 673 B |
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 694 B After Width: | Height: | Size: 694 B |
|
Before Width: | Height: | Size: 901 B After Width: | Height: | Size: 901 B |
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB |
|
|
@ -4,13 +4,65 @@ pub const UNIFONT_UPPER: &[u8] = include_bytes!("../data/unifont_upper-15.1.05.o
|
|||
pub const UNIFONT_NAME: &str = "Unifont";
|
||||
pub const UNIFONT_SIZE: f32 = 16.0;
|
||||
|
||||
pub const EGG_COVER: &[u8] = include_bytes!("../data/egg_cover.png");
|
||||
pub const EGG_PATTERNS: &[&[u8]] = &[
|
||||
include_bytes!("../data/egg_pattern_0.png"),
|
||||
include_bytes!("../data/egg_pattern_1.png"),
|
||||
include_bytes!("../data/egg_pattern_2.png"),
|
||||
include_bytes!("../data/egg_pattern_3.png"),
|
||||
include_bytes!("../data/egg_pattern_4.png"),
|
||||
include_bytes!("../data/egg_pattern_5.png"),
|
||||
include_bytes!("../data/egg_pattern_6.png"),
|
||||
pub const EGG_BAD_COVERS: &[&[u8]] = &[include_bytes!("../data/egg_bad/cover_00.png")];
|
||||
pub const EGG_BAD_PATTERNS: &[&[u8]] = &[
|
||||
include_bytes!("../data/egg_bad/pattern_00.png"),
|
||||
include_bytes!("../data/egg_bad/pattern_01.png"),
|
||||
include_bytes!("../data/egg_bad/pattern_02.png"),
|
||||
include_bytes!("../data/egg_bad/pattern_03.png"),
|
||||
include_bytes!("../data/egg_bad/pattern_04.png"),
|
||||
include_bytes!("../data/egg_bad/pattern_05.png"),
|
||||
include_bytes!("../data/egg_bad/pattern_06.png"),
|
||||
];
|
||||
|
||||
pub const EGG_COVERS: &[&[u8]] = &[
|
||||
include_bytes!("../data/egg/cover_00.png"),
|
||||
include_bytes!("../data/egg/cover_01.png"),
|
||||
include_bytes!("../data/egg/cover_02.png"),
|
||||
include_bytes!("../data/egg/cover_03.png"),
|
||||
include_bytes!("../data/egg/cover_04.png"),
|
||||
include_bytes!("../data/egg/cover_05.png"),
|
||||
include_bytes!("../data/egg/cover_06.png"),
|
||||
];
|
||||
pub const EGG_PATTERNS: &[&[u8]] = &[
|
||||
include_bytes!("../data/egg/pattern_00.png"),
|
||||
include_bytes!("../data/egg/pattern_01.png"),
|
||||
include_bytes!("../data/egg/pattern_02.png"),
|
||||
include_bytes!("../data/egg/pattern_03.png"),
|
||||
include_bytes!("../data/egg/pattern_04.png"),
|
||||
include_bytes!("../data/egg/pattern_05.png"),
|
||||
include_bytes!("../data/egg/pattern_06.png"),
|
||||
include_bytes!("../data/egg/pattern_07.png"),
|
||||
include_bytes!("../data/egg/pattern_08.png"),
|
||||
include_bytes!("../data/egg/pattern_09.png"),
|
||||
include_bytes!("../data/egg/pattern_10.png"),
|
||||
include_bytes!("../data/egg/pattern_11.png"),
|
||||
include_bytes!("../data/egg/pattern_12.png"),
|
||||
include_bytes!("../data/egg/pattern_13.png"),
|
||||
include_bytes!("../data/egg/pattern_14.png"),
|
||||
include_bytes!("../data/egg/pattern_15.png"),
|
||||
include_bytes!("../data/egg/pattern_16.png"),
|
||||
include_bytes!("../data/egg/pattern_17.png"),
|
||||
include_bytes!("../data/egg/pattern_18.png"),
|
||||
include_bytes!("../data/egg/pattern_19.png"),
|
||||
include_bytes!("../data/egg/pattern_20.png"),
|
||||
include_bytes!("../data/egg/pattern_21.png"),
|
||||
include_bytes!("../data/egg/pattern_22.png"),
|
||||
include_bytes!("../data/egg/pattern_23.png"),
|
||||
include_bytes!("../data/egg/pattern_24.png"),
|
||||
include_bytes!("../data/egg/pattern_25.png"),
|
||||
include_bytes!("../data/egg/pattern_26.png"),
|
||||
include_bytes!("../data/egg/pattern_27.png"),
|
||||
include_bytes!("../data/egg/pattern_28.png"),
|
||||
include_bytes!("../data/egg/pattern_29.png"),
|
||||
include_bytes!("../data/egg/pattern_30.png"),
|
||||
include_bytes!("../data/egg/pattern_31.png"),
|
||||
include_bytes!("../data/egg/pattern_32.png"),
|
||||
include_bytes!("../data/egg/pattern_33.png"),
|
||||
include_bytes!("../data/egg/pattern_34.png"),
|
||||
include_bytes!("../data/egg/pattern_35.png"),
|
||||
include_bytes!("../data/egg/pattern_36.png"),
|
||||
include_bytes!("../data/egg/pattern_37.png"),
|
||||
include_bytes!("../data/egg/pattern_38.png"),
|
||||
include_bytes!("../data/egg/pattern_39.png"),
|
||||
];
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use image::{imageops, RgbaImage};
|
||||
use rand::Rng;
|
||||
use showbits_assets::{EGG_COVER, EGG_PATTERNS};
|
||||
use rand::{seq::SliceRandom, Rng};
|
||||
use showbits_assets::{EGG_BAD_COVERS, EGG_BAD_PATTERNS, EGG_COVERS, EGG_PATTERNS};
|
||||
use showbits_common::{
|
||||
color::{self, WHITE},
|
||||
widgets::{Image, Text},
|
||||
|
|
@ -14,29 +14,44 @@ use super::{Context, Drawing};
|
|||
|
||||
pub struct EggDrawing;
|
||||
|
||||
fn load_image(bytes: &[u8]) -> anyhow::Result<RgbaImage> {
|
||||
Ok(image::load_from_memory(bytes)?.into_rgba8())
|
||||
fn load_image(bytes: &[u8]) -> RgbaImage {
|
||||
image::load_from_memory(bytes)
|
||||
.expect("malformed image data")
|
||||
.into_rgba8()
|
||||
}
|
||||
|
||||
impl Drawing for EggDrawing {
|
||||
fn draw(&self, printer: &mut Printer, ctx: &mut Context) -> anyhow::Result<()> {
|
||||
// Load image data from memory
|
||||
let cover = load_image(EGG_COVER)?;
|
||||
let mut patterns = vec![];
|
||||
for pattern in EGG_PATTERNS {
|
||||
patterns.push(load_image(pattern)?);
|
||||
}
|
||||
let mut rng = rand::thread_rng();
|
||||
|
||||
// Prepare egg image
|
||||
// Choose which set of egg images to use
|
||||
let bad_egg = rng.gen_range(0..16) == 0;
|
||||
let (covers, patterns) = if bad_egg {
|
||||
(EGG_BAD_COVERS, EGG_BAD_PATTERNS)
|
||||
} else {
|
||||
(EGG_COVERS, EGG_PATTERNS)
|
||||
};
|
||||
|
||||
// Load images from memory
|
||||
let covers = covers.iter().map(|img| load_image(img)).collect::<Vec<_>>();
|
||||
let patterns = patterns
|
||||
.iter()
|
||||
.map(|img| load_image(img))
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
// Choose a random cover
|
||||
let cover = covers.choose(&mut rng).expect("too few covers");
|
||||
|
||||
// Prepare image of appropriate size
|
||||
let mut image =
|
||||
RgbaImage::from_pixel(cover.width(), cover.height(), color::to_image_color(WHITE));
|
||||
|
||||
// Draw patterns onto egg
|
||||
let mut last_idx = None;
|
||||
let mut y = rand::thread_rng().gen_range(-100_i64..0);
|
||||
let mut y = rng.gen_range(-100_i64..0);
|
||||
while y < image.height().into() {
|
||||
let idx = loop {
|
||||
let idx = rand::thread_rng().gen_range(0..patterns.len());
|
||||
let idx = rng.gen_range(0..patterns.len());
|
||||
if Some(idx) != last_idx {
|
||||
break idx;
|
||||
}
|
||||
|
|
@ -49,7 +64,7 @@ impl Drawing for EggDrawing {
|
|||
}
|
||||
|
||||
// Finally, draw the cover
|
||||
imageops::overlay(&mut image, &cover, 0, 0);
|
||||
imageops::overlay(&mut image, cover, 0, 0);
|
||||
|
||||
let mut tree = Tree::<Context>::new(WHITE);
|
||||
|
||||
|
|
|
|||