pixie/masks

  Source   Edit

Types

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

Procs

proc `$`(mask: Mask): string {....raises: [], tags: [].}
Prints the mask size.   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 `[]`(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 applyOpacity(mask: Mask; opacity: float32) {....raises: [], tags: [].}
Multiplies alpha of the image by opacity.   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
proc ceil(mask: Mask) {....raises: [], tags: [].}
A value of 0 stays 0. Anything else turns into 255.   Source   Edit
proc copy(mask: Mask): Mask {....raises: [PixieError], tags: [].}
Copies the image data into a new image.   Source   Edit
proc dataIndex(mask: Mask; x, y: int): int {.inline, ...raises: [], tags: [].}
  Source   Edit
proc fill(mask: Mask; value: uint8) {.inline, ...raises: [], tags: [].}
Fills the mask with the value.   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 getValueSmooth(mask: Mask; x, y: float32): uint8 {....raises: [], tags: [].}
Gets a interpolated value with float point coordinates.   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 invert(mask: Mask) {....raises: [], tags: [].}
Inverts all of the values - creates a negative of the mask.   Source   Edit
proc magnifyBy2(mask: Mask; power = 1): Mask {....raises: [PixieError], tags: [].}
Scales mask up by 2 ^ power.   Source   Edit
proc minifyBy2(mask: Mask; power = 1): Mask {....raises: [PixieError], tags: [].}
Scales the mask down by an integer scale.   Source   Edit
proc newMask(width, height: int): Mask {....raises: [PixieError], tags: [].}
Creates a new mask with the parameter dimensions.   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 spread(mask: Mask; spread: float32) {....raises: [PixieError], tags: [].}
Grows the mask by spread.   Source   Edit

Templates

template `[]=`(view: UnsafeMask; x, y: int; color: uint8)
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
template `[]`(view: UnsafeMask; x, y: int): uint8
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
template unsafe(src: Mask): UnsafeMask
  Source   Edit