pub struct Placement {
pub width: u32,
pub height: u32,
pub scale: (f64, f64),
pub center: (f64, f64),
pub corners: [(f64, f64); 4],
}Expand description
The placement of an image material.
Fields§
§width: u32Width of the original image in pixels.
height: u32Height of the original image in pixels.
scale: (f64, f64)Scale (x, y) as stored; the corners are what is drawn.
center: (f64, f64)Centre in layer pixels.
corners: [(f64, f64); 4]Where (0, 0), (w, 0), (0, h) and (w, h) of the original go.
Implementations§
Source§impl Placement
impl Placement
Sourcepub fn draw(
&self,
original: &RgbaImage,
level_scale: f64,
offset: (f64, f64),
width: u32,
height: u32,
scale: f64,
) -> Option<RgbaImage>
pub fn draw( &self, original: &RgbaImage, level_scale: f64, offset: (f64, f64), width: u32, height: u32, scale: f64, ) -> Option<RgbaImage>
Draw original (the original image read at level_scale of its
full size) placed on a width × height output at scale of the
canvas, with the corners moved by the layer’s offset.
Sourcepub fn bounds(&self, offset: (f64, f64), scale: f64) -> (i64, i64, i64, i64)
pub fn bounds(&self, offset: (f64, f64), scale: f64) -> (i64, i64, i64, i64)
The output pixels the placed image can cover, (x0, y0, x1, y1), at
scale of the canvas (not clipped to any output).
Sourcepub fn draw_region(
&self,
original: &RgbaImage,
level_scale: f64,
offset: (f64, f64),
region: (u32, u32, u32, u32),
scale: f64,
) -> Option<RgbaImage>
pub fn draw_region( &self, original: &RgbaImage, level_scale: f64, offset: (f64, f64), region: (u32, u32, u32, u32), scale: f64, ) -> Option<RgbaImage>
Placement::draw for the part (left, top, width, height) of the
output only: the result is width × height with its top-left at
output pixel (left, top).
Sourcepub fn magnification(&self) -> f64
pub fn magnification(&self) -> f64
How much the original is scaled on the canvas (the larger side).