Struct rustty_oxide::Canvas
[−]
[src]
pub struct Canvas { /* fields omitted */ }
Logical clone of Frame that exposes backend functionality for users without breaking the API rules
Examples
use oxide::Canvas; let mut canvas = Canvas::new(60, 10); let (rows, cols) = canvas.size(); // Set the entire canvas to '-' character for i in 0..cols*rows { let y = i / cols; let x = i % cols; let mut cell = canvas.get_mut(x, y).unwrap(); cell.set_ch('-'); }
Methods
impl Canvas
[src]
fn new(cols: usize, rows: usize) -> Canvas
[src]
Constructs a new Canvas
object cols wide by rows high
Examples
use oxide::Canvas; let mut canvas = Canvas::new(60, 10);
fn size(&self) -> Size
[src]
Returns the size of the canvas
Examples
use oxide::Canvas; let mut canvas = Canvas::new(60, 10); assert_eq!(canvas.size(), (60, 10));
fn cellvec(&self) -> &Vec<Cell>
[src]
Returns a reference to the vector of cells that lie within the canvas
fn cellvec_mut(&mut self) -> &mut Vec<Cell>
[src]
Returns a mutable reference to the vector of cells that lie within the canvas
fn clear(&mut self, blank: Cell)
[src]
Clears the canvas with a blank Cell
fn pos_to_index(&self, x: usize, y: usize) -> Option<usize>
[src]
Converts a position on the screen to the relative coordinate within the Canvas cell buffer
fn get(&self, x: usize, y: usize) -> Option<&Cell>
[src]
Returns a reference to the cell at the specified position (x,*y*), in the form of an Option. If no cell exists at that position, then None
fn get_mut(&mut self, x: usize, y: usize) -> Option<&mut Cell>
[src]
Returns a mutable reference to the cell at the specified position (x, y), in the form of an Option. If no cell exists at that position, then None
fn origin(&self) -> Pos
[src]
The location of the canvas
fn set_origin(&mut self, new_origin: Pos)
[src]
Mantually sets the location of the canvas
Trait Implementations
impl Widget for Canvas
[src]
fn draw(&mut self, parent: &mut CellAccessor)
[src]
Draws the widget to the valid CellAccessor
passed
fn pack(
&mut self,
parent: &HasSize,
halign: HorizontalAlign,
valign: VerticalAlign,
margin: (usize, usize)
)
[src]
&mut self,
parent: &HasSize,
halign: HorizontalAlign,
valign: VerticalAlign,
margin: (usize, usize)
)
Aligns the widget with the parent
as reference
fn resize(&mut self, new_size: Size)
[src]
Resize the given widget to new dimensions given by Size
fn draw_box(&mut self)
[src]
Expose the painter trait draw_box
for all widgets, which outlines the space enclosed within the widget Read more
fn frame(&self) -> &Frame
[src]
Return a reference the renderer, Base
in general cases
fn frame_mut(&mut self) -> &mut Frame
[src]
Return a mutable reference to the renderer, Base
in general cases