pub struct Sprite {
pub image: ImageId,
pub src: PxRect,
pub dest: PxRect,
pub clip: PxRect,
pub layer: Layer,
pub flip_x: bool,
pub opacity: u8,
pub brightness: u8,
pub paint: Paint,
pub base: Option<PxRect>,
}Expand description
A picture on top of the cell grid (game ADR-0038): part of an image file,
scaled into a rectangle of console pixels. app draws it from a texture
with nearest-pixel sampling, so whole-number scales stay sharp.
Fields§
§image: ImageIdWhich image (ImageTable::id).
src: PxRectThe part of the image shown, in image pixels. It must lie inside the image.
dest: PxRectWhere src is stretched to, in console pixels.
clip: PxRectThe part of dest that is drawn. Clipping and cutting only ever
shrink this; src and dest stay as given, so the picture never
shifts or rescales.
layer: LayerUnder or over the glyphs.
flip_x: boolMirrored left to right within dest.
opacity: u8255 = solid; lower lets what is under it show through.
brightness: u8How bright its pixels are drawn: 255 = as the image and the paint
have them, lower = that much darker, 0 = black where it shows.
Unlike a lower opacity, a picture over another (a tile’s edge over
its ground) darkens as much as one alone (GlyphBuffer::fade).
paint: PaintHow its pixels are coloured.
base: Option<PxRect>The console pixels it stands on, for a picture that reaches above them (a unit’s head over the tile above its own): where cells replace its base up to one of the base’s edges, what it shows past that edge goes too, so a menu over a unit doesn’t leave its head showing above the menu.
Implementations§
Source§impl Sprite
impl Sprite
Sourcepub const fn new(
image: ImageId,
src: PxRect,
dest: PxRect,
layer: Layer,
) -> Self
pub const fn new( image: ImageId, src: PxRect, dest: PxRect, layer: Layer, ) -> Self
A solid, unflipped sprite showing all of dest.
Sourcepub fn clipped_src(&self) -> [f32; 4]
pub fn clipped_src(&self) -> [f32; 4]
The part of src that maps to clip, as [x, y, w, h] in image
pixels (fractions of a pixel when clip cuts through a scaled
one). With flip_x, the left of clip shows the right of src.