-
-
Save NotNite/4b48409e335368a7d94665df95b357ae to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extern "C" { | |
// idx goes from 0..size() | |
// color is 0xRRGGBB | |
fn set_pixel(idx: u32, color: u32); | |
fn get_pixel(idx: u32) -> u32; | |
fn size() -> u32; | |
fn time() -> u64; // unix ms wall clock | |
} | |
#[no_mangle] | |
#[allow(clippy::missing_safety_doc)] | |
pub unsafe extern "C" fn tick(time: f32) { | |
// time is elapsed seconds, starting at 0 | |
let p = (time * 5.0) as u32; | |
for i in 0..size() { | |
if i == p { | |
set_pixel(i, 0xFFFFFF); | |
} else { | |
set_pixel(i, 0x000000); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment