about summary refs log tree commit diff
path: root/infohazard/src/main.rs
blob: 8ed6c8f3e1d6d4319ae214f1e23b6adc1e1e6bbe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
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()*/
}