pub struct DrawingStream { /* private fields */ }Expand description
Byte drawing stream of GameBoy.
It simillars with crate::io::GbStream. But there are some
significant differences.
-
DrawingStreamusesAPAmode drawing library of GBDK. this causes many side effects, For example, if you try to useDrawingStreaminside a VBL interrupt, it will have unexpected result. For more detail, please refer GBDK Docs -
Unable to change line with
\n, this means, when you want to make a new line, you should use theDrawingStream::cursorfunction. -
DrawingStreamcan also draw shapes in addition to texts.
§Examples
let mut s = unsafe {DrawingStream::new()}; // prints to second line.
write!(s, "Hello, APA!");Implementations§
Source§impl DrawingStream
impl DrawingStream
Sourcepub unsafe fn new() -> Self
pub unsafe fn new() -> Self
Creates new DrawingStream.
Enable APA mode to draw texts.
§Safety
This will break crate::io::GbStream.
After this function, you cannot use GbStream dependent functions such as
println!.
Sourcepub fn set_style(&self, style: DrawingStyle)
pub fn set_style(&self, style: DrawingStyle)
Apply drawing style.
Internally, call color function of GBDK.
Sourcepub fn cursor(&self, x: u8, y: u8)
pub fn cursor(&self, x: u8, y: u8)
Set cursor of DrawingStream.
§Panics
Panics if coordinate parameter out of bounds.
§Safety
Because of the bound check, it is guaranteed to move the cursor to a valid range.
§Examples
let mut s = unsafe {DrawingStream::new()};
DrawingStream::cursor(0, 1); //prints to second line.
write!(s, "Hello, Cursor!");
Sourcepub fn draw_point(&self, (x, y): (u8, u8))
pub fn draw_point(&self, (x, y): (u8, u8))
Sourcepub fn write_byte(&mut self, b: u8) -> Result<(), Error>
pub fn write_byte(&mut self, b: u8) -> Result<(), Error>
Writes a byte into this writer, returning whether the write succeeded.
write_char assumes that the input is valid Unicode character. However, GBDK maps one byte to one character or symbol.
Therefore, write_byte is recommended when you want to print one
character to the GameBoy.
§Errors
This function will return an instance of Error on error.