Port of the fantastic Iconoir Icon Pack to Rust embedded devices, with a focus on speed, usability, and completeness.

Overview

embedded-iconoir - Icons for every device, ever.

What is embedded-iconor?

embedded-iconoir is a library that allows you to use Iconoir on embedded devices , using Rust and the embedded-graphics library.

How many Icons?

All the over 1300 icons offered by Iconoir are also supported in this library. They are ordered by categories, so if you need a preview look at the Iconoir Website to pick out the exact icon you need.

How much size does this add to my binary?

Not a lot, actually. Only icons that you actually use are included, and they are tiny. Every pixel only takes a single bit, so each icon is resolution^2 / 8 bytes in size. For 24px resolution, each icon is only 72 bytes. That means you could fit all 1300+ icons in 24px resolution into less than 100kb! That's more than 20% smaller than this extremely over-compressed image of a cat: (Image Source)

Usage

Selecting a resolution

embedded-iconoir gives you feature flags for the available rendering resolutions: 12px, 18px, 24px, 32px, 48px, 96px and 144px. You can also enable the all-resolutions feature to just get all of them, but note that that will significantly increase your compile time.

Using the icons

The icons are structured into modules by size and then category. So, icons::sizeXXpx::CATEGORY::CamelCaseIconName is how you can select a specific icon in a specific resolution. If you're only using one resolution, it's a good idea to import embedded_iconoir::icons::sizeXXpx::* so that you have direct access to all categories.

Here's an example:

fn main() -> anyhow::Result<()> {
    // init display

    let color = Rgb888::CSS_CYAN;

    // Color is specified during icon creation
    let mut icon_tiny = icons::size12px::development::CodeBracketsSquare::new(color);
    let mut icon_normal = icons::size24px::development::CodeBracketsSquare::new(color);
    let mut icon_large = icons::size48px::development::CodeBracketsSquare::new(color);
    let mut icon_huge = icons::size144px::development::CodeBracketsSquare::new(color);

    // Icons must be wrapped into images to draw them properly
    let image_tiny = Image::new(&icon_tiny, Point::new(10, 10));
    // ...

    image_tiny.draw(&mut display)?;
    // ...


    // Changing colors after creation:
    let mut idx = 0u8;
    let colorscheme = colorous::RAINBOW;

    loop {
        let Color { r, g, b } = colorscheme.eval_rational(idx as usize, u8::MAX as usize);
        let idx = idx.overflowing_add(1).0;

        // Colors can be changed dynamically during runtime
        icon_tiny.set_color(Rgb888::new(r, g, b));
        // ...

        // But the images need to be recreated each time, because of their reference to the icon
        let image_tiny = Image::new(&icon_tiny, Point::new(10, 10));
        // ...

        image_tiny.draw(&mut display)?;
        // ...
    }

    Ok(())
}

If you run this, you'll get something like this:

A complete version of this code can also be viewed in examples/src/bin/cover_example.rs.

"But I want a different resolution!"

That is certainly doable. All resolutions are dynamically generated, and the ones that are available are so because they seemed to fit a fairly broad spectrum of use cases. If something is missing in your opinion, please open an issue on GitHub. Note that bigger resolutions as well as a high amount of different resolutions (e.g 10px, 11px, ..., 47px, 48px) will at some point conflict with crates.io's max package size of 10MB, as the icons are pre-baked. So, if this is relevant for your use case, forking the repository and using it as a Git dependency is a better idea.

Developing locally

To develop embedded-iconoir locally, clone the repository, and then execute git submodule init and git submodule update to pull Iconoir into the repository. After that, run cargo xtask generate to render the icons to .bits files, and generate the code.

Contributing

If you found a bug, or think that a feature is missing, please open an issue on GitHub. Of course, Pull Requests are also very much appreciated.

You might also like...
Easily sync your clipboard between devices. This is a work in progress app.

Clipboard Sync Description Easily sync your clipboard between devices. This is a work in progress app. Stack Frontend: React Tauri isomorphic-ws TSX,

diff successive buffers with embedded ansi codes in rust, outputting a minimal change

ansi-diff diff successive buffers with embedded ansi codes in rust, outputting a minimal change You can use this crate to build command-line interface

TI LDC1312/LDC1314/LDC1612/LDC1614 inductance-to-digital converter driver for Rust embedded-hal

ldc1x1x Rust embedded-hal 1.x driver for Texas Instruments (TI) I²C inductance-to-digital converters (LDC): LDC1312/LDC1314, LDC1612/LDC1614. Includes

⚡️ Fast MagicString port driven by Rust and N-API

magic-string-rs 100% API compatible (port) MagicString by Rich-Harris implementation for Node and modern browsers, also, for rust, of course. Installa

This is a test to port C++'s ymfm and Rust's vgmplay to ESP32(Xtensa).
This is a test to port C++'s ymfm and Rust's vgmplay to ESP32(Xtensa).

m5stack-chipstream This is a test to port C++'s ymfm and Rust's vgmplay to ESP32(Xtensa). Still slow and impractical, depending on the sound chip you

Crate of GitHub’s collection of gitignores, embedded, automatically updated

Gitignores GitHub’s collection of gitignores, embedded, automatically updated. API documentation. Public Domain via CC0-1.0 (same as source data). MSR

C API to SpringQL (for embedded mode)

SpringQL C Client This repository is a C client for SpringQL and provides it provides: springql.h: C header file. libspringql_client.{so,dylib}: Share

An asynchronous Hardware Abstraction Layer (HAL) for embedded systems

embedded-hal-async An asynchronous Hardware Abstraction Layer (HAL) for embedded systems. This crate contains asynchronous versions of the embedded-ha

A compatibility layer to smooth the transition between different versions of embedded-hal

Embedded HAL Compatibility Layer A compatibility layer to smooth the transition between different versions of embedded-hal (specifically 0.2.x and 1.0

Comments
  • Make IconoirInternal a sealed trait

    Make IconoirInternal a sealed trait

    This makes IconoirInternal a sealed trait, which prevents people impling the trait outside of this crate.

    This is somewhat necessary, as the unchecked methods could lead to OOB access on "untrusted" user inputs. You might still want to make the sealed trait unsafe, but since you only implement it in a macro, it's probably not worth it.

    opened by jamesmunns 2
Owner
null
Ector is an open source async, no-alloc actor framework for embedded devices

Ector is an open source async, no-alloc actor framework for embedded devices. Ector is an open source async, no-alloc actor framework for embedded dev

Drogue IoT 11 Dec 15, 2022
Freebsd-embedded-hal - Like linux-embedded-hal but FreeBSD

freebsd-embedded-hal Implementation of embedded-hal traits for FreeBSD devices: gpio: using libgpio, with stateful and toggleable support, with suppor

null 2 Oct 1, 2022
🦞 wasm-pack based build tool

rsw-rs This project is in early experimental stage. # dev rsw watch # release rsw build # create crate rsw new # rsw.toml name = 'rsw' version = "0.

lencx 71 Dec 30, 2022
A cross-platform serial port library in Rust. Provides a blocking I/O interface and port enumeration including USB device information.

Note: This is a fork of the original serialport-rs project on GitLab. Please note there have been some changes to both the supported targets and which

Serialport 128 Jan 4, 2023
syncmap is a fast, concurrent cache library built with a focus on performance and correctness.

syncmap syncmap syncmap is a fast, concurrent cache library syncmap is a fast, concurrent cache library built with a focus on performance and correctn

Behrouz R.Farsi 15 Dec 2, 2022
Combine internet connections, increase your download speed

dispatch A SOCKS proxy that balances traffic between network interfaces. Should work on macOS, Windows, and Linux. Only tested on macOS for now. This

Alexandre Kirszenberg 90 Jan 7, 2023
Simple async codec for rkyv. Reuses streaming buffer for maximum speed

rkyv_codec Simple async codec for rkyv. Reuses streaming buffer for maximum speed! This crate provides a makeshift adaptor for streaming &Archived<Obj

Zyansheep 19 Jun 14, 2022
Github mirror of codeberg repo. Monitor live bandwidth usage/ network speed on PC. Native version also available for Android, separately.

Netspeed Monitor Netspeed is a cross-platform desktop application that shows the live upload speed, download speed and day's usage as an overlay. Feat

Vishnu N K 16 May 3, 2023
mach-dump can parse Mach-O core dumps taken with lldb from macOS and iOS devices.

mach-dump mach-dump can parse Mach-O core dumps taken with lldb from macOS and iOS devices. It has no external dependencies. Example use std::path::Pa

Tobi 8 Sep 16, 2022
Incremental, multi-version remote backup tool for block devices.

bsync Incremental, multi-version remote backup tool for block devices. The on-disk backup format is a SQLite database and I've been dogfooding this on

Heyang Zhou 7 Aug 21, 2022