{"id":20431483,"url":"https://github.com/devyatsu/hex_rgb_converter","last_synced_at":"2025-07-26T07:34:35.785Z","repository":{"id":178796040,"uuid":"662372854","full_name":"DevYatsu/hex_rgb_converter","owner":"DevYatsu","description":"Dead-simple hex-to-rgb and rgb-to-hex converter made in rust.","archived":false,"fork":false,"pushed_at":"2023-07-05T21:06:45.000Z","size":187768,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-15T18:25:01.255Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DevYatsu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-07-05T02:06:18.000Z","updated_at":"2023-07-05T03:07:52.000Z","dependencies_parsed_at":null,"dependency_job_id":"caaf112a-2daa-4d08-a947-e15852bf9477","html_url":"https://github.com/DevYatsu/hex_rgb_converter","commit_stats":null,"previous_names":["devyatsu/hex_rbg_converter"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DevYatsu%2Fhex_rgb_converter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DevYatsu%2Fhex_rgb_converter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DevYatsu%2Fhex_rgb_converter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DevYatsu%2Fhex_rgb_converter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DevYatsu","download_url":"https://codeload.github.com/DevYatsu/hex_rgb_converter/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241975136,"owners_count":20051428,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-15T08:12:00.109Z","updated_at":"2025-03-05T05:44:58.644Z","avatar_url":"https://github.com/DevYatsu.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# hex_rbg_converter\n\nThe Hex-RGB Converter is a Rust library that allows you to convert colors between hexadecimal (hex) and RGB formats. It provides convenient macros and structs to simplify color conversion operations.\n\n## Usage\n\nTo use the Hex-RGB Converter, you need to import the necessary modules and macros into your Rust project:\n\n```rust\nuse hex_rgb_converter::{RgbColor, HexColor, Color};\n#[macro_use] mod macros;\n```\n\nThe Color struct and macros are provided by the library to facilitate color conversions.\n\n### Examples\n\nHere are some examples of how you can use the Hex-RGB Converter:\n\n#### Multiple Ways to Instantiate Colors\n\nThere are multiple ways to instantiate colors using the Hex-RGB Converter:\n\n```rust\n// all the following lines instantiate the same struct (HexColor)\nlet hex_1: HexColor = Color::hex(\"fff\");\nlet hex_2 = HexColor::new(\"fff\");\nlet hex_3 = hex!(\"fff\");\nlet hex_4 = color!(\"fff\");\n\n// all the following lines instantiate the same struct (RgbColor)\nlet rgb_1: RgbColor = Color::rgb(1, 2, 3);\nlet rgb_2 = RgbColor::new(1, 2, 3);\nlet rgb_3 = rgb!(1, 2, 3);\nlet rgb_4 = color!(1, 2, 3);\n```\n\nYou can either or not add '#' at the start of the hex colors.\nFor simplicity purposes, we will be using macros to instantiate colors in the tutorial.\n\n#### Convert Hex to RGB\n\nTo convert a color from hex format to RGB, you can use the color! macro followed by the hex value:\n\n```rust\nlet my_hex_color: HexColor = color!(\"787878\");\nlet my_color_in_rgb: RgbColor = my_hex_color.to_rgb();\nprintln!(\"Hex Color: {}\", my_hex_color);\nprintln!(\"RGB Color: {}\", my_color_in_rgb);\n```\n\n#### Convert RGB to Hex\n\nTo convert a color from RGB to hex format, you can use the hex! macro followed by the RGB values:\n\n```rust\nlet test_color: HexColor = hex!(\"#12ef78\").to_rgb().to_hex();\ntest_color.print();\n```\n\n#### Manipulate RGB Colors\n\nYou can also manipulate RGB colors using the provided methods. Here's an example:\n\n```rust\nlet mut rgb_col: RgbColor = color!(23, 2, 255);\nrgb_col\n    .set_blue(90)\n    .set_green(90)\n    .set_red(90)\n    .set_color(Colors::All(120));\n// use Colors enum to choose the color (Reg,Green,Blue,All)\n//can also use 'r', 'g' and 'b'\n\nprintln!(\"RGB Color: {}\", rgb_col);\nprintln!(\"Hex Color: {}\", rgb_col.to_hex());\n```\n\n#### Comparison and Equality\n\nYou can compare colors for equality using the `is_equal` method for different color formats and `RgbColor::are_equal` as well as `HexColor::are_equal` methods for the same format. Here's an example:\n\n```rust\nlet hex_col: HexColor = hex!(\"#fff\");\nlet rgb_col: RgbColor = rgb!(2, 4, 5);\nprintln!(\"Are hex_col and rgb_col equal? {}\", hex_col.is_equal(\u0026rgb_col)); // false here\n\nlet other_hex: HexColor = hex!(\"ffffff\");\nprintln!(\"Are hex_col and other_hex equal? {}\", HexColor::are_equal(\u0026hex_col, \u0026other_hex)); // true here\n```\n\n#### Color by Name\n\nThe Hex-RGB Converter also provides a convenient method to get the hex representation of a color by its name:\n\n```rust\nColor::by_name(\"orange\").print();\n```\n\n## Contributing\n\nIf you'd like to contribute to the Hex-RGB Converter library, feel free to submit issues or pull requests on the [GitHub repository](https://github.com/DevYatsu/hex_rgb_converter).\n\n## License\n\nThis project is licensed under the MIT License. See the [LICENSE](./LICENSE) file for more details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevyatsu%2Fhex_rgb_converter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevyatsu%2Fhex_rgb_converter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevyatsu%2Fhex_rgb_converter/lists"}