diff options
-rw-r--r-- | README.md | 11 | ||||
-rw-r--r-- | infohazard/Cargo.toml | 9 | ||||
-rw-r--r-- | infohazard/src/main.rs | 51 | ||||
-rw-r--r-- | slugs/Cargo.toml | 14 | ||||
-rw-r--r-- | slugs/readme.md | 34 | ||||
-rw-r--r-- | slugs/src/main.rs | 94 |
6 files changed, 1 insertions, 212 deletions
diff --git a/README.md b/README.md index f2b7fa9..623f6fa 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ These are part of the 89a spec, but are kept separate as they're not "core" to t - [x] Application Extension - [x] Comment Extension - [ ] Plain Text Extension -- [ ] Netscape Looping Extension ([details][netscape]) +- [x] Netscape Looping Extension ([details][netscape]) ### Relevant Writings @@ -44,14 +44,5 @@ Similar to FFMPEG's ffprobe, gifprobe will print details of a gif to stdout. ## gaudio Nothing valued is here. Inject/Retrieve MP3 files from GiFs. I'd like to eventually play them right outta the thing, right, but that's a lot harder. -## TODO: theft -gif tool for weird gif things. -just the place i put things -that have nowhere else to go -so i stop making so many -weird little projects here - -eventually i think it will absorb gaudio - # License gifed, gifprobe, and gaudio are licensed under Creative Commons Zero 1.0; they're in the public domain. Attribution is appreciated, but not required. diff --git a/infohazard/Cargo.toml b/infohazard/Cargo.toml deleted file mode 100644 index bc3e269..0000000 --- a/infohazard/Cargo.toml +++ /dev/null @@ -1,9 +0,0 @@ -[package] -name = "infohazard" -version = "0.1.0" -edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -gifed = { path = "../gifed" } \ No newline at end of file diff --git a/infohazard/src/main.rs b/infohazard/src/main.rs deleted file mode 100644 index 8ed6c8f..0000000 --- a/infohazard/src/main.rs +++ /dev/null @@ -1,51 +0,0 @@ -use std::fs::File; - -use gifed::{ - block::{LoopCount, Palette}, - writer::{GifBuilder, ImageBuilder, Writer}, -}; - -fn main() { - let black = vec![0; 35]; - let red = vec![1; 35]; - - let mut horiz = black.clone(); - for _ in 0..(34 / 2) { - horiz.extend(&red); - horiz.extend(&black); - } - - let mut row = vec![0]; - row.extend([2, 0].repeat(34 / 2)); - - let vert = row.repeat(35); - - let file = File::create("infohazard.gif").unwrap(); - let mut writer = Writer::new( - file, - 35, - 35, - Some(Palette::try_from([0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 0].as_slice()).unwrap()), - ) - .unwrap(); - - writer.repeat(LoopCount::Forever).unwrap(); - writer - .image(ImageBuilder::new(35, 35).delay(16).build(horiz).unwrap()) - .unwrap(); - writer - .image(ImageBuilder::new(35, 35).delay(16).build(vert).unwrap()) - .unwrap(); - writer.done().unwrap(); - - /* - GifBuilder::new(35, 35) - .palette(Palette::try_from([0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 0].as_slice()).unwrap()) - .repeat(LoopCount::Forever) - .image(ImageBuilder::new(35, 35).delay(16).build(horiz).unwrap()) - .image(ImageBuilder::new(35, 35).delay(16).build(vert).unwrap()) - .build() - .unwrap() - .save("infohazard.gif") - .unwrap()*/ -} diff --git a/slugs/Cargo.toml b/slugs/Cargo.toml deleted file mode 100644 index ba4dac2..0000000 --- a/slugs/Cargo.toml +++ /dev/null @@ -1,14 +0,0 @@ -[package] -name = "slugs" -version = "0.1.0" -edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -camino = "1.1.2" -gifed = { path = "../gifed" } -png = "0.17.7" -tepimg = { git = "https://github.com/gennyble/tep" } -thiserror = "1.0.38" -colorsquash = { path = "../../colorsquash" } \ No newline at end of file diff --git a/slugs/readme.md b/slugs/readme.md deleted file mode 100644 index 72a47ca..0000000 --- a/slugs/readme.md +++ /dev/null @@ -1,34 +0,0 @@ -# slugs -**s**mall, **l**ittle **g**id builder. (but with a u before the l an an s after the g so it's slugs 🥺) - -usage: `slugs <directory>` - -where directory looks something like this: -directory -├ manifest.conf -├ palette -├ frame1.tep -├ frame2.tep -├ frame3.tep - -and manifest.conf looking like: -``` -Width 8 -Height 16 -Palette palette -Delay 1 - -Frame frame1.tep -Frame frame2.tep - Delay 2 -Frame frame3.tep -``` - -```kdl -gif width=16 height=16 delay=4 { - palette "palette" - image "frame1.tep" - image "frame2.tep" delay=2 - image "frame3.tep" -} -``` \ No newline at end of file diff --git a/slugs/src/main.rs b/slugs/src/main.rs deleted file mode 100644 index bdf936e..0000000 --- a/slugs/src/main.rs +++ /dev/null @@ -1,94 +0,0 @@ -use std::fs::File; - -use camino::{Utf8Path, Utf8PathBuf}; -use colorsquash::{ColorCollector, Squasher}; -use gifed::{ - block::{extension::DisposalMethod, Palette}, - writer::{ImageBuilder, Writer}, - Color, -}; - -fn main() { - let base = Utf8PathBuf::from("/Users/gen/microglass-transfer/transcube"); - let mut collector = ColorCollector::new(); - - let mut imgs = vec![]; - for idx in 1..=120 { - let img = load_and_rgb(base.join(format!("{idx:04}.png"))); - collector.add(&img.b); - imgs.push(img); - } - - let squash: Squasher<u8> = collector.as_squasher(255); - let pal = squash.palette(); - let trans_idx = pal - .iter() - .enumerate() - .find(|(_idx, rgb)| rgb[0] == 0 && rgb[1] == 0 && rgb[2] == 0) - .unwrap() - .0; - - let mut palette = Palette::new(); - for c in pal { - palette.push(Color::new(c[0], c[1], c[2])); - } - println!("{}", palette.len()); - - let f = File::create(base.join("transcube.gif")).unwrap(); - let mut write = Writer::new(f, imgs[0].w as u16, imgs[1].h as u16, Some(palette)).unwrap(); - - for img in imgs { - let mut buf = vec![0; img.w as usize * img.h as usize]; - squash.map_unsafe(&img.b, &mut buf); - let img = ImageBuilder::new(img.w as u16, img.h as u16) - .transparent_index(Some(trans_idx as u8)) - .delay(3) - .disposal_method(DisposalMethod::RestoreBackground) - .build(buf) - .unwrap(); - - write.image(img).unwrap(); - } - - write.repeat(gifed::block::LoopCount::Forever).unwrap(); - write.done().unwrap(); -} - -pub fn load_and_rgb<P: AsRef<Utf8Path>>(path: P) -> Img { - let decoder = png::Decoder::new(File::open(path.as_ref()).unwrap()); - let mut reader = decoder.read_info().unwrap(); - let mut b = vec![0; reader.output_buffer_size()]; - let info = reader.next_frame(&mut b).unwrap(); - - let b = (&b[..info.buffer_size()]).to_owned(); - - Img { - b: rgba_replace_a(b, (0, 0, 0), 128), - w: info.width, - h: info.height, - } -} - -pub fn rgba_replace_a(buf: Vec<u8>, repl: (u8, u8, u8), tol: u8) -> Vec<u8> { - let mut r = vec![0; (buf.len() / 4) * 3]; - - for (idx, px) in buf.chunks(4).enumerate() { - if px[3] >= tol { - r[idx * 3] = px[0]; - r[idx * 3 + 1] = px[1]; - r[idx * 3 + 2] = px[2]; - } else { - r[idx * 3] = repl.0; - r[idx * 3 + 1] = repl.1; - r[idx * 3 + 2] = repl.2; - } - } - - r -} - -pub struct Img { - b: Vec<u8>, - w: u32, - h: u32, -} |