Skip to main content

TMask

Struct TMask 

Source
pub struct TMask {
    pub w: u32,
    pub h: u32,
    /* private fields */
}

Fields§

§w: u32§h: u32

Implementations§

Source§

impl TMask

Source

pub fn new(w: u32, h: u32) -> Option<TMask>

a mask of w x h pixels, every pixel 0 (None: bad size) [tm_alloc]

Source

pub fn tiles_x(&self) -> u32

Source

pub fn tiles_y(&self) -> u32

Source

pub fn clear(&mut self, value: u8) -> i32

every pixel = value [tm_clear]

Source

pub fn get(&self, x: i32, y: i32) -> u8

coverage of one pixel (0 outside) [tm_get]

Source

pub fn span(&self, x: i32, y: i32, maxn: i32) -> (Span<'_>, i32)

a run of n (1..maxn) pixels from (x, y) [tm_span]

Source

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]

Source

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]

Source

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]

Source

pub fn tile_set(&mut self, tx: u32, ty: u32, full: bool)

tile (tx, ty) := all 0 / all 255 [tm_tile_set]

Source

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]

Source

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]

Source

pub fn combine(&mut self, src: &TMask, op: u32) -> i32

dst = dst OP src per pixel (same size) [tm_combine]

Source

pub fn combine_self(&mut self, op: u32) -> i32

dst = dst OP dst (tm_combine with the same mask as both operands)

Source

pub fn copy(&mut self, src: &TMask) -> i32

dst = src (same size) [tm_copy]

Source

pub fn invert(&mut self)

v = 255 - v [tm_invert]

Source

pub fn threshold(&mut self, level: i32)

v = v >= level ? 255 : 0 (level clamped to 1..255) [tm_threshold]

Source

pub fn optimize(&mut self)

every uniform tile becomes a sentinel [tm_optimize]

Source

pub fn count_tiles(&self) -> (u32, u32)

(tiles held in memory, slots that are all 255) [tm_count_tiles]

Source

pub fn bbox(&self) -> Option<[i32; 4]>

x0, y0, x1, y1 (exclusive) of the pixels != 0, None when the mask is empty [tm_bbox]

Source

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]

Source

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]

Source

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]

Source

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)

Source

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]

Trait Implementations§

Source§

impl Clone for TMask

Source§

fn clone(&self) -> TMask

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl Forget for TMask

§

impl Freeze for TMask

§

impl RefUnwindSafe for TMask

§

impl Send for TMask

§

impl Sync for TMask

§

impl Unpin for TMask

§

impl UnsafeUnpin for TMask

§

impl UnwindSafe for TMask

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.