pub struct SimpleCanvas<'a> { /* private fields */ }
Implementations§
Source§impl<'a> SimpleCanvas<'a>
impl<'a> SimpleCanvas<'a>
Sourcepub fn new(
width: usize,
height: usize,
fill_color: Option<Color>,
antialiasing: bool,
antialiasing_resolution: usize,
) -> Self
pub fn new( width: usize, height: usize, fill_color: Option<Color>, antialiasing: bool, antialiasing_resolution: usize, ) -> Self
Examples found in repository?
examples/shapes.rs (lines 52-58)
47fn main() -> Result<(), String> {
48 let antialiasing = false;
49 let antialiasing_resolution = 1;
50 let fill_color = Some(color::BLACK);
51
52 let mut canvas = SimpleCanvas::new(
53 WIDTH as usize,
54 HEIGHT as usize,
55 fill_color,
56 antialiasing,
57 antialiasing_resolution,
58 );
59
60 let mut graphics = Graphics::create(&mut canvas)?;
61 graphics.run(&mut ShapesHandler {})?;
62
63 Ok(())
64}
More examples
examples/points_cloud.rs (lines 66-72)
61fn main() -> Result<(), String> {
62 let antialiasing = false;
63 let antialiasing_resolution = 1;
64 let fill_color = Some(color::BLACK);
65
66 let mut canvas = SimpleCanvas::new(
67 WIDTH as usize,
68 HEIGHT as usize,
69 fill_color,
70 antialiasing,
71 antialiasing_resolution,
72 );
73
74 let mut graphics = Graphics::create(&mut canvas)?;
75 graphics.run(&mut PointsCloudSample {
76 point_cloud: create_point_cloud(),
77 })?;
78
79 Ok(())
80}
pub fn size(&self) -> usize
pub fn save(&mut self, path: &str) -> Result<()>
Trait Implementations§
Source§impl<'a> Canvas for SimpleCanvas<'a>
impl<'a> Canvas for SimpleCanvas<'a>
fn draw_shape(&mut self, shape: &mut impl Shape)
fn change_color(&mut self, color: Color)
fn clamp_row(&self, row: i64) -> i64
fn clamp_col(&self, col: i64) -> i64
fn color_at(&self, index: usize) -> Color
fn width(&self) -> usize
fn height(&self) -> usize
fn fits_inside(&self, row: i64, col: i64) -> bool
fn fill(&mut self)
fn antialiasing(&self) -> bool
fn resolution(&self) -> usize
fn color(&self) -> Color
fn set_pixel(&mut self, row: usize, col: usize)
fn set_pixel_color(&mut self, row: usize, col: usize, color: Color)
fn buffer_mut_slice(&mut self) -> &mut [Color] ⓘ
Source§impl<'a> RequestDraw<'a> for SimpleCanvas<'a>
impl<'a> RequestDraw<'a> for SimpleCanvas<'a>
fn set_draw_request_handler<T: HandlesDrawRequest>(&mut self, handler: &'a T)
fn request_draw(&self)
Auto Trait Implementations§
impl<'a> Freeze for SimpleCanvas<'a>
impl<'a> !RefUnwindSafe for SimpleCanvas<'a>
impl<'a> Send for SimpleCanvas<'a>
impl<'a> Sync for SimpleCanvas<'a>
impl<'a> Unpin for SimpleCanvas<'a>
impl<'a> !UnwindSafe for SimpleCanvas<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more