Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions examples/image/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//! However, to keep the example simple, we instead enable std. It significantly
//! increases the binary size but it's good enough for simple apps.

#![allow(static_mut_refs)]
#![no_main]
use firefly_rust as ff;
use std::cell::OnceCell;
Expand Down
1 change: 1 addition & 0 deletions src/graphics/bindings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ extern {
y: i32,
color: i32,
);
pub(crate) fn draw_qr(ptr: u32, len: u32, x: i32, y: i32, black: i32, white: i32);
pub(crate) fn draw_sub_image(
ptr: u32,
len: u32,
Expand Down
9 changes: 9 additions & 0 deletions src/graphics/funcs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,15 @@ pub fn draw_text(t: &str, f: &Font, p: Point, c: Color) {
}
}

/// Render a QR code for the given text.
pub fn draw_qr(t: &str, p: Point, black: Color, white: Color) {
let ptr = t.as_ptr();
let len = t.len();
unsafe {
b::draw_qr(ptr as u32, len as u32, p.x, p.y, black.into(), white.into());
}
}

/// Render an image using the given colors.
pub fn draw_image(i: &Image, p: Point) {
let ptr = i.raw.as_ptr();
Expand Down