Skip to content

Commit

Permalink
Little more cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
itsmeow committed Dec 25, 2023
1 parent 3d47ac7 commit 2d7865e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 15 deletions.
32 changes: 19 additions & 13 deletions dmsrc/iconforge.dm
Original file line number Diff line number Diff line change
@@ -1,21 +1,27 @@
/// Generates a spritesheet at: [file_path][spritesheet_name]_[size_id].png
/// Spritesheet will contain all sprites listed within "sprites".
/// Sprite object format: list(
/// icon_file = 'icons/path_to/an_icon.dmi',
/// icon_state = "some_icon_state",
/// dir = SOUTH,
/// frame = 1,
/// transform = list(transform_object, ...)
/// )
/// transform_object format:
/// list("type" = "Color", "color" = "#ff0000", "blend_mode" = ICON_MULTIPLY)
/// list("type" = "Icon", "icon" = sprite_object, "blend_mode" = ICON_OVERLAY)
/// "sprites" format:
/// list(
/// "sprite_name" = list(
/// icon_file = 'icons/path_to/an_icon.dmi',
/// icon_state = "some_icon_state",
/// dir = SOUTH,
/// frame = 1,
/// transform = list([TRANSFORM_OBJECT], ...)
/// ),
/// ...,
/// )
/// TRANSFORM_OBJECT format:
/// list("type" = "BlendColor", "color" = "#ff0000", "blend_mode" = ICON_MULTIPLY)
/// list("type" = "BlendIcon", "icon" = sprite_object, "blend_mode" = ICON_OVERLAY)
/// list("type" = "Scale", "width" = 32, "height" = 32)
/// list("type" = "Crop", "x1" = 0, "y1" = 0, "x2" = 32, "y2" = 32)
/// Returns a SpritesheetResult as JSON, containing fields:
/// sizes: list("32x32", "64x64", ...etc)
/// sprites: list("sprite_name" = list("size_id" = "32x32", "position" = 0), ...)
/// error: A string, empty if there were no errors.
/// list(
/// "sizes" = list("32x32", "64x64", ...etc)
/// "sprites" = list("sprite_name" = list("size_id" = "32x32", "position" = 0), ...)
/// "error" = "[A string, empty if there were no errors.]"
/// )
/// In the event of an unrecoverable error, where the spritesheet could not even generate, returns a string containing the error.
#define rustg_iconforge_generate(file_path, spritesheet_name, sprites) RUSTG_CALL(RUST_G, "iconforge_generate")(file_path, spritesheet_name, sprites)
/// Returns a job_id for use with rustg_iconforge_check()
Expand Down
4 changes: 2 additions & 2 deletions src/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,11 @@ fn hash_algorithm<B: AsRef<[u8]>>(name: &str, bytes: B) -> Result<String> {
}
}

pub fn string_hash(algorithm: &str, string: &str) -> Result<String> {
fn string_hash(algorithm: &str, string: &str) -> Result<String> {
hash_algorithm(algorithm, string)
}

pub fn file_hash(algorithm: &str, path: &str) -> Result<String> {
fn file_hash(algorithm: &str, path: &str) -> Result<String> {
let mut bytes: Vec<u8> = Vec::new();
let mut file = BufReader::new(File::open(path)?);
file.read_to_end(&mut bytes)?;
Expand Down

0 comments on commit 2d7865e

Please sign in to comment.