pixie/images

Types

Image = ref object
  width*, height*: int
  data*: seq[ColorRGBX]
Image object that holds bitmap data in RGBA format.   Source Edit

Procs

proc newImage(width, height: int): Image {...}{.raises: [PixieError], tags: [].}
Creates a new image with the parameter dimensions.   Source Edit
proc newImage(mask: Mask): Image {...}{.raises: [PixieError], tags: [].}
  Source Edit
proc copy(image: Image): Image {...}{.raises: [PixieError], tags: [].}
Copies the image data into a new image.   Source Edit
proc `$`(image: Image): string {...}{.raises: [], tags: [].}
Prints the image size.   Source Edit
proc inside(image: Image; x, y: int): bool {...}{.inline, raises: [], tags: [].}
Returns true if (x, y) is inside the image.   Source Edit
proc dataIndex(image: Image; x, y: int): int {...}{.inline, raises: [], tags: [].}
  Source Edit
proc getRgbaUnsafe(image: Image; x, y: int): ColorRGBX {...}{.inline, raises: [],
    tags: [].}
Gets a color 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 `[]`(image: Image; x, y: int): ColorRGBX {...}{.inline, raises: [], tags: [].}
Gets a pixel at (x, y) or returns transparent black if outside of bounds.   Source Edit
proc getColor(image: Image; x, y: int): Color {...}{.inline, raises: [], tags: [].}
Gets a color at (x, y) or returns transparent black if outside of bounds.   Source Edit
proc setRgbaUnsafe(image: Image; x, y: int; color: SomeColor) {...}{.inline,
    raises: [].}
Sets a color 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 `[]=`(image: Image; x, y: int; color: SomeColor) {...}{.inline, raises: [].}
Sets a pixel at (x, y) or does nothing if outside of bounds.   Source Edit
proc setColor(image: Image; x, y: int; color: Color) {...}{.inline, raises: [],
    tags: [].}
Sets a color at (x, y) or does nothing if outside of bounds.   Source Edit
proc fillUnsafe(data: var seq[ColorRGBX]; color: SomeColor; start, len: int) {...}{.
    raises: [].}
Fills the image data with the parameter color starting at index start and continuing for len indices.   Source Edit
proc fill(image: Image; color: SomeColor) {...}{.inline, raises: [].}
Fills the image with the parameter color.   Source Edit
proc isOneColor(image: Image): bool {...}{.raises: [], tags: [].}
Checks if the entire image is the same color.   Source Edit
proc isTransparent(image: Image): bool {...}{.raises: [], tags: [].}
Checks if this image is fully transparent or not.   Source Edit
proc flipHorizontal(image: Image) {...}{.raises: [], tags: [].}
Flips the image around the Y axis.   Source Edit
proc flipVertical(image: Image) {...}{.raises: [], tags: [].}
Flips the image around the X axis.   Source Edit
proc subImage(image: Image; x, y, w, h: int): Image {...}{.raises: [PixieError],
    tags: [].}
Gets a sub image from this image.   Source Edit
proc diff(master, image: Image): (float32, Image) {...}{.raises: [PixieError],
    tags: [].}
Compares the parameters and returns a score and image of the difference.   Source Edit
proc minifyBy2(image: Image; power = 1): Image {...}{.raises: [PixieError], tags: [].}
Scales the image down by an integer scale.   Source Edit
proc magnifyBy2(image: Image; power = 1): Image {...}{.raises: [PixieError], tags: [].}
Scales image up by 2 ^ power.   Source Edit
proc applyOpacity(target: Image | Mask; opacity: float32) {...}{.raises: [].}
Multiplies alpha of the image by opacity.   Source Edit
proc invert(target: Image | Mask) {...}{.raises: [].}
Inverts all of the colors and alpha.   Source Edit
proc blur(image: Image; radius: float32;
          outOfBounds: SomeColor = color(0, 0, 0, 0)) {...}{.raises: [PixieError].}
Applies Gaussian blur to the image given a radius.   Source Edit
proc newMask(image: Image): Mask {...}{.raises: [PixieError], tags: [].}
Returns a new mask using the alpha values of the parameter image.   Source Edit
proc getRgbaSmooth(image: Image; x, y: float32; wrapped = false): ColorRGBX {...}{.
    raises: [], tags: [].}
Gets a interpolated color with float point coordinates. Pixels outside the image are transparent.   Source Edit
proc draw(a, b: Image; transform = mat3(); blendMode = bmNormal) {...}{.inline,
    raises: [PixieError], tags: [RootEffect].}
Draws one image onto another using matrix with color blending.   Source Edit
proc draw(a, b: Mask; transform = mat3(); blendMode = bmMask) {...}{.inline,
    raises: [PixieError], tags: [RootEffect].}
Draws a mask onto a mask using a matrix with color blending.   Source Edit
proc draw(image: Image; mask: Mask; transform = mat3(); blendMode = bmMask) {...}{.
    inline, raises: [PixieError], tags: [RootEffect].}
Draws a mask onto an image using a matrix with color blending.   Source Edit
proc draw(mask: Mask; image: Image; transform = mat3(); blendMode = bmMask) {...}{.
    inline, raises: [PixieError], tags: [RootEffect].}
Draws a image onto a mask using a matrix with color blending.   Source Edit
proc drawTiled(dst, src: Image; mat: Mat3; blendMode = bmNormal) {...}{.
    raises: [PixieError], tags: [RootEffect].}
  Source Edit
proc resize(srcImage: Image; width, height: int): Image {...}{.raises: [PixieError],
    tags: [RootEffect].}
Resize an image to a given height and width.   Source Edit
proc shadow(image: Image; offset: Vec2; spread, blur: float32; color: SomeColor): Image {...}{.
    raises: [PixieError].}
Create a shadow of the image with the offset, spread and blur.   Source Edit
proc superImage(image: Image; x, y, w, h: int): Image {...}{.raises: [PixieError],
    tags: [RootEffect].}
Either cuts a sub image or returns a super image with padded transparency.   Source Edit