{"id":19358365,"url":"https://github.com/paritytech/polkadot-identicon-rust","last_synced_at":"2025-06-26T07:31:49.194Z","repository":{"id":43063203,"uuid":"388435012","full_name":"paritytech/polkadot-identicon-rust","owner":"paritytech","description":"Identicon implementation in Rust","archived":false,"fork":false,"pushed_at":"2023-08-07T15:00:12.000Z","size":102,"stargazers_count":9,"open_issues_count":1,"forks_count":4,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-06-24T00:10:13.901Z","etag":null,"topics":["icon","identicon","parity","polkadot","rust"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/paritytech.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":"2021-07-22T11:16:56.000Z","updated_at":"2024-07-17T08:50:13.000Z","dependencies_parsed_at":"2024-11-10T07:11:36.555Z","dependency_job_id":"4843f7f9-4a18-417a-ae7c-14aae1b5d013","html_url":"https://github.com/paritytech/polkadot-identicon-rust","commit_stats":{"total_commits":31,"total_committers":6,"mean_commits":5.166666666666667,"dds":0.6451612903225806,"last_synced_commit":"098ea59fd11278467b8c3815e44aa55e533e36bb"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/paritytech/polkadot-identicon-rust","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paritytech%2Fpolkadot-identicon-rust","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paritytech%2Fpolkadot-identicon-rust/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paritytech%2Fpolkadot-identicon-rust/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paritytech%2Fpolkadot-identicon-rust/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/paritytech","download_url":"https://codeload.github.com/paritytech/polkadot-identicon-rust/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paritytech%2Fpolkadot-identicon-rust/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262022038,"owners_count":23246239,"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":["icon","identicon","parity","polkadot","rust"],"created_at":"2024-11-10T07:11:26.192Z","updated_at":"2025-06-26T07:31:49.170Z","avatar_url":"https://github.com/paritytech.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# Crate `plot_icon`\n\n## Overview\n\nThis is a lib crate for generating standard 19-circle icons in `png` and in `svg` format.  \n![identicon](./src/identicon_example.svg)\n\nOutput is `Vec\u003cu8\u003e` `png` data, or `svg::Document` with `svg` data, both could be easily printed into files.  \n\nThe identicon color scheme and elements arrangement follow the published javascript [code](https://github.com/paritytech/oo7/blob/master/packages/polkadot-identicon/src/index.jsx) for polkadot identicon generation. This crate is intended mainly for use by [Signer](https://github.com/paritytech/parity-signer).  \n\n\n## Input\n\nIdenticon is generated for `\u0026[u8]` input slice. During identicon generation, this input slice gets hashed, therefore, any length would be acceptable.  \n\nTypical input slice is a public key. Public key is often encountered as a hexadecimal string (`d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d`) or as a base58 network-specific string (`5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY`), both could be easily transformed into `\u0026[u8]` input.  \n\nCrate also supports generation of identicon-like images with user-provided colors in RGBA format.  \n\n\n## PNG\n\nSigner uses images in `png` format, since `svg` format is not sufficiently supported on devices side and might be non-deterministic. Therefore, this crate sticks mostly to `png` generation. Feature `\"pix\"` (enabled by default) enables generation of `png` images.  \n\nFunction `generate_png` produces `png` data for identicon, and requires:  \n- `\u0026[u8]` slice  \n- target image size in pixels (`u16`)  \n`png` images are generated pixel-by-pixel, and the quality of final image is determined by the image size. Each `png` pixel (with integer coordinates) falling within the identicon circle element (with float circle parameters) gets the color of the circle. Below certain image size (approximately 100 pix) the circles become too pixelated. Also, images with even number of pixels size are off-centered by a pixel.  \n\nSigner needs small `png` identicon icons. Exact parameters are yet TBD (at the moment, identicons are 30 pix and device-independent), however, the straightforward approach with `generate_png` does not produce acceptable results.  \n\nPossible solution is to generate larger identicon and then scale it down in Signer frontend, but it was noticed that the scaling results (pixelation, color distribution) are device-dependent and although a minor thing, it should definitely be avoided in *identicon*.  \n\nTo generate reproducible small identicons, the rescaling is performed within the crate. A larger `png` is generated, and then scaled down to originally desired size. This procedure results in both less pixelated circles and compensated off-centering.  \n\nFunction `generate_png_scaled_custom` performs the scaling with custom parameters, and requires:  \n- `\u0026[u8]` slice  \n- **target** identicon size in pixels (`u8` - it is for small identicons, after all)  \n- scaling factor (`u8`), how much larger the larger `png` actually is  \n- filter ([`FilterType`](https://docs.rs/image/latest/image/imageops/enum.FilterType.html)) used for image resize  \n\nThe scaling factor reasonable values are in range `[4..=8]`, below it the pixelation persists, above it the images are not visibly improving anymore, and may even seem blurry.  \n\nAll filters produce reasonable results, except `FilterType::Nearest` that yields visibly distorted images and therefore is not recommended.  \n\nFunction `generate_png_scaled_default` performs the scaling with default scaling parameters (scaling factor `5` and filter `FilterType::Lanczos3`) for image with default Signer identicon size (30 pix), and requires only:  \n- `\u0026[u8]` slice  \nIf somehow the generation of the identicon fails, function outputs default-sized (30x30) transparent `png` image, i.e. it never produces an error.  \n\nFunction `generate_png_with_colors` is similar to `generate_png`, but accepts identicon colors directly, and does not generate color set itself. This is intended mainly for tests. Function `generate_png_with_colors` requires:  \n- `[[u8; 4]; 19]` 19-element set of colors in RGBA format  \n- target image size in pixels (`u16`)  \n\nFunction `generate_png_scaled_custom_with_colors` is similar to `generate_png_scaled_custom`, but accepts identicon colors directly, and does not generate color set itself. This is intended mainly for tests. Function `generate_png_scaled_custom_with_colors` requires:  \n- `[[u8; 4]; 19]` 19-element set of colors in RGBA format  \n- target identicon size in pixels (`u8`)  \n- scaling factor (`u8`)  \n- filter ([`FilterType`](https://docs.rs/image/latest/image/imageops/enum.FilterType.html)) used for image resize  \n\n\n## SVG\n\nFeature `\"vec\"` (enabled by default) enables infallible generation of identicon pictures in `svg` format. Since `svg` is a vector format, no image size parameters are needed.\n\nFunction `generate_svg` reqires only `\u0026[u8]` input slice.  \n\nFunction `generate_svg_with_colors` uses pre-set colors and is intended mainly for tests. It requires only the color set (`[[u8; 4]; 19]` 19-element set of colors in RGBA format).  \n\n\n## Tests and Examples\n\nTests in `colors.rs` module check if the color sets calculated for Alice and Bob are identical to the colors in the corresponding well-known icons.  \n\nDoc tests in `lib.rs` produce various test pics, both png (through different functions and parameters) and `svg`.  \n\n\n## Notes\n\nThere are several uncertainties about how the original published code was designed to work, those should be clarified, eventually.  \n\nFor example, calculated HSL color saturation could range 30..109, and is processed as percents. Crate `palette` (currently used here) processes saturation values over 100 as percents over 100, and gives some results (slightly different from results for 100% saturation), but it is necessary to check if the calculations in js and here are matching.  \n\nSee details in code comments.  \n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fparitytech%2Fpolkadot-identicon-rust","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fparitytech%2Fpolkadot-identicon-rust","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fparitytech%2Fpolkadot-identicon-rust/lists"}