A canvas on which you can draw anything with ease before drawing the pixels on your small hardware display.

Overview

embedded-canvas

sponsor-uscrates-iodocs-rs

canvas - a piece of cloth backed or framed as a surface for a painting

NOTE: This crate is still in development and may have breaking changes from one version to another.

embedded-canvas is a convenient crate for embedded-graphics and provides a Canvas and CanvasAt on which you can draw anything with ease before drawing the pixels on the embedded display.

Based on embedded-graphics-core and embedded-graphics (see transform feature in Crate features).

This crate is no_std but requires alloc for the time being.

The main advantages of the canvases in this crate are:

  1. Transparency - pixels that haven't been drawn, won't override pixels on the display.

  2. Cropping - The ability to crop leaves only the part of the canvas you want to draw on the display. This is especially useful when you want to partially show text, figures and images.

Example: Cropping text

How to work with canvases

There are two main canvases you can work with:

Canvas

A canvas which you can draw on with origin Point::zero(). The canvas location is not set for the provided display.

After drawing decide where to place it on the display using the methods:

  • Canvas::place_at(top_left: Point) -> CanvasAt
  • Canvas::place_center(center: Point) -> CanvasAt

CanvasAt

CanvasAt is a type of canvas ready to be drawn on the display at specified location (hence the name CanvasAt).

There are two ways of using CanvasAt:

  1. Directly placing the CanvasAt on specified location on the display and drawing inside.
  2. Create a Canvas and when ready to draw it on the display place the Canvas at specified location using the methods:
    • Canvas::place_at(top_left: Point) -> CanvasAt
    • Canvas::place_center(center: Point) -> CanvasAt

Crate features

License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this project by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

You might also like...
CLI game to see how fast you can guess the language of a code block!
CLI game to see how fast you can guess the language of a code block!

Guess That Lang! CLI game to see how fast you can guess the language of a code block! If you like the game, please consider giving a ⭐ ! Code is retri

A tool to display the minimap of a game larger on a second screen
A tool to display the minimap of a game larger on a second screen

maximap A tool to display the minimap of a game larger on a second screen. Should work on all operating systems supported by captrs and rust_minifb, s

Generate, display and solve mazes in an animated way in the terminal.
Generate, display and solve mazes in an animated way in the terminal.

How to Run Usage: maze_solver.exe [OPTIONS] --generator GENERATOR|--input INPUT [ROWS] [COLUMNS] Arguments: [ROWS] Number of rows to draw

Random utility stuff for bevy for my personal use. You're welcome to use it, too, if you like.

bevy_cleancut Random utility stuff for bevy for my personal use. You're welcome to use it, too, if you like. Stuff It's all in the prelude: use bevy_c

A puzzle game where you eat your own tail to win!

taileater taileater is a puzzle game available for free here: https://szunami.itch.io/taileater This project is built using Rust and Bevy. Assets were

Managed game servers, matchmaking, and DDoS mitigation that lets you focus on building your game
Managed game servers, matchmaking, and DDoS mitigation that lets you focus on building your game

Managed game servers, matchmaking, and DDoS mitigation that lets you focus on building your game. Home - Docs - Twitter - Discord 👾 Features Everythi

This tool allows you to open one or more notebooks in Visual Studio and go hog wild exploring your systems in Bevy.
This tool allows you to open one or more notebooks in Visual Studio and go hog wild exploring your systems in Bevy.

Bevyrly Bevy is rly useful, but requires some hygiene! Pronounced as /ˈbɛvə(ɹ)li/, derives from Old English, combining befer ("beaver") and leah ("cle

A tilemap rendering crate for bevy which is more ECS friendly.
A tilemap rendering crate for bevy which is more ECS friendly.

bevy_ecs_tilemap A tilemap rendering plugin for bevy which is more ECS friendly by having an entity per tile. Features A tile per entity Fast renderin

Vulkan and Rust rendering~game engine which creation is covered with YouTube videos

Vulkan and Rust rendering~game engine which creation is covered with YouTube videos

Comments
  • Add examples

    Add examples

    Add more examples in:

    • ./examples directory
    • Readme & Crate docs (with images, draw inspiration from https://docs.rs/embedded-graphics)

    :heavy_check_mark: Cropping - an idea for an example that will show the cropping functionality for a useful use case:

    Show a box with an outline and e.g. 3 lines of text. Only the middle line will be fully shown while the others will be partially visible (i.e. cropped) below and above the middle one.

    • example provided in #5
    • screenshot in commit https://github.com/LechevSpace/embedded-canvas/commit/b91bacea95d9fcc13efe5a6b91fcd244b3f3dcdd

    :heavy_check_mark: Transparency - create a shape (e.g. a rectangle) filled with a specific color on the display, then create a canvas, draw anything on it with different color and place it inside the rectangle that's been already drawn on the display.

    • Example provided in #6
    good first issue 
    opened by elpiel 5
  • Tiny typo in homepage URL

    Tiny typo in homepage URL

    Cargo.toml documentation link at https://github.com/LechevSpace/embedded-canvas/blob/main/Cargo.toml#L11 reads "canavas" instead of "canvas"... :-)

    opened by peter9477 2
  • Add badges

    Add badges

    Add badges for:

    • :heavy_check_mark: docs.rs (documentation) - not in lib.rs
    • :heavy_check_mark: crates.io
    • :heavy_check_mark: sponsoring
    • :heavy_check_mark: GitHub repository - not in Readme.md
    • ~build status (eventually)~ see #4

    These badges can be added to:

    • :heavy_check_mark: Readme
    • :heavy_check_mark: Crate docs ( lib.rs )
    good first issue 
    opened by elpiel 0
  • Feature: Canvases with const generic

    Feature: Canvases with const generic

    This will allow the crate to support no_std environments without an allocator (alloc).

    Something in the line of:

    use embedded_graphics_core::prelude::{PixelColor, Point};
    
    pub struct Canvas<C: PixelColor, const W: usize, const H: usize> {
        pub pixels: [[Option<C>; W]; H],
    }
    pub struct CanvasAt<C: PixelColor, const W: usize, const H: usize> {
        pub top_left: Point,
        pub pixels: [[Option<C>; W]; H],
    }
    

    This will require const generic Size as well.

    opened by elpiel 0
Releases(v0.2.0)
  • v0.2.0(Aug 8, 2022)

    Added

    • Feature alloc - enables Canvas & CanvasAt
    • CCanavas & CCanvasAt - const generic alternatives to Canvas & CanvasAt which don't use alloc and update docs and README to include them
    • Fix typos in Cargo.toml
    Source code(tar.gz)
    Source code(zip)
  • v0.1.2(Jun 24, 2022)

    Fix error on docs.rs regarding doc(cfg) feature flag being an unstable feature See docs.rs build for v0.1.1 https://docs.rs/crate/embedded-canvas/0.1.1/builds/581694

    Source code(tar.gz)
    Source code(zip)
  • v0.1.1(Jun 24, 2022)

    Adds:

    • Badges #3
    • Examples for transparency & cropping with screenshots in both Readme & lib.rs #1
    • Show feature flags implementation in docs.rs (for feature transform)
    Source code(tar.gz)
    Source code(zip)
  • v0.1.0(Jun 16, 2022)

    The first release of embedded-canvas :tada:!

    This first release is no_std but requires alloc for embedded devices.

    Added

    • Canvas - a canvas with origin Point::zero() and no set location on the provided display.
    • CanvasAt - a type of canvas ready to be drawn on the display at the specified location.

    Read the full documentation at: https://docs.rs/embedded-canvas/0.1.0

    Full Changelog: https://github.com/LechevSpace/embedded-canvas/commits/v0.1.0

    Source code(tar.gz)
    Source code(zip)
Owner
Lechev.space
An open space for developing technologies and improving life on Earth.
Lechev.space
Motion graphics creation tool in Bevy. (Highly inspired by Motion Canvas and Manim)

Bevy MotionGfx Bevy Motiongfx is a motion graphics creation tool in Bevy. It is highly inspired by Motion Canvas & Manim. Goal The goal of this tool i

Nixon 3 Nov 6, 2023
Little 2D physics engine used for my game Crate Before Attack.

Circle2D Circle2D is a little physics library used for my game CrateBeforeAttack. Live demo: https://koalefant.github.io/circle2d/ It is not productio

Evgeny Andreeshchev 24 Jan 14, 2022
Small game where you play a big spider chasing small spiders, written in Rust and Macroquad.

Ludum Dare #49 Compo entry - Procedural Spider Small game where you play a big spider chasing small spiders. Each spider you catch makes you bigger! C

Jakub Arnold 16 Sep 5, 2022
You have been an apprentice to a powerful sorcerer for as long as you can remember.

You have been an apprentice to a powerful sorcerer for as long as you can remember. However you dream of becoming a rancher, raising animals in your own pen.

null 3 Jun 22, 2022
A prototype plugin providing a simple line drawing api for bevy.

bevy_debug_lines A prototype plugin providing a simple line drawing api for bevy. See docs.rs for documentation. Expect breakage on master. Click on t

Michael Palmos 92 Dec 31, 2022
An immediate mode 2D drawing API for Bevy game engine

Bevy Canvas API prototype An unofficial immediate mode 2D drawing API for Bevy game engine. Check the documentation or the examples to know how to use

Federico Rinaldi 20 Apr 21, 2022
This is an online game in which you program your character and he fights with other players

Game for programmers The goal of this project is to create a simple game for programmers. The essence of the game Each player has his own character th

Danila 1 Dec 10, 2021
The Big Cheese a webapp wherein you can share recipes with your friends.

The Big Cheese The Big Cheese a webapp wherein you can share recipes with your friends. Contributing Contributions are what make the open source commu

null 3 May 5, 2022
A simple example showcasing how to use Bevy to display a square with acceleration (controllable with your keyboard) that wraps around the screen!

Bevy Wrapping Square example A simple example showcasing how to use Bevy to display a square with acceleration (controllable with your keyboard) that

Luciano Mammino 3 Oct 23, 2022
Provision Mammoth-ready Minecraft clusters with ease!

Minecraft Server Provisioner Provision Mammoth-ready Minecraft clusters with ease! Overview Provisioner is a tool designed to make the creation of Mam

null 19 Sep 29, 2022