pub struct State<IMG> { /* private fields */ }
Expand description
Implementations§
Source§impl<IMG: Bitmap + Serialize + for<'de> Deserialize<'de>> State<IMG>
impl<IMG: Bitmap + Serialize + for<'de> Deserialize<'de>> State<IMG>
Sourcepub fn new(
size: Size<i32>,
load_project_fn: Option<LoadProject>,
save_project_fn: Option<SaveProject>,
) -> Self
pub fn new( size: Size<i32>, load_project_fn: Option<LoadProject>, save_project_fn: Option<SaveProject>, ) -> Self
Create a new default state for the editor, with a starting canvas size
Sourcepub fn execute(&mut self, event: Event) -> Result<CanvasEffect>
pub fn execute(&mut self, event: Event) -> Result<CanvasEffect>
Execute an Event
. This is the main way of changing the editor’s
state, and probably the most central method of this library. A
CanvasEffect
is returned to communicate to the caller what kind of
visual updates must be made.
Sourcepub fn canvas_mut(&mut self) -> &mut Canvas<IMG>
pub fn canvas_mut(&mut self) -> &mut Canvas<IMG>
Sourcepub fn selected_tool(&self) -> Tool
pub fn selected_tool(&self) -> Tool
Get the currently selected Tool
Sourcepub fn main_color(&self) -> Color
pub fn main_color(&self) -> Color
Get the main (selected) color. This is the color used by most tools when drawing
Sourcepub fn spritesheet(&self) -> Size<u8>
pub fn spritesheet(&self) -> Size<u8>
Get the spritesheet dimensions (number of horizontal and vertical
frames). For a static image (not an animation) it will be (1, 1)
.
Sourcepub fn free_image(&self) -> Option<&FreeImage<IMG>>
pub fn free_image(&self) -> Option<&FreeImage<IMG>>
Get the FreeImage
Sourcepub fn update_free_image(&mut self, mouse_canvas: Position<i32>) -> Result<()>
pub fn update_free_image(&mut self, mouse_canvas: Position<i32>) -> Result<()>
When drawing lines, rectangles, etc. or moving things, there are visible
effects (e.g. a preview of the line or of the image being moved) that
are not immediately represented in the canvas, but are stored as a
FreeImage
instead. This method must be called as often as possible
whenever the mouse moves, in order to update this preview image.
Trait Implementations§
Source§impl<'de, IMG> Deserialize<'de> for State<IMG>where
IMG: Deserialize<'de>,
impl<'de, IMG> Deserialize<'de> for State<IMG>where
IMG: Deserialize<'de>,
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl<IMG> Freeze for State<IMG>where
IMG: Freeze,
impl<IMG> RefUnwindSafe for State<IMG>where
IMG: RefUnwindSafe,
impl<IMG> Send for State<IMG>where
IMG: Send,
impl<IMG> Sync for State<IMG>where
IMG: Sync,
impl<IMG> Unpin for State<IMG>where
IMG: Unpin,
impl<IMG> UnwindSafe for State<IMG>where
IMG: UnwindSafe,
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
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>
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>
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