proc lerp(a, b: uint8; t: float32): uint8 {...}{.inline, raises: [], tags: [].}
-
+Linearly interpolate between a and b using t.
proc lerp(a, b: ColorRGBA; t: float32): ColorRGBA {...}{.inline, raises: [], tags: [].}
+Linearly interpolate between a and b using t.
+
+
+func lerp(a, b: Color; v: float32): Color {...}{.inline, raises: [], tags: [].}
+
+
+Linearly interpolate between a and b using t.
@@ -196,13 +203,6 @@ Converts a color to premultiplied alpha from straight alpha.
Converts a color from premultiplied alpha to straight alpha.
-
-
-func lerp(a, b: Color; v: float32): Color {...}{.inline, raises: [], tags: [].}
-
-
-
-
proc toPremultipliedAlpha(c: Color): Color {...}{.inline, raises: [], tags: [].}
@@ -228,7 +228,7 @@ Converts a color from premultiplied alpha to straight alpha.
- Made with Nim. Generated: 2021-02-25 14:52:03 UTC
+ Made with Nim. Generated: 2021-02-25 15:05:38 UTC
diff --git a/docs/pixie/common.idx b/docs/pixie/common.idx
index 38e3261..74e5e8a 100644
--- a/docs/pixie/common.idx
+++ b/docs/pixie/common.idx
@@ -2,8 +2,8 @@ PixieError pixie/common.html#PixieError common: PixieError
fractional pixie/common.html#fractional,float32 common: fractional(v: float32): float32
lerp pixie/common.html#lerp,uint8,uint8,float32 common: lerp(a, b: uint8; t: float32): uint8
lerp pixie/common.html#lerp,ColorRGBA,ColorRGBA,float32 common: lerp(a, b: ColorRGBA; t: float32): ColorRGBA
+lerp pixie/common.html#lerp,Color,Color,float32 common: lerp(a, b: Color; v: float32): Color
toPremultipliedAlpha pixie/common.html#toPremultipliedAlpha,ColorRGBA common: toPremultipliedAlpha(c: ColorRGBA): ColorRGBA
toStraightAlpha pixie/common.html#toStraightAlpha,ColorRGBA common: toStraightAlpha(c: ColorRGBA): ColorRGBA
-lerp pixie/common.html#lerp,Color,Color,float32 common: lerp(a, b: Color; v: float32): Color
toPremultipliedAlpha pixie/common.html#toPremultipliedAlpha,Color common: toPremultipliedAlpha(c: Color): Color
toStraightAlpha pixie/common.html#toStraightAlpha,Color common: toStraightAlpha(c: Color): Color
diff --git a/docs/pixie/fileformats/bmp.html b/docs/pixie/fileformats/bmp.html
index c036c8d..e8eb33f 100644
--- a/docs/pixie/fileformats/bmp.html
+++ b/docs/pixie/fileformats/bmp.html
@@ -165,7 +165,7 @@ Decodes bitmap data into an Image.
proc decodeBmp(data: seq[uint8]): Image {...}{.inline, raises: [PixieError], tags: [].}
-
+Decodes bitmap data into an Image.
@@ -185,7 +185,7 @@ Encodes an image into the BMP file format.
- Made with Nim. Generated: 2021-02-25 14:52:04 UTC
+ Made with Nim. Generated: 2021-02-25 15:05:39 UTC
diff --git a/docs/pixie/fileformats/jpg.html b/docs/pixie/fileformats/jpg.html
index 4be6cfb..00fef9f 100644
--- a/docs/pixie/fileformats/jpg.html
+++ b/docs/pixie/fileformats/jpg.html
@@ -165,14 +165,14 @@ Decodes the JPEG into an Image.
proc decodeJpg(data: string): Image {...}{.inline, raises: [PixieError], tags: [].}
-
+Decodes the JPEG data into an Image.
proc encodeJpg(image: Image): string {...}{.raises: [PixieError], tags: [].}
-
+Encodes Image into a JPEG data string.
@@ -185,7 +185,7 @@ Decodes the JPEG into an Image.
- Made with Nim. Generated: 2021-02-25 14:52:04 UTC
+ Made with Nim. Generated: 2021-02-25 15:05:39 UTC
diff --git a/docs/pixie/fileformats/png.html b/docs/pixie/fileformats/png.html
index 7484c30..78e5879 100644
--- a/docs/pixie/fileformats/png.html
+++ b/docs/pixie/fileformats/png.html
@@ -162,14 +162,14 @@ window.addEventListener('DOMContentLoaded', main);
proc decodePng(data: seq[uint8]): Image {...}{.raises: [PixieError], tags: [].}
-Decodes the PNG into an Image.
+Decodes the PNG data into an Image.
proc decodePng(data: string): Image {...}{.inline, raises: [PixieError], tags: [].}
-
+Decodes the PNG data into an Image.
@@ -204,7 +204,7 @@ Encodes the mask data into the PNG file format.
- Made with Nim. Generated: 2021-02-25 14:52:04 UTC
+ Made with Nim. Generated: 2021-02-25 15:05:39 UTC
diff --git a/docs/pixie/fileformats/svg.html b/docs/pixie/fileformats/svg.html
index d7abdf0..c375a4d 100644
--- a/docs/pixie/fileformats/svg.html
+++ b/docs/pixie/fileformats/svg.html
@@ -174,7 +174,7 @@ Render SVG file and return the image.
- Made with Nim. Generated: 2021-02-25 14:52:05 UTC
+ Made with Nim. Generated: 2021-02-25 15:05:40 UTC
diff --git a/docs/pixie/images.html b/docs/pixie/images.html
index 7bf11b8..c87c71b 100644
--- a/docs/pixie/images.html
+++ b/docs/pixie/images.html
@@ -503,7 +503,7 @@ Draws one image onto another using matrix with color blending.
raises: [PixieError, Exception], tags: [RootEffect].}
-
+Draws one image onto another using a position offset with color blending.
@@ -511,7 +511,7 @@ Draws one image onto another using matrix with color blending.
raises: [PixieError, Exception], tags: [RootEffect].}
-
+Draws a mask onto an image using a matrix with color blending.
@@ -519,7 +519,7 @@ Draws one image onto another using matrix with color blending.
inline, raises: [PixieError, Exception], tags: [RootEffect].}
-
+Draws a mask onto an image using a position offset with color blending.
@@ -527,7 +527,7 @@ Draws one image onto another using matrix with color blending.
raises: [PixieError, Exception], tags: [RootEffect].}
-
+Draws a mask onto a mask using a matrix with color blending.
@@ -535,7 +535,7 @@ Draws one image onto another using matrix with color blending.
raises: [PixieError, Exception], tags: [RootEffect].}
-
+Draws a mask onto a mask using a position offset with color blending.
@@ -543,7 +543,7 @@ Draws one image onto another using matrix with color blending.
raises: [PixieError, Exception], tags: [RootEffect].}
-
+Draws a image onto a mask using a matrix with color blending.
@@ -551,7 +551,7 @@ Draws one image onto another using matrix with color blending.
inline, raises: [PixieError, Exception], tags: [RootEffect].}
-
+Draws a image onto a mask using a position offset with color blending.
@@ -579,7 +579,7 @@ Shifts the target by offset.
- Made with Nim. Generated: 2021-02-25 14:52:04 UTC
+ Made with Nim. Generated: 2021-02-25 15:05:38 UTC
diff --git a/docs/pixie/masks.html b/docs/pixie/masks.html
index 57ec4b5..a937d8f 100644
--- a/docs/pixie/masks.html
+++ b/docs/pixie/masks.html
@@ -357,7 +357,7 @@ A value of 0 stays 0. Anything else turns into 255.
- Made with Nim. Generated: 2021-02-25 14:52:04 UTC
+ Made with Nim. Generated: 2021-02-25 15:05:38 UTC
diff --git a/docs/pixie/paints.html b/docs/pixie/paints.html
index e0fcc6e..33dc305 100644
--- a/docs/pixie/paints.html
+++ b/docs/pixie/paints.html
@@ -272,7 +272,7 @@ Angular gradient.
- Made with Nim. Generated: 2021-02-25 14:52:05 UTC
+ Made with Nim. Generated: 2021-02-25 15:05:39 UTC
diff --git a/docs/pixie/paths.html b/docs/pixie/paths.html
index 7cc4b99..c3e2d04 100644
--- a/docs/pixie/paths.html
+++ b/docs/pixie/paths.html
@@ -628,7 +628,7 @@ Return elements in pairs: (1st, 2nd), (2nd, 3rd) ... (n - 1, last).
- Made with Nim. Generated: 2021-02-25 14:52:05 UTC
+ Made with Nim. Generated: 2021-02-25 15:05:39 UTC
diff --git a/docs/theindex.html b/docs/theindex.html
index 0fd7ff7..18b8505 100644
--- a/docs/theindex.html
+++ b/docs/theindex.html
@@ -917,7 +917,7 @@ window.addEventListener('DOMContentLoaded', main);
- Made with Nim. Generated: 2021-02-25 14:52:05 UTC
+ Made with Nim. Generated: 2021-02-25 15:05:40 UTC
diff --git a/src/pixie/common.nim b/src/pixie/common.nim
index ab0f957..5158209 100644
--- a/src/pixie/common.nim
+++ b/src/pixie/common.nim
@@ -10,16 +10,25 @@ proc fractional*(v: float32): float32 {.inline.} =
result = result - floor(result)
proc lerp*(a, b: uint8, t: float32): uint8 {.inline.} =
+ ## Linearly interpolate between a and b using t.
let t = round(t * 255).uint32
((a * (255 - t) + b * t) div 255).uint8
proc lerp*(a, b: ColorRGBA, t: float32): ColorRGBA {.inline.} =
+ ## Linearly interpolate between a and b using t.
let x = round(t * 255).uint32
result.r = ((a.r.uint32 * (255 - x) + b.r.uint32 * x) div 255).uint8
result.g = ((a.g.uint32 * (255 - x) + b.g.uint32 * x) div 255).uint8
result.b = ((a.b.uint32 * (255 - x) + b.b.uint32 * x) div 255).uint8
result.a = ((a.a.uint32 * (255 - x) + b.a.uint32 * x) div 255).uint8
+func lerp*(a, b: Color, v: float32): Color {.inline.} =
+ ## Linearly interpolate between a and b using t.
+ result.r = lerp(a.r, b.r, v)
+ result.g = lerp(a.g, b.g, v)
+ result.b = lerp(a.b, b.b, v)
+ result.a = lerp(a.a, b.a, v)
+
proc toPremultipliedAlpha*(c: ColorRGBA): ColorRGBA {.inline.} =
## Converts a color to premultiplied alpha from straight alpha.
result.r = ((c.r.uint32 * c.a.uint32) div 255).uint8
@@ -36,12 +45,6 @@ proc toStraightAlpha*(c: ColorRGBA): ColorRGBA {.inline.} =
result.g = ((result.g.uint32 * multiplier) div 255).uint8
result.b = ((result.b.uint32 * multiplier) div 255).uint8
-func lerp*(a, b: Color, v: float32): Color {.inline.} =
- result.r = lerp(a.r, b.r, v)
- result.g = lerp(a.g, b.g, v)
- result.b = lerp(a.b, b.b, v)
- result.a = lerp(a.a, b.a, v)
-
proc toPremultipliedAlpha*(c: Color): Color {.inline.} =
## Converts a color to premultiplied alpha from straight alpha.
result.r = c.r * c.a
diff --git a/src/pixie/fileformats/bmp.nim b/src/pixie/fileformats/bmp.nim
index 5be8d1f..546e635 100644
--- a/src/pixie/fileformats/bmp.nim
+++ b/src/pixie/fileformats/bmp.nim
@@ -49,6 +49,7 @@ proc decodeBmp*(data: string): Image =
result[x, result.height - y - 1] = rgba
proc decodeBmp*(data: seq[uint8]): Image {.inline.} =
+ ## Decodes bitmap data into an Image.
decodeBmp(cast[string](data))
proc encodeBmp*(image: Image): string =
diff --git a/src/pixie/fileformats/jpg.nim b/src/pixie/fileformats/jpg.nim
index 9cd1b37..fddc06a 100644
--- a/src/pixie/fileformats/jpg.nim
+++ b/src/pixie/fileformats/jpg.nim
@@ -20,7 +20,9 @@ proc decodeJpg*(data: seq[uint8]): Image =
copyMem(result.data[0].addr, pixels[0].unsafeAddr, pixels.len)
proc decodeJpg*(data: string): Image {.inline.} =
+ ## Decodes the JPEG data into an Image.
decodeJpg(cast[seq[uint8]](data))
proc encodeJpg*(image: Image): string =
+ ## Encodes Image into a JPEG data string.
raise newException(PixieError, "Encoding JPG not supported yet")
diff --git a/src/pixie/fileformats/png.nim b/src/pixie/fileformats/png.nim
index 0f2d9d3..1304838 100644
--- a/src/pixie/fileformats/png.nim
+++ b/src/pixie/fileformats/png.nim
@@ -303,7 +303,7 @@ proc decodeImageData(
discard # Not possible, parseHeader validates
proc decodePng*(data: seq[uint8]): Image =
- ## Decodes the PNG into an Image.
+ ## Decodes the PNG data into an Image.
if data.len < (8 + (8 + 13 + 4) + 4): # Magic bytes + IHDR + IEND
failInvalid()
@@ -413,6 +413,7 @@ proc decodePng*(data: seq[uint8]): Image =
result.data = decodeImageData(header, palette, transparency, imageData)
proc decodePng*(data: string): Image {.inline.} =
+ ## Decodes the PNG data into an Image.
decodePng(cast[seq[uint8]](data))
proc encodePng*(
diff --git a/src/pixie/images.nim b/src/pixie/images.nim
index 36d365e..f0cd02e 100644
--- a/src/pixie/images.nim
+++ b/src/pixie/images.nim
@@ -804,35 +804,35 @@ proc draw*(a, b: Image, mat: Mat3, blendMode = bmNormal) {.inline.} =
a.drawUber(b, mat, blendMode)
proc draw*(a, b: Image, pos = vec2(0, 0), blendMode = bmNormal) {.inline.} =
- # Draws one image onto another using a position offset with color blending.
+ ## Draws one image onto another using a position offset with color blending.
a.draw(b, translate(pos), blendMode)
proc draw*(image: Image, mask: Mask, mat: Mat3, blendMode = bmMask) {.inline.} =
- # Draws a mask onto an image using a matrix with color blending.
+ ## Draws a mask onto an image using a matrix with color blending.
image.drawUber(mask, mat, blendMode)
proc draw*(
image: Image, mask: Mask, pos = vec2(0, 0), blendMode = bmMask
) {.inline.} =
- # Draws a mask onto an image using a position offset with color blending.
+ ## Draws a mask onto an image using a position offset with color blending.
image.drawUber(mask, translate(pos), blendMode)
proc draw*(a, b: Mask, mat: Mat3, blendMode = bmMask) {.inline.} =
- # Draws a mask onto a mask using a matrix with color blending.
+ ## Draws a mask onto a mask using a matrix with color blending.
a.drawUber(b, mat, blendMode)
proc draw*(a, b: Mask, pos = vec2(0, 0), blendMode = bmMask) {.inline.} =
- # Draws a mask onto a mask using a position offset with color blending.
+ ## Draws a mask onto a mask using a position offset with color blending.
a.draw(b, translate(pos), blendMode)
proc draw*(mask: Mask, image: Image, mat: Mat3, blendMode = bmMask) {.inline.} =
- # Draws a image onto a mask using a matrix with color blending.
+ ## Draws a image onto a mask using a matrix with color blending.
mask.drawUber(image, mat, blendMode)
proc draw*(
mask: Mask, image: Image, pos = vec2(0, 0), blendMode = bmMask
) {.inline.} =
- # Draws a image onto a mask using a position offset with color blending.
+ ## Draws a image onto a mask using a position offset with color blending.
mask.draw(image, translate(pos), blendMode)
proc resize*(srcImage: Image, width, height: int): Image =
|