diff --git a/README.md b/README.md index 42094a7..6b99667 100644 --- a/README.md +++ b/README.md @@ -4,8 +4,6 @@ icon-cutter is a library which creates .dmi files tailored to use with an 8-bit A pre-compiled exe version can be found on the [releases page], but you can build your own from this repo at your preference. -[releases page]: https://github.com/tgstation/icon-cutter/releases - ## Dependencies The [Rust] compiler: @@ -36,15 +34,19 @@ cargo build --release ## Running -Simply drag your input .png file(s) onto the produced executable. You can also run it from the command line and provide the file paths as arguments. +Simply drag your input .png file(s) onto the produced executable. You can also run it from the command line and provide the file path(s) as arguments. -In addition, there needs to be a `config.yaml` file present in the executable's directory that complies with the format specified in `examples/config.yaml`. +In addition, there needs to be a `config.yaml` file present in the executable's directory that complies with the format specified in `examples/config-documentation.yaml`. Example formats for the .png and config.yaml files can be found in `examples/`. +All you have to do is copy the template and config file from one of them into the same folder in where the program will be executed. + +**Note:** The final products in dmi forms are fully functional but uncompressed. In order to reduce memory usage, open the DMI with DreamMaker and save it without changing anything. The file size should be noticeably reduced. If you're still having problems, ask in the [Coderbus Discord]'s `#tooling-questions` channel. +[releases page]: https://github.com/tgstation/icon-cutter/releases [DM]: https://secure.byond.com/ [Rust]: https://rust-lang.org [Cargo]: https://doc.rust-lang.org/cargo/ @@ -56,4 +58,4 @@ If you're still having problems, ask in the [Coderbus Discord]'s This project is licensed under the [AGPL license](https://en.wikipedia.org/wiki/Affero_General_Public_License). -See [LICENSE](./LICENSE) for more details. \ No newline at end of file +See [LICENSE](./LICENSE) for more details. diff --git a/examples/config.yaml b/examples/config-documentation.yaml similarity index 96% rename from examples/config.yaml rename to examples/config-documentation.yaml index b84a093..b3d3b41 100644 --- a/examples/config.yaml +++ b/examples/config-documentation.yaml @@ -1,224 +1,224 @@ -## PATH CONFIGS ## -##v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v## - - -## The path of the file to open. -## Optional, you can opt to leave it out and click and drag the file into the binary to execute it instead. - -#file_to_open: "./input.dmi" - - -## Name for the file to output. -## Optional, if unset the output name will be the same as the input file's, with "-output" appended to it, ending in ".dmi" -## Example output with "smooth_icon" as input: "smooth_icon.dmi" - -#output_name: "output" - - -##N ame for the icon-state prefixes. -## Optional, if unset it will default to "icon" -## Example output with "smooth_icon" as input: smooth_icon-0, smooth_icon-63, smooth_icon-137... - -#base_icon_state: "icon" - - -##^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^## - - -## ICON CONFIGS ## -##v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v## -## Possible icon coordinates here range from (0,0) in the top-left corner to (icon_size_x,icon_size_y) in the bottom-right one. -## Optional, defaults to 32. - -#icon_size_x: 32 -#icon_size_y: 32 - - -##v#v#v## -## While the default behavior is to cut the whole of the sprite into four corners, one can configure custom ranges for smaller corners. -## The values are in pixel cordinates, in the X axis for the west-east components and on the Y axis for the north-south ones. -## All of them are optional - -## Defaults to 0. - -#west_start: 0 - - -## Defaults to 0. - -#north_start: 0 - - -## Defaults to (icon_size_x / 2). - -#west_end = 16 - - -# Defaults to (icon_size_y / 2). - -#north_end = 16 - - -# Defaults to west_end. - -#east_start = 16 - - -# Defaults to north_end. - -#south_start = 16 - - -## Defaults to icon_size_x. - -#east_end = 32 - - -## Defaults to icon_size_y. - -#south_end = 32 - -##^#^#^## - - -## The resulting icon does not need to be the same size as the cut one. -## The four settings are optional. - -## These two default to the base respective icon_size. -#output_icon_size_x: 32 -#output_icon_size_y: 32 - -## These two default to 0. -#output_west_start: 0 -#output_north_start: 0 - -## Defaults to the value of (output_west_start + (west_end - west_start)), which is the result of the x-offest plus the size in the x-axis of the west corner icons. -#output_east_start: 16 - -## Defaults to the value of (output_north_start + (north_end - north_start)), which is the result of the y-offest plus the size in the y-axis of the north corner icons. -#output_south_start: 16 - - -## Produces 4 directions per final icon_state if set to true. -## Some projects might want to be able to use BYOND's client dir rotation feature, and smoothed sprites might look disconnected as the junctions have changed. -## This adds the properly rotated versions as directional images, allowing for client-side perspective rotation. -## Optional, defaults to false. - -#produce_dirs: false - - -## For animated icons, how many frames each icon_state has. If unset it will default to 1 (one), denoting a non-animated image. - -#frames_per_state: 2 - - -## If frames_per_state is defined and different than 1 (one), then this variable is used. -## It is a list of the delays in the animation of each frame. -## If the number of entires is lower than the number of frames, it will start reading from the beginning and repeating the pattern. -## This makes a single entry valid, for example, but then all frames will have that same delay. -## If the number of entries is defined and higher than the number of frames, the program will fail with the relevant error code. -## Optional, defaults all values to 1 - -#delay: -# - 20 -# - 20 - - -##^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^## - - -## ICON STATE CONFIGS ## -## These values are in icon-state steps as they would appear in the dmi file. -## The first icon is in the position 0 (zero), and subsequent ones increase that value by one. -## If frames_per_state is defined and different from 1, then the position indicates the location of the first frame, and the program will read the following ones in sequence. -##v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v## - - -### Prefab icons. -## These values are for specific junctions the icon already exists for, or you just don't want the corner-building method used. -## The notation is junction signature: position -## Optional, defaults to using the corners for every signature. If defined, signature will be skiped in favor of the prefab. - -#prefabs: -# 9: 22 -# 5: 25 - - -## Prefab overlays. -## Optional, but for every overlay signature entry, there must be a prefabs entry with a matching signature, refering to the image to be overlaid. -## Multiple positions may be selected in the list, each denoting one image (or set of frames) to be overlaid over the prefab, in the listed order. - -#prefab_overlays: -# 9: -# - 20 -# 5: -# - 23 - - -### Standard corners. - - -## Convex corners. -## Necessary to be able to run the program. -nw_convex: 0 -ne_convex: 1 -sw_convex: 2 -se_convex: 3 - - -##Vertical corners. -##Necessary to be able to run the program. -nw_vertical: 4 -ne_vertical: 5 -sw_vertical: 6 -se_vertical: 7 - - -##Horizontal corners. -##Necessary to be able to run the program. -nw_horizontal: 8 -ne_horizontal: 9 -sw_horizontal: 10 -se_horizontal: 11 - - -##Concave corners. -##Necessary to be able to run the program. -nw_concave: 12 -ne_concave: 13 -sw_concave: 14 -se_concave: 15 - - -##Flat corners. -##Optional. Will produce 16 icon variants without these, and 48 with them. -#nw_flat: 16 -#ne_flat: 17 -#sw_flat: 18 -#se_flat: 19 - - -##^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^## - - -## DEBUG CONFIGS ## -##v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v## -##If enabled, it will produce an image with every possible corner type variant (convex, concave, horizontal, vertical and flat). -##Useful for debugging purposes. -##Optional, defaults to false. - -#produce_corners: false - - -##^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^## - - -## VERSION CONFIGS ## -##v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v## -##This is a dmi version compatibility config. Do not touch it unless you know what you are doing, for you risk getting a corrupted file as a result. -##Optional, defaults to "4.0". - -#dmi_version: "4.0" - - -##^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^## +## PATH CONFIGS ## +##v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v## + + +## The path of the file to open. +## Optional, you can opt to leave it out and click and drag the file into the binary to execute it instead. + +#file_to_open: "./input.dmi" + + +## Name for the file to output. +## Optional, if unset the output name will be the same as the input file's, with "-output" appended to it, ending in ".dmi" +## Example output with "smooth_icon" as input: "smooth_icon.dmi" + +#output_name: "output" + + +##N ame for the icon-state prefixes. +## Optional, if unset it will default to "icon" +## Example output with "smooth_icon" as input: smooth_icon-0, smooth_icon-63, smooth_icon-137... + +#base_icon_state: "icon" + + +##^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^## + + +## ICON CONFIGS ## +##v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v## +## Possible icon coordinates here range from (0,0) in the top-left corner to (icon_size_x,icon_size_y) in the bottom-right one. +## Optional, defaults to 32. + +#icon_size_x: 32 +#icon_size_y: 32 + + +##v#v#v## +## While the default behavior is to cut the whole of the sprite into four corners, one can configure custom ranges for smaller corners. +## The values are in pixel cordinates, in the X axis for the west-east components and on the Y axis for the north-south ones. +## All of them are optional + +## Defaults to 0. + +#west_start: 0 + + +## Defaults to 0. + +#north_start: 0 + + +## Defaults to (icon_size_x / 2). + +#west_end = 16 + + +# Defaults to (icon_size_y / 2). + +#north_end = 16 + + +# Defaults to west_end. + +#east_start = 16 + + +# Defaults to north_end. + +#south_start = 16 + + +## Defaults to icon_size_x. + +#east_end = 32 + + +## Defaults to icon_size_y. + +#south_end = 32 + +##^#^#^## + + +## The resulting icon does not need to be the same size as the cut one. +## The four settings are optional. + +## These two default to the base respective icon_size. +#output_icon_size_x: 32 +#output_icon_size_y: 32 + +## These two default to 0. +#output_west_start: 0 +#output_north_start: 0 + +## Defaults to the value of (output_west_start + (west_end - west_start)), which is the result of the x-offest plus the size in the x-axis of the west corner icons. +#output_east_start: 16 + +## Defaults to the value of (output_north_start + (north_end - north_start)), which is the result of the y-offest plus the size in the y-axis of the north corner icons. +#output_south_start: 16 + + +## Produces 4 directions per final icon_state if set to true. +## Some projects might want to be able to use BYOND's client dir rotation feature, and smoothed sprites might look disconnected as the junctions have changed. +## This adds the properly rotated versions as directional images, allowing for client-side perspective rotation. +## Optional, defaults to false. + +#produce_dirs: false + + +## For animated icons, how many frames each icon_state has. If unset it will default to 1 (one), denoting a non-animated image. + +#frames_per_state: 2 + + +## If frames_per_state is defined and different than 1 (one), then this variable is used. +## It is a list of the delays in the animation of each frame. +## If the number of entires is lower than the number of frames, it will start reading from the beginning and repeating the pattern. +## This makes a single entry valid, for example, but then all frames will have that same delay. +## If the number of entries is defined and higher than the number of frames, the program will fail with the relevant error code. +## Optional, defaults all values to 1 + +#delay: +# - 20 +# - 20 + + +##^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^## + + +## ICON STATE CONFIGS ## +## These values are in icon-state steps as they would appear in the dmi file. +## The first icon is in the position 0 (zero), and subsequent ones increase that value by one. +## If frames_per_state is defined and different from 1, then the position indicates the location of the first frame, and the program will read the following ones in sequence. +##v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v## + + +### Prefab icons. +## These values are for specific junctions the icon already exists for, or you just don't want the corner-building method used. +## The notation is junction signature: position +## Optional, defaults to using the corners for every signature. If defined, signature will be skiped in favor of the prefab. + +#prefabs: +# 9: 22 +# 5: 25 + + +## Prefab overlays. +## Optional, but for every overlay signature entry, there must be a prefabs entry with a matching signature, refering to the image to be overlaid. +## Multiple positions may be selected in the list, each denoting one image (or set of frames) to be overlaid over the prefab, in the listed order. + +#prefab_overlays: +# 9: +# - 20 +# 5: +# - 23 + + +### Standard corners. + + +## Convex corners. +## Necessary to be able to run the program. +nw_convex: 0 +ne_convex: 1 +sw_convex: 2 +se_convex: 3 + + +##Vertical corners. +##Necessary to be able to run the program. +nw_vertical: 4 +ne_vertical: 5 +sw_vertical: 6 +se_vertical: 7 + + +##Horizontal corners. +##Necessary to be able to run the program. +nw_horizontal: 8 +ne_horizontal: 9 +sw_horizontal: 10 +se_horizontal: 11 + + +##Concave corners. +##Necessary to be able to run the program. +nw_concave: 12 +ne_concave: 13 +sw_concave: 14 +se_concave: 15 + + +##Flat corners. +##Optional. Will produce 16 icon variants without these, and 48 with them. +#nw_flat: 16 +#ne_flat: 17 +#sw_flat: 18 +#se_flat: 19 + + +##^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^## + + +## DEBUG CONFIGS ## +##v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v## +##If enabled, it will produce an image with every possible corner type variant (convex, concave, horizontal, vertical and flat). +##Useful for debugging purposes. +##Optional, defaults to false. + +#produce_corners: false + + +##^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^## + + +## VERSION CONFIGS ## +##v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v#v## +##This is a dmi version compatibility config. Do not touch it unless you know what you are doing, for you risk getting a corrupted file as a result. +##Optional, defaults to "4.0". + +#dmi_version: "4.0" + + +##^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^##