pixie/masks

Types

Mask = ref object
  width*, height*: int
  data*: seq[uint8]
Mask object that holds mask opacity data.

Procs

proc newMask(width, height: int): Mask {...}{.raises: [PixieError], tags: [].}
Creates a new mask with the parameter dimensions.
proc wh(mask: Mask): Vec2 {...}{.inline, raises: [], tags: [].}
Return with and height as a size vector.
proc copy(mask: Mask): Mask {...}{.raises: [PixieError], tags: [].}
Copies the image data into a new image.
proc `$`(mask: Mask): string {...}{.raises: [], tags: [].}
Prints the mask size.
proc inside(mask: Mask; x, y: int): bool {...}{.inline, raises: [], tags: [].}
Returns true if (x, y) is inside the mask.
proc dataIndex(mask: Mask; x, y: int): int {...}{.inline, raises: [], tags: [].}
proc getValueUnsafe(mask: Mask; x, y: int): uint8 {...}{.inline, raises: [], tags: [].}
Gets a value from (x, y) coordinates.
  • No bounds checking *

Make sure that x, y are in bounds. Failure in the assumptions will case unsafe memory reads.

proc `[]`(mask: Mask; x, y: int): uint8 {...}{.inline, raises: [], tags: [].}
Gets a pixel at (x, y) or returns transparent black if outside of bounds.
proc setValueUnsafe(mask: Mask; x, y: int; value: uint8) {...}{.inline, raises: [],
    tags: [].}
Sets a value from (x, y) coordinates.
  • No bounds checking *

Make sure that x, y are in bounds. Failure in the assumptions will case unsafe memory writes.

proc `[]=`(mask: Mask; x, y: int; value: uint8) {...}{.inline, raises: [], tags: [].}
Sets a value at (x, y) or does nothing if outside of bounds.
proc minifyBy2(mask: Mask; power = 1): Mask {...}{.raises: [PixieError], tags: [].}
Scales the mask down by an integer scale.
proc fillUnsafe(data: var seq[uint8]; value: uint8; start, len: int) {...}{.
    raises: [], tags: [].}
Fills the mask data with the parameter value starting at index start and continuing for len indices.
proc fill(mask: Mask; value: uint8) {...}{.inline, raises: [], tags: [].}
Fills the mask with the parameter value.
proc getValueSmooth(mask: Mask; x, y: float32): uint8 {...}{.raises: [], tags: [].}
Gets a interpolated value with float point coordinates.
proc spread(mask: Mask; spread: float32) {...}{.raises: [PixieError], tags: [].}
Grows the mask by spread.
proc ceil(mask: Mask) {...}{.raises: [], tags: [].}
A value of 0 stays 0. Anything else turns into 255.
proc blur(mask: Mask; radius: float32; outOfBounds: uint8 = 0) {...}{.
    raises: [PixieError], tags: [].}
Applies Gaussian blur to the image given a radius.