pixie/masks

Types

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

Procs

proc newMask(width, height: int): Mask {...}{.raises: [PixieError], tags: [].}
Creates a new mask with the parameter dimensions.   Source Edit
proc copy(mask: Mask): Mask {...}{.raises: [PixieError], tags: [].}
Copies the image data into a new image.   Source Edit
proc `$`(mask: Mask): string {...}{.raises: [], tags: [].}
Prints the mask size.   Source Edit
proc inside(mask: Mask; x, y: int): bool {...}{.inline, raises: [], tags: [].}
Returns true if (x, y) is inside the mask.   Source Edit
proc dataIndex(mask: Mask; x, y: int): int {...}{.inline, raises: [], tags: [].}
  Source Edit
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.

  Source Edit
proc `[]`(mask: Mask; x, y: int): uint8 {...}{.inline, raises: [], tags: [].}
Gets a value at (x, y) or returns transparent black if outside of bounds.   Source Edit
proc getValue(mask: Mask; x, y: int): uint8 {...}{.inline, raises: [], tags: [].}
Gets a value at (x, y) or returns transparent black if outside of bounds.   Source Edit
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.

  Source Edit
proc `[]=`(mask: Mask; x, y: int; value: uint8) {...}{.inline, raises: [], tags: [].}
Sets a value at (x, y) or does nothing if outside of bounds.   Source Edit
proc setValue(mask: Mask; x, y: int; value: uint8) {...}{.inline, raises: [],
    tags: [].}
Sets a value at (x, y) or does nothing if outside of bounds.   Source Edit
proc minifyBy2(mask: Mask; power = 1): Mask {...}{.raises: [PixieError], tags: [].}
Scales the mask down by an integer scale.   Source Edit
proc magnifyBy2(mask: Mask; power = 1): Mask {...}{.raises: [PixieError], tags: [].}
Scales mask up by 2 ^ power.   Source Edit
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.   Source Edit
proc fill(mask: Mask; value: uint8) {...}{.inline, raises: [], tags: [].}
Fills the mask with the parameter value.   Source Edit
proc getValueSmooth(mask: Mask; x, y: float32): uint8 {...}{.raises: [], tags: [].}
Gets a interpolated value with float point coordinates.   Source Edit
proc spread(mask: Mask; spread: float32) {...}{.raises: [PixieError], tags: [].}
Grows the mask by spread.   Source Edit
proc ceil(mask: Mask) {...}{.raises: [], tags: [].}
A value of 0 stays 0. Anything else turns into 255.   Source Edit
proc blur(mask: Mask; radius: float32; outOfBounds: uint8 = 0) {...}{.
    raises: [PixieError], tags: [].}
Applies Gaussian blur to the image given a radius.   Source Edit