From 8d02875e0f76fcde6d7bbd09af07e8c3f2c09e73 Mon Sep 17 00:00:00 2001 From: Stephen D <webmaster@scd31.com> Date: Fri, 21 Feb 2025 18:10:27 -0500 Subject: [PATCH] jess duck --- build.rs | 3 +-- src/assets/duck.png | Bin 0 -> 1075 bytes src/lib.rs | 43 +++---------------------------------------- 3 files changed, 4 insertions(+), 42 deletions(-) create mode 100644 src/assets/duck.png diff --git a/build.rs b/build.rs index 56ecea4..4aa57be 100644 --- a/build.rs +++ b/build.rs @@ -7,8 +7,7 @@ use image::{GenericImageView, ImageReader}; fn main() { println!("cargo::rerun-if-changed=build.rs"); - handle_image("cat"); - handle_image("meow"); + handle_image("duck"); } fn handle_image(name: &str) { diff --git a/src/assets/duck.png b/src/assets/duck.png new file mode 100644 index 0000000000000000000000000000000000000000..7d2c910310b2b6e1e2cf23cd640bd74780493a4c GIT binary patch literal 1075 zcmV-31kC%1P)<h;3K|Lk000e1NJLTq003YB001Tk0ssI2wEGDj0004lX+uL$Nkc;* zaB^>EX>4Tx04R}tkv&MmKpe$iQ>7vm2djuUWT;MdsYM)X6^c-y)C#RSm|Xe=O&XFE z7e~Rh;NZt%)xpJCR|i)?5c~jf7n~Gbq{ROvg%&X$9QWhhy~o`<KxkH(YWBndRkMst zG9l*jt77040){byC}I*b^|^F91<&zy4<BFeB0S6c+@E7WDVPlKiNtZH8y4{f@yw>B zbKWNov9hEPpA%0RbV1@ruFEdJaV|M5@XU~r&CC;rh{aMD%U#UMhDsbG4lAlg`9jWR zh4U6?wOVKGd-4|s3);#u*J+L;iA5|S4G}WxsGtf95n44;Ok`+3;o%>1{AqH@<f?#? zV*xd&kQ_hwAN=mtEKWz=q+kN*eX;G22_Ucwv>LYkeQevU6TtrrTxlJDtqIJ2lHTZO z;Ui#h8@RacX!0I#xdV(o>5?HilAoqfECTOm^i6qS=oaW-b9-y=<MaW@Qdg-P;NTFL zEK&Bl$GiKwd;9lHyT2a~QgY?dGL#Ge000SaNLh0L04^f{04^f|c%?sf00007bV*G` z2k8P87X<?yj|43M000?uMObu0Z*6U5Zgc=ca%Ew3Wn>_CX>@2HM@dakSAh-}0006W zNkl<ZXx{Bv%WlLl2wX@0|6g_w(IT(G7z5*7MfIs_(*VPGc%-z}UjJu)>NCP9rO?m0 zDZd_*>ed?KHeAo34?)vf>)CYlis5LSPNg2Q6AUV)+~^RE={LVDMu!;0v(aPp_#(K7 zP=|nM^%aivb~$mfyjsM+G$VRuWR`dxj0u~WNGG*sW-zAnrFUHkb*c0NYV=HRojZnO zaekvn$nsDvkqi&$aJz}01CXfATS)Ob=zx2ml^8#cMAfJimdq<&29-{4|I(X7Qy)~` z2Y0<Wt#lN0tU(ynr9(!;#*)`R<GZt>p_@bqjH<mev||D7jAnQFkOnQ2Fw;o4Qi>KM zugXQLTJo>AXXKU+?(DCQcp}|@v{4kX7@84_lt#7|#*S3aQx-;5S**;O5rss?#Og_Q z$9DfC33dubbvL~r?xeVZtzz7EJPG3DwXBj3bU1~xz^W<q*`gJwJb~tqX?e0s26`I$ z%GPPYpkX+S^lxXNaSZ)AqsCVD5=-pXdrt3zA`_Fo?)&`<B?Bb(gh6fI-5drXUan&E zM~$GR9&zK45zGf@-EoQ2W}-3bZeQ=uYIJf(e2_?AgC6(a2oY-vM0-u|M<`cCZ*bhJ zXk4m1R}6Z56TmJbuo`rRK91G>t^lX2bw#6N?1TA6h41r?pLyYBJ{=lMsNzm;_ipBH tf<A^-v??DETHfv+U6=(|9EVS$4}aL5RZ8}B@u~m-002ovPDHLkV1hmM<^%u$ literal 0 HcmV?d00001 diff --git a/src/lib.rs b/src/lib.rs index ada07ff..b4b5ad2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,51 +1,14 @@ -use bitvec::{order::Msb0, view::BitView}; - -const WIDTH: i32 = 96; -const HEIGHT: i32 = 38; - #[no_mangle] pub extern "C" fn next_frame(frame: u16, ptr: *mut u8) -> u8 { - let out = unsafe { std::slice::from_raw_parts_mut(ptr, 456) }.view_bits_mut::<Msb0>(); + let out = unsafe { std::slice::from_raw_parts_mut(ptr, 456) }; if frame > 100 { return 1; } - let cat = include_bytes!(concat!(env!("OUT_DIR"), "/cat.bin")).view_bits::<Msb0>(); - let meow = include_bytes!(concat!(env!("OUT_DIR"), "/meow.bin")).view_bits::<Msb0>(); - - let thres = WIDTH / 4; - - let dx = (frame as i32 * 4 - thres).min(thres); - - for x in 0..96 { - for y in 0..38 { - let out_idx = index(x, y); - let in_idx = index(x - dx, y); - - out.set(out_idx, cat[in_idx]); - } - } - - if dx == thres && frame / 7 % 2 == 0 { - // make meow flash on and off every 4 frames for the remaining time - - for x in 0..96 { - for y in 0..38 { - let idx = index(x, y); + let duck = include_bytes!(concat!(env!("OUT_DIR"), "/duck.bin")); - out.set(idx, meow[idx] || out[idx]); - } - } - } + out.copy_from_slice(duck); 0 } - -fn index(x: i32, y: i32) -> usize { - if x < 0 || y < 0 || x >= WIDTH || y >= HEIGHT { - return 0; - } - - x as usize + y as usize * WIDTH as usize -} -- GitLab