Rusty fast cross-platform 2D drawing library

Overview

Bly

Rusty fast cross-platform 2D graphics library

rust-clippy analyze GitHub GitHub code size in bytes

Concept

  • Easy to use

Bly is easy to use and yet can be called from various windowing libraries using RawWindowHandle. To start using Bly, simply write the following code

let mut canvas = match bly::create_canvas(&window) {
    Ok(c) => c,
    Err(_) => {
        panic!("Can't initialize Bly!");
    }
};

For more information and to see an actual sample, click here!

  • Cross-platform

Bly also aims to work the same way on all platforms.
Currently supported platforms are Win32 and XLib

How it can be coded

#![allow(clippy::single_match)]

extern crate env_logger as logger;

use bly::{Color, Point2};

use std::env;

use winit::{
    event::{Event, WindowEvent},
    event_loop::EventLoop,
    window::WindowBuilder,
};

fn main() {
    env::set_var("RUST_LOG", "info");

    logger::init();
    let event_loop = EventLoop::new();

    let window = WindowBuilder::new()
        .with_title("A fantastic window!")
        .with_inner_size(winit::dpi::LogicalSize::new(520.0, 520.0))
        .build(&event_loop)
        .unwrap();

    let mut canvas = match bly::create_canvas(&window) {
        Ok(b) => b,
        Err(_) => {
            panic!("Can't initialize Bly!");
        }
    };

    event_loop.run(move |event, _, control_flow| {
        control_flow.set_wait();
        match event {
            Event::WindowEvent {
                event: WindowEvent::CloseRequested,
                window_id,
            } if window_id == window.id() => control_flow.set_exit(),

            Event::MainEventsCleared => canvas.draw(|painter| {
                painter.clear(Color::WhiteGray);

                painter.draw_rect(Point2::new(20.0,20.0), Point2::new(150.0,150.0), Color::Rgba(1.0, 1.0, 1.0, 1.0));
                painter.draw_rect(Point2::new(180.0,20.0), Point2::new(150.0,150.0), Color::Rgba(0.5, 0.5, 0.5, 1.0));
                painter.draw_rect(Point2::new(340.0,20.0), Point2::new(150.0,150.0), Color::Rgba(0.0, 0.0, 0.0, 1.0));

                painter.draw_rect(Point2::new(20.0,180.0), Point2::new(150.0,150.0), Color::Rgba(1.0, 0.0, 0.0, 1.0));
                painter.draw_rect(Point2::new(180.0,180.0), Point2::new(150.0,150.0), Color::Rgba(0.0, 1.0, 0.0, 1.0));
                painter.draw_rect(Point2::new(340.0,180.0), Point2::new(150.0,150.0), Color::Rgba(0.0, 0.0, 1.0, 1.0));

                painter.draw_rect(Point2::new(20.0,340.0), Point2::new(150.0,150.0), Color::Rgba(1.0, 1.0, 0.0, 1.0));
                painter.draw_rect(Point2::new(180.0,340.0), Point2::new(150.0,150.0), Color::Rgba(0.0, 1.0, 1.0, 1.0));
                painter.draw_rect(Point2::new(340.0,340.0), Point2::new(150.0,150.0), Color::Rgba(1.0, 0.0, 1.0, 1.0));
            }),
            _ => (),
        }
    });
}

Output

Windows

windows

XLib

xlib

Crates

bly

This is the core of bly. This crate is used to do the actual drawing

bly-ac

Provides traits for abstraction of backend crates, etc., as described below

bly-dx2d

Bly's drawing backend for Windows (uses Direct2D internally).

bly-cairo

Bly's drawing backend for Unix (uses Cairo internally).

You might also like...
A new pure-Rust library for cross-platform low-level access to USB devices.

nusb A new pure-Rust library for cross-platform low-level access to USB devices. Documentation Compared to rusb and libusb Pure Rust, no dependency on

General purpose cross-platform GIS-rendering library written in Rust
General purpose cross-platform GIS-rendering library written in Rust

Galileo is a general purpose cross-platform geo-rendering library. Web examples Raster tile layer (OSM) Vector tile layer (Maplibre) Use buttons at th

โŒš A command-line tool (and library) for the rusty Swatch Internet Time.

โŒš A command-line tool (and library) for the rusty Swatch Internet Time. Comes with XBar/Swiftbar support.

A cross platform minimalistic text user interface
A cross platform minimalistic text user interface

titik Titik is a crossplatform TUI widget library with the goal of being able to interact intuitively on these widgets. It uses crossterm as the under

A cross-platform graphical process/system monitor with a customizable interface and a multitude of features
A cross-platform graphical process/system monitor with a customizable interface and a multitude of features

A cross-platform graphical process/system monitor with a customizable interface and a multitude of features. Supports Linux, macOS, and Windows. Inspired by both gtop and gotop.

Cross-platform terminal program to download IEEE journals
Cross-platform terminal program to download IEEE journals

IEEE Journal Downloader A cross-platform terminal program which tries to download every article in a specified journal and merge the documents into on

๐Ÿ“บ(tv) Tidy Viewer is a cross-platform CLI csv pretty printer that uses column styling to maximize viewer enjoyment.
๐Ÿ“บ(tv) Tidy Viewer is a cross-platform CLI csv pretty printer that uses column styling to maximize viewer enjoyment.

๐Ÿ“บ(tv) Tidy Viewer is a cross-platform CLI csv pretty printer that uses column styling to maximize viewer enjoyment.

Native cross-platform full feature terminal-based sequence editor for git interactive rebase.
Native cross-platform full feature terminal-based sequence editor for git interactive rebase.

Native cross-platform full feature terminal-based sequence editor for git interactive rebase.

Cross-platform Rust rewrite of the GNU coreutils
Cross-platform Rust rewrite of the GNU coreutils

Cross-platform Rust rewrite of the GNU coreutils

Releases(0.0.8)
  • 0.0.8(Feb 24, 2023)

    What's Changed

    • 1 allows drawing of lines by @Lattexshz in https://github.com/Lattexshz/Bly/pull/3
    • 6 allow ellipse to be drawn by @Lattexshz in https://github.com/Lattexshz/Bly/pull/8
    • Preparing for wayland by @Lattexshz in https://github.com/Lattexshz/Bly/pull/9
    • Documentation by @Lattexshz in https://github.com/Lattexshz/Bly/pull/12

    New Contributors

    • @Lattexshz made their first contribution in https://github.com/Lattexshz/Bly/pull/3

    Full Changelog: https://github.com/Lattexshz/Bly/compare/0.0.7...0.0.8

    Source code(tar.gz)
    Source code(zip)
Owner
ใ“ใ‚“ใซใกใฏใ€‚
null
A Rust library for drawing grid-based user interfaces using ASCII characters.

grux A library for drawing grid-based user interfaces using ASCII characters. // Provides a uniform interface for drawing to a 2D grid. use grux::Grid

Matan Lurey 4 Jan 10, 2023
a rust crate for drawing fancy pie charts in the terminal

piechart piechart is a rust crate for drawing fancy pie charts in the terminal. Example usage: use piechart::{Chart, Color, Data}; fn main() { le

Jakob Hellermann 35 Dec 30, 2022
`boxy` - declarative box-drawing characters

boxy - declarative box-drawing characters Box-drawing characters are used extensively in text user interfaces software for drawing lines, boxes, and o

Miguel Young 7 Dec 30, 2022
Alacritty - A fast, cross-platform, OpenGL terminal emulator

Alacritty is a modern terminal emulator that comes with sensible defaults, but allows for extensive configuration. By integrating with other applications, rather than reimplementing their functionality, it manages to provide a flexible set of features with high performance. The supported platforms currently consist of BSD, Linux, macOS and Windows.

Alacritty 43.8k Dec 31, 2022
๐Ÿ”ฅ ๐Ÿ“ (fwdt) "few word do trick" is a cross platform manual fast logger

Few Word Do Trick (fwdt) Few Word Do Trick (fwdt) is a cross-platform general purpose fast logger for humans that supports incomplete csvs for a bette

Alex Hallam 15 Feb 3, 2023
Cross-platform Rust library for coloring and formatting terminal output

Coloring terminal output Documentation term-painter is a cross-platform (i.e. also non-ANSI terminals) Rust library for coloring and formatting termin

Lukas Kalbertodt 75 Jul 28, 2022
Cross platform terminal library rust

Cross-platform Terminal Manipulation Library Crossterm is a pure-rust, terminal manipulation library that makes it possible to write cross-platform te

crossterm-rs 2.1k Jan 2, 2023
Cross-platform terminal screen clearing library

ClearScreen Cross-platform terminal screen clearing library. API documentation. Dual-licensed with Apache 2.0 and MIT. Uses Caretaker Maintainership.

null 23 Dec 30, 2022
Cross-platform WebView library in Rust for Tauri.

Cross-platform WebView rendering library in Rust that supports all major desktop platforms like Windows, macOS, and Linux. Overview Wry connects the w

Tauri 2.2k Jan 9, 2023
A cross-platform library for retrieving information about connected devices.

Devices devices is a cross-platform library for retrieving information about connected devices. Combined with a library like sysinfo, a more or less c

Hank Jordan 4 Jan 8, 2023