pub struct FreeImage<IMG> {
pub rect: Rect<i32>,
pub pivot: Option<Point<i32>>,
pub texture: IMG,
}Expand description
Represents an image that is not in any Canvas, but floats freely on
the screen until it is anchored back into the canvas. Typical uses of this
are imported images and selections – they can be moved around and
manipulated before being integrated into the canvas (by anchoring).
Fields§
§rect: Rect<i32>§pivot: Option<Point<i32>>§texture: IMGImplementations§
Source§impl<IMG: Bitmap> FreeImage<IMG>
impl<IMG: Bitmap> FreeImage<IMG>
Sourcepub fn new(p: Position<i32>, img: IMG) -> Self
pub fn new(p: Position<i32>, img: IMG) -> Self
Creates a new free image at a specified position, with predefined inner image
Sourcepub fn from_canvas_area(
canvas: &Canvas<IMG>,
area: Rect<i32>,
pivot: Option<Point<i32>>,
) -> Self
pub fn from_canvas_area( canvas: &Canvas<IMG>, area: Rect<i32>, pivot: Option<Point<i32>>, ) -> Self
Creates a free image from the contents of the canvas at a specified area. A pivot point might be provided in case the image is being dragged/moved, in which case it would be the mouse position (relative to the image, (0, 0) being the top left corner of the image)
Sourcepub fn from_pixels(
size: Size<i32>,
pixels: Vec<Point<i32>>,
color: Color,
offset: Position<i32>,
) -> Self
pub fn from_pixels( size: Size<i32>, pixels: Vec<Point<i32>>, color: Color, offset: Position<i32>, ) -> Self
Create a free image from a set of pixels with a certain color. All other pixels will be set to transparent. If the pixels provided are offset by a certain amount, an offset can be passed so that they are discounted from the original pixel positions. If there is no offset, it should be (0, 0).
Sourcepub fn line_preview(p0: Point<i32>, p: Point<i32>, color: Color) -> Self
pub fn line_preview(p0: Point<i32>, p: Point<i32>, color: Color) -> Self
Creates a free image with a line between two points in a certain color.
Sourcepub fn rect_preview(p0: Point<i32>, p: Point<i32>, color: Color) -> Self
pub fn rect_preview(p0: Point<i32>, p: Point<i32>, color: Color) -> Self
Creates a free image with a rectangle between two points in a certain color.
Sourcepub fn move_by_pivot(&mut self, p: Point<i32>)
pub fn move_by_pivot(&mut self, p: Point<i32>)
Change the position of the free image considering that the passed point is the mouse position where it was released, and that the initial mouse position is defined by the pivot.
Sourcepub fn flip_horizontally(&mut self)
pub fn flip_horizontally(&mut self)
Flips the free image horizontally
Sourcepub fn flip_vertically(&mut self)
pub fn flip_vertically(&mut self)
Flips the free image vertically
Trait Implementations§
Source§impl<'de, IMG> Deserialize<'de> for FreeImage<IMG>where
IMG: Deserialize<'de>,
impl<'de, IMG> Deserialize<'de> for FreeImage<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 FreeImage<IMG>where
IMG: Freeze,
impl<IMG> RefUnwindSafe for FreeImage<IMG>where
IMG: RefUnwindSafe,
impl<IMG> Send for FreeImage<IMG>where
IMG: Send,
impl<IMG> Sync for FreeImage<IMG>where
IMG: Sync,
impl<IMG> Unpin for FreeImage<IMG>where
IMG: Unpin,
impl<IMG> UnwindSafe for FreeImage<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