pub struct Sketch<S: State> {Show 16 fields
pub width: usize,
pub height: usize,
pub is_looping: bool,
pub frame_count: u32,
pub delta_time: f32,
pub mouse_x: f32,
pub mouse_y: f32,
pub mouse_is_pressed: bool,
pub mouse_button: MouseButton,
pub draw_method: Option<fn(&mut Self)>,
pub setup_method: Option<fn(&mut Self)>,
pub mouse_pressed_method: Option<fn(&mut Self)>,
pub mouse_released_method: Option<fn(&mut Self)>,
pub key_pressed_method: Option<fn(&mut Self, Key)>,
pub key_released_method: Option<fn(&mut Self, Key)>,
pub state: S,
/* private fields */
}Fields§
§width: usize§height: usize§is_looping: bool§frame_count: u32§delta_time: f32§mouse_x: f32§mouse_y: f32§mouse_is_pressed: bool§draw_method: Option<fn(&mut Self)>§setup_method: Option<fn(&mut Self)>§mouse_pressed_method: Option<fn(&mut Self)>§mouse_released_method: Option<fn(&mut Self)>§key_pressed_method: Option<fn(&mut Self, Key)>§key_released_method: Option<fn(&mut Self, Key)>§state: SImplementations§
Source§impl<S: State> Sketch<S>
impl<S: State> Sketch<S>
Sourcepub fn key_is_down(&self, key: Key) -> bool
pub fn key_is_down(&self, key: Key) -> bool
Checks if the key: Key is currently pressed
Sourcepub fn no_stroke(&mut self)
pub fn no_stroke(&mut self)
Removes the current stroke color, drawn shapes will not have an outline
Sourcepub fn stroke_weight(&mut self, weight: i8)
pub fn stroke_weight(&mut self, weight: i8)
Sets the thickness of the outline
Sourcepub fn stroke_mode(&mut self, mode: StrokeMode)
pub fn stroke_mode(&mut self, mode: StrokeMode)
Changes the current stroke mode, see StrokeMode
Sourcepub fn fill_pixel(&mut self, x: i32, y: i32)
pub fn fill_pixel(&mut self, x: i32, y: i32)
Applies current fill color to pixel at x,y
Sourcepub fn stroke_pixel(&mut self, x: i32, y: i32)
pub fn stroke_pixel(&mut self, x: i32, y: i32)
Applies current stroke color to pixel at x,y
Sourcepub fn rect(&mut self, x: i32, y: i32, w: i32, h: i32)
pub fn rect(&mut self, x: i32, y: i32, w: i32, h: i32)
Draws a rectangle at x,y with side lengths w,h
Sourcepub fn triangle(&mut self, x0: i32, y0: i32, x1: i32, y1: i32, x2: i32, y2: i32)
pub fn triangle(&mut self, x0: i32, y0: i32, x1: i32, y1: i32, x2: i32, y2: i32)
Draws a triangle between points x0,y0 x1,y1 and x2,y2
Sourcepub fn background(&mut self, color: u32)
pub fn background(&mut self, color: u32)
Fills the window with given color
pub fn image( &mut self, image_buffer: ImageBuffer<Rgb<u8>, Vec<u8>>, x: i32, y: i32, )
Sourcepub fn line(&mut self, x0: i32, y0: i32, x1: i32, y1: i32)
pub fn line(&mut self, x0: i32, y0: i32, x1: i32, y1: i32)
Draws a line between points x0,y0 and x1,y1
Sourcepub fn begin_shape(&mut self, shape_type: ShapeType)
pub fn begin_shape(&mut self, shape_type: ShapeType)
Indicates the start of a shape construction
Sourcepub fn begin_hole(&mut self)
pub fn begin_hole(&mut self)
Indicate start of a hole within the current shape construction
Sourcepub fn end_shape(&mut self)
pub fn end_shape(&mut self)
Indicate the end of the current shape construction and render constructed shape
pub fn font(&mut self, font: FontMode)
pub fn text(&mut self, string: &str, x: i32, y: i32)
Auto Trait Implementations§
impl<S> Freeze for Sketch<S>where
S: Freeze,
impl<S> !RefUnwindSafe for Sketch<S>
impl<S> !Send for Sketch<S>
impl<S> !Sync for Sketch<S>
impl<S> Unpin for Sketch<S>where
S: Unpin,
impl<S> !UnwindSafe for Sketch<S>
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> 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