pub struct TMask {
pub w: u32,
pub h: u32,
/* private fields */
}Fields§
§w: u32§h: u32Implementations§
Source§impl TMask
impl TMask
Sourcepub fn new(w: u32, h: u32) -> Option<TMask>
pub fn new(w: u32, h: u32) -> Option<TMask>
a mask of w x h pixels, every pixel 0 (None: bad size) [tm_alloc]
pub fn tiles_x(&self) -> u32
pub fn tiles_y(&self) -> u32
Sourcepub fn span(&self, x: i32, y: i32, maxn: i32) -> (Span<'_>, i32)
pub fn span(&self, x: i32, y: i32, maxn: i32) -> (Span<'_>, i32)
a run of n (1..maxn) pixels from (x, y) [tm_span]
Sourcepub fn row<'a>(
&'a self,
x: i32,
y: i32,
n: i32,
buf: &'a mut [u8],
) -> (&'a [u8], bool)
pub fn row<'a>( &'a self, x: i32, y: i32, n: i32, buf: &'a mut [u8], ) -> (&'a [u8], bool)
the n bytes of (x .. x+n-1, y): (bytes, true when they are buf) [tm_row]
Sourcepub fn row_w(&mut self, x: i32, y: i32) -> Option<&mut [u8]>
pub fn row_w(&mut self, x: i32, y: i32) -> Option<&mut [u8]>
writable bytes from (x, y) to the end of its tile row (at most w - x) [tm_row_w]
Sourcepub fn tile_w(&mut self, tx: u32, ty: u32) -> Option<&mut [u8]>
pub fn tile_w(&mut self, tx: u32, ty: u32) -> Option<&mut [u8]>
writable 64 x 64 tile (materialised with its content) [tm_tile_w]
Sourcepub fn tile_set(&mut self, tx: u32, ty: u32, full: bool)
pub fn tile_set(&mut self, tx: u32, ty: u32, full: bool)
tile (tx, ty) := all 0 / all 255 [tm_tile_set]
Sourcepub fn fill_rect(
&mut self,
x0: i32,
y0: i32,
x1: i32,
y1: i32,
value: u8,
) -> i32
pub fn fill_rect( &mut self, x0: i32, y0: i32, x1: i32, y1: i32, value: u8, ) -> i32
set the pixels of the rectangle (x1, y1 exclusive, clipped) to value; whole tiles of 0 / 255 become sentinels [tm_fill_rect]
Sourcepub fn combine_block(
&mut self,
tx: u32,
ty: u32,
src: Block<'_>,
op: u32,
) -> i32
pub fn combine_block( &mut self, tx: u32, ty: u32, src: Block<'_>, op: u32, ) -> i32
combine a 64 x 64 block into tile (tx, ty) [tm_combine_block]
Sourcepub fn combine(&mut self, src: &TMask, op: u32) -> i32
pub fn combine(&mut self, src: &TMask, op: u32) -> i32
dst = dst OP src per pixel (same size) [tm_combine]
Sourcepub fn combine_self(&mut self, op: u32) -> i32
pub fn combine_self(&mut self, op: u32) -> i32
dst = dst OP dst (tm_combine with the same mask as both operands)
Sourcepub fn threshold(&mut self, level: i32)
pub fn threshold(&mut self, level: i32)
v = v >= level ? 255 : 0 (level clamped to 1..255) [tm_threshold]
Sourcepub fn count_tiles(&self) -> (u32, u32)
pub fn count_tiles(&self) -> (u32, u32)
(tiles held in memory, slots that are all 255) [tm_count_tiles]
Sourcepub fn bbox(&self) -> Option<[i32; 4]>
pub fn bbox(&self) -> Option<[i32; 4]>
x0, y0, x1, y1 (exclusive) of the pixels != 0, None when the mask is empty [tm_bbox]
Sourcepub fn load_a8(&mut self, src: &[u8], stride: usize) -> i32
pub fn load_a8(&mut self, src: &[u8], stride: usize) -> i32
the mask becomes a copy of the dense w x h A8 image at src (row stride stride) [tm_load_a8]
Sourcepub fn store_a8(&self, dst: &mut [u8], stride: usize)
pub fn store_a8(&self, dst: &mut [u8], stride: usize)
write the mask as a dense w x h A8 image (row stride stride) [tm_store_a8]
Sourcepub fn raster_path(
&mut self,
path: &Path,
ras: &mut Raster,
rule: u32,
op: u32,
) -> i32
pub fn raster_path( &mut self, path: &Path, ras: &mut Raster, rule: u32, op: u32, ) -> i32
rasterize the path (subpaths closed implicitly, rule RULE_) with exact anti-aliased coverage and combine it into the mask with op (TM_) [tm_raster_path]
Sourcepub fn raster_polygon(
&mut self,
path: &mut Path,
ras: &mut Raster,
pts: &[(f32, f32)],
rule: u32,
op: u32,
) -> i32
pub fn raster_polygon( &mut self, path: &mut Path, ras: &mut Raster, pts: &[(f32, f32)], rule: u32, op: u32, ) -> i32
raster_path of one closed polygon given as points in mask pixels (replaces the path)
Sourcepub fn trace(&self, cb: &mut dyn FnMut(&[(i32, i32)]) -> i32) -> i32
pub fn trace(&self, cb: &mut dyn FnMut(&[(i32, i32)]) -> i32) -> i32
outlines of the pixels with coverage >= 128 along pixel edges: cb(points) for every closed contour (corners in pixel-edge coordinates, implicitly closed, inside on the right); returns 0 or the first nonzero cb result [tm_trace]