Crate beacon_calculator

Source
Expand description

This is a library for calculating the ideal combination of glass colors to color a Minecraft beacon.

§Features

  • Color Approxmation: Find the best combination of glass colors to approximate a given color
  • Pane Calculation: Calculate the color of the beacon beam with some given glass colors
  • Standard Colors: Acces the standard Minecraft colors

§Color Approxmation

find_combination_default and it’s custom variants are used for approximating a color using the limited palette of Minecraft colors.

use beacon_calculator::find_combination_default;

find_combination_default([254, 44, 84]);

Returns:

Some(Panes {
    panes: [
        "pink",
        "magenta",
        "orange",
        "pink",
        "pink",
        "red",
    ],
    distance: 7.9557647705078125,
    color: PreciseRGB {
        red: 208.5,
        green: 89.90625,
        blue: 95.78125,
    },
})

§Performance Considerations

When using the custom variants pay attention to what limits you set, as they can get out of hand rather quickly. A depth and cutoff of 7 already take longer than 30 seconds on my machine for example. The accuracy doesn’t get much better with values over 6 anyway.

§Get color from panes

calculate_color_from_panes_default and it’s custom counterpart are used for getting the color of a Vec<String> representing a list of glass colors. Order is important here!

use beacon_calculator::calculate_color_from_panes_default;

calculate_color_from_panes_default(&[
    "red".to_string(),
    "green".to_string(),
    "red".to_string(),
]);

Returns:

PreciseRGB {
    red: 155.5,
    green: 65.5,
    blue: 34.0,
}

§Standard Colors

get_standard_colors just gets the standard Minecraft colors in form of a HashMap<String, [u8;3]>

§Optional Features

  • serde: Derives Serialize and Deserialize for custom datatypes

Structs§

Panes
Represents some glass panes, their DE2000 distance to the target and their calculated color
PreciseRGB
Represents a RGB color using f64

Functions§

calculate_color_from_panes_custom
Calculates the color of some glass panes using custom colors
calculate_color_from_panes_default
Calculates the color of some glass panes using the default Minecraft colors
find_combination_custom
Calculates the most precise combination with the given values (excl. custom Colors)
find_combination_custom_colors
Calculates the most precise combination with the given values (incl. custom Colors)
find_combination_default
Calculates the most precise combination with the default values
get_standard_colors
Gets the standard Minecraft colors