pub struct PaintMaps { /* private fields */ }Expand description
All painted masks of the running editor / game, by name.
Implementations§
Source§impl PaintMaps
impl PaintMaps
Sourcepub fn global() -> &'static PaintMaps
pub fn global() -> &'static PaintMaps
The process-wide registry (the renderer reads masks from here).
Sourcepub fn create(&self, name: &str, width: u32, height: u32)
pub fn create(&self, name: &str, width: u32, height: u32)
Creates an empty mask (all base layer) unless one exists.
Sourcepub fn load_or_create(&self, name: &str, assets: &Assets, size: u32)
pub fn load_or_create(&self, name: &str, assets: &Assets, size: u32)
Loads paint/<name>.png from the project, or creates a fresh mask.
Sourcepub fn snapshot(&self, name: &str) -> Option<([u32; 2], Vec<u8>, u64)>
pub fn snapshot(&self, name: &str) -> Option<([u32; 2], Vec<u8>, u64)>
(size, pixels, version) of a mask, for uploading to the GPU.
Sourcepub fn restore(&self, name: &str, size: [u32; 2], rgba: Vec<u8>) -> bool
pub fn restore(&self, name: &str, size: [u32; 2], rgba: Vec<u8>) -> bool
Restores an undo snapshot, incrementing the version so the renderer uploads it again. Rejects empty/oversized images and mismatched RGBA lengths without changing the map.
Sourcepub fn brush(
&self,
name: &str,
uv: [f32; 2],
radius: f32,
strength: f32,
hardness: f32,
mode: BrushMode,
)
pub fn brush( &self, name: &str, uv: [f32; 2], radius: f32, strength: f32, hardness: f32, mode: BrushMode, )
Applies one brush dab at uv (0..1). radius is in uv units, strength 0..1 per dab,
hardness 0 (soft falloff) .. 1 (hard edge).
Sourcepub fn fill(&self, name: &str, layer: usize)
pub fn fill(&self, name: &str, layer: usize)
Fills the whole mask with one layer (a quick base coat).
Sourcepub fn save_all(&self, assets_dir: &Path) -> usize
pub fn save_all(&self, assets_dir: &Path) -> usize
Writes every edited mask to <assets>/paint/<name>.png. Returns how many were saved.
Sourcepub fn dirty_names(&self) -> Vec<String>
pub fn dirty_names(&self) -> Vec<String>
Names of masks with unsaved edits.
Auto Trait Implementations§
impl !Freeze for PaintMaps
impl RefUnwindSafe for PaintMaps
impl Send for PaintMaps
impl Sync for PaintMaps
impl Unpin for PaintMaps
impl UnsafeUnpin for PaintMaps
impl UnwindSafe for PaintMaps
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
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSend for T
impl<T> DowncastSend for T
§impl<T> DowncastSync for T
impl<T> DowncastSync for 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 moreimpl<T> MaybeSync for T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.