-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
overlay roster picture display and other stuff (#173)
* random improvements * random improvements * update dependencies, load images * basic rpd page * retry if request fails * little refactor * basic implementation of all rpd features. other random changes lost track of * remove unnecessary images * add ellipses when truncating text * equally spaced cards in rpd, preferring arrangement of 4s and 3s * remove animation of time and state graphic in game * remove animation of time and state graphic in game * small refactor, new rpd textures, better network performance * updated graphics, placement and text fitting, improved code readability, sponsor, member pictures * revert gid and tid, remove background image * resolve cargo.lock merge conflict * tournament logo changes from upstream * prefetch next game data * clippy * new api for team data * clippy * more clippy * separate uwhscores and uwhportal links * Misc improvements and react changes to tournament ID * make network calls concurrent * Skip sections of rpd when no data is present, Fix quotes in text, Correct role logic * skip rpd section if there are no images to display * cargo clippy * fetch next game data if tid changes * typo * reduce height of each row in roster list by 2 pixels * show old game's results if is_old_game is still true * show old game's results if is_old_game is still true * fix issues with game data caching and reacting to tid changes * restore lock file * improve some variable naming * check for updates to `next_game_number` each snapshot * don't invalidate cache * Only request the same information once --------- Co-authored-by: Tristan Debrunner <tdebrunner@atlantissports.org>
- Loading branch information
1 parent
129a531
commit f0f88fd
Showing
84 changed files
with
3,947 additions
and
1,465 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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
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,21 @@ | ||
# AlphaGen | ||
|
||
AlphaGen is a small Rust application used to generate greyscale mask images based on the alpha channel of an image. It takes input image files and an output directory as command-line arguments and processes the images in parallel to generate greyscale mask images. | ||
|
||
## Usage | ||
|
||
```shell | ||
alphagen input_file(s) output_directory | ||
``` | ||
|
||
### Installation | ||
|
||
To use AlphaGen, you need to have Rust and Cargo installed. If you don't have them installed, you can follow the official Rust installation guide: https://www.rust-lang.org/tools/install | ||
|
||
Once Rust is installed, you can clone the project repository and navigate to the project directory: | ||
|
||
```shell | ||
git clone <repository-url> | ||
cd alphagen | ||
cargo install --path . | ||
``` |
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,51 @@ | ||
use image::io::Reader; | ||
use image::GenericImageView; | ||
use image::ImageFormat; | ||
use rayon::iter::ParallelBridge; | ||
use rayon::iter::ParallelIterator; | ||
use std::fs; | ||
use std::io::BufWriter; | ||
use std::io::Cursor; | ||
use std::path::PathBuf; | ||
|
||
/// Processes all files in `paths` and writes output images to `dir_output` | ||
pub fn on_paths(paths: Vec<&PathBuf>, dir_output: PathBuf) { | ||
paths.iter().par_bridge().for_each(|path| { | ||
let file = image::open(path).unwrap(); | ||
let mut output_image_buff = image::GrayAlphaImage::new(file.width(), file.height()); | ||
let mut pixs = output_image_buff.pixels_mut(); | ||
let mut file_out = fs::File::create(dir_output.join(path.file_name().unwrap())) | ||
.expect("Couldn't create output file"); | ||
for (_, _, alpha_channel) in file.pixels() { | ||
let p = pixs.next().unwrap(); | ||
p.0[0] = alpha_channel[3]; | ||
p.0[1] = alpha_channel[3]; | ||
} | ||
output_image_buff | ||
.write_to(&mut file_out, image::ImageFormat::Png) | ||
.unwrap_or_else(|_| { | ||
panic!( | ||
"Couldn't write to output directory {}/{:?}", | ||
dir_output.display(), | ||
path.file_name().unwrap_or_default() | ||
) | ||
}); | ||
}); | ||
} | ||
|
||
/// Process raw image data | ||
pub fn on_raw(input: &[u8]) -> Result<Vec<u8>, Box<dyn std::error::Error>> { | ||
let img_in = Reader::new(Cursor::new(input)) | ||
.with_guessed_format()? | ||
.decode()?; | ||
let mut img_out = image::GrayAlphaImage::new(img_in.width(), img_in.height()); | ||
let mut pixs = img_out.pixels_mut(); | ||
for (_, _, alpha_channel) in img_in.pixels() { | ||
let p = pixs.next().unwrap(); | ||
p.0[0] = alpha_channel[3]; | ||
p.0[1] = alpha_channel[3]; | ||
} | ||
let mut writer = BufWriter::new(Cursor::new(Vec::new())); | ||
img_out.write_to(&mut writer, ImageFormat::Png)?; | ||
Ok(writer.into_inner()?.into_inner()) | ||
} |
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 |
---|---|---|
@@ -1,63 +1,43 @@ | ||
use alphagen::on_paths; | ||
use clap::Parser; | ||
use image::GenericImageView; | ||
use log::warn; | ||
use rayon::iter::ParallelBridge; | ||
use rayon::iter::ParallelIterator; | ||
use std::{fs, path::PathBuf}; | ||
use std::path::PathBuf; | ||
|
||
#[derive(Parser, Debug)] | ||
#[clap(author, version, about, long_about = None)] | ||
struct Cli { | ||
#[clap(long, short, required = true)] | ||
/// Directory within which to find the color images | ||
path: PathBuf, | ||
#[command(author, version, about)] | ||
struct Args { | ||
#[clap(help = "Input files", required = true)] | ||
input_location: Vec<PathBuf>, | ||
|
||
#[clap(long, short)] | ||
/// Output directory for the alpha images | ||
out: Option<PathBuf>, | ||
#[clap(help = "Output directory", required = true)] | ||
output_location: PathBuf, | ||
} | ||
|
||
fn main() { | ||
let args = Cli::parse(); | ||
pretty_env_logger::init(); | ||
let args = Args::parse(); | ||
|
||
if let Some(ref out) = args.out { | ||
if out == &args.path { | ||
println!("Error: if the <out> arg is specified, it cannot match the <path> arg"); | ||
return; | ||
} | ||
assert!(out.is_dir()); | ||
let dir_output = args.output_location; | ||
if !dir_output.is_dir() { | ||
std::fs::create_dir_all(&dir_output).expect("Could not create output directory!"); | ||
} | ||
|
||
assert!(args.path.is_dir()); | ||
|
||
let append_alpha = args.out.is_none(); | ||
let out_dir = args.out.as_ref().unwrap_or(&args.path).to_path_buf(); | ||
|
||
let input_paths = fs::read_dir(args.path).unwrap(); | ||
|
||
input_paths.par_bridge().for_each(|path| { | ||
if let Ok(path) = path { | ||
let file_name: String = path.path().file_stem().unwrap().to_str().unwrap().into(); | ||
let file = image::open(path.path()).unwrap(); | ||
|
||
let mut imgbuf = image::GrayAlphaImage::new(file.width(), file.height()); | ||
let mut pixs = imgbuf.pixels_mut(); | ||
|
||
let mut out_path = out_dir.clone(); | ||
out_path.push(if append_alpha { | ||
format!("{file_name}_alpha.png") | ||
let paths = args | ||
.input_location | ||
.iter() | ||
.par_bridge() | ||
.filter(|p| { | ||
if p.is_file() { | ||
true | ||
} else { | ||
format!("{file_name}.png") | ||
}); | ||
let fout = &mut fs::File::create(out_path).unwrap(); | ||
|
||
for pixel in file.pixels() { | ||
let p = pixs.next().unwrap(); | ||
p.0[0] = pixel.2[3]; | ||
p.0[1] = pixel.2[3]; | ||
warn!("{} is not a valid file path. Skipping.", p.display()); | ||
false | ||
} | ||
}) | ||
.collect::<Vec<_>>(); | ||
|
||
imgbuf.write_to(fout, image::ImageFormat::Png).unwrap(); | ||
println!("Completed: {}", path.path().to_str().unwrap()); | ||
} | ||
}); | ||
assert!(paths.is_empty(), "No valid input file paths!"); | ||
on_paths(paths, dir_output); | ||
} |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Diff not rendered.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Diff not rendered.
Oops, something went wrong.