diff --git a/docs/pixie.html b/docs/pixie.html
index 0f7bd60..e5b7127 100644
--- a/docs/pixie.html
+++ b/docs/pixie.html
@@ -533,7 +533,7 @@ Strokes a polygon.
- Made with Nim. Generated: 2021-02-25 15:05:40 UTC
+ Made with Nim. Generated: 2021-02-25 15:15:51 UTC
diff --git a/docs/pixie/blends.html b/docs/pixie/blends.html
index 6a30bd4..64a41cd 100644
--- a/docs/pixie/blends.html
+++ b/docs/pixie/blends.html
@@ -239,7 +239,7 @@ window.addEventListener('DOMContentLoaded', main);
proc blendAlpha(backdrop, source: uint8): uint8 {...}{.inline, raises: [], tags: [].}
-
+Blends alphas of backdrop, source.
@@ -282,7 +282,7 @@ Unpack the first 32 bits into 4 rgba(0, 0, 0, value)
proc hasSimdBlender(blendMode: BlendMode): bool {...}{.raises: [], tags: [].}
-
+Is there a blend function for a given blend mode with SIMD support?
@@ -297,7 +297,7 @@ Unpack the first 32 bits into 4 rgba(0, 0, 0, value)
proc hasSimdMasker(blendMode: BlendMode): bool {...}{.raises: [], tags: [].}
-
+Is there a blend masking function with SIMD support?
@@ -310,7 +310,7 @@ Unpack the first 32 bits into 4 rgba(0, 0, 0, value)
- Made with Nim. Generated: 2021-02-25 15:05:38 UTC
+ Made with Nim. Generated: 2021-02-25 15:15:49 UTC
diff --git a/docs/pixie/common.html b/docs/pixie/common.html
index 93386a5..92130b8 100644
--- a/docs/pixie/common.html
+++ b/docs/pixie/common.html
@@ -228,7 +228,7 @@ Converts a color from premultiplied alpha to straight alpha.
- Made with Nim. Generated: 2021-02-25 15:05:38 UTC
+ Made with Nim. Generated: 2021-02-25 15:15:49 UTC
diff --git a/docs/pixie/fileformats/bmp.html b/docs/pixie/fileformats/bmp.html
index e8eb33f..c75b463 100644
--- a/docs/pixie/fileformats/bmp.html
+++ b/docs/pixie/fileformats/bmp.html
@@ -185,7 +185,7 @@ Encodes an image into the BMP file format.
- Made with Nim. Generated: 2021-02-25 15:05:39 UTC
+ Made with Nim. Generated: 2021-02-25 15:15:50 UTC
diff --git a/docs/pixie/fileformats/jpg.html b/docs/pixie/fileformats/jpg.html
index 00fef9f..41ec5eb 100644
--- a/docs/pixie/fileformats/jpg.html
+++ b/docs/pixie/fileformats/jpg.html
@@ -185,7 +185,7 @@ Encodes Image into a JPEG data string.
- Made with Nim. Generated: 2021-02-25 15:05:39 UTC
+ Made with Nim. Generated: 2021-02-25 15:15:50 UTC
diff --git a/docs/pixie/fileformats/png.html b/docs/pixie/fileformats/png.html
index 78e5879..5c34f95 100644
--- a/docs/pixie/fileformats/png.html
+++ b/docs/pixie/fileformats/png.html
@@ -204,7 +204,7 @@ Encodes the mask data into the PNG file format.
- Made with Nim. Generated: 2021-02-25 15:05:39 UTC
+ Made with Nim. Generated: 2021-02-25 15:15:50 UTC
diff --git a/docs/pixie/fileformats/svg.html b/docs/pixie/fileformats/svg.html
index c375a4d..777e3ce 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 15:05:40 UTC
+ Made with Nim. Generated: 2021-02-25 15:15:51 UTC
diff --git a/docs/pixie/images.html b/docs/pixie/images.html
index c87c71b..6147038 100644
--- a/docs/pixie/images.html
+++ b/docs/pixie/images.html
@@ -479,7 +479,7 @@ Returns a new mask using the alpha values of the parameter image.
tags: [].}
-
+Gets a interpolated color with float point coordinates. Pixes outside the image are transparent.
@@ -487,7 +487,7 @@ Returns a new mask using the alpha values of the parameter image.
tags: [].}
-
+Gets a interpolated color with float point coordinates. Pixes outside the image are repeated.
@@ -579,7 +579,7 @@ Shifts the target by offset.
- Made with Nim. Generated: 2021-02-25 15:05:38 UTC
+ Made with Nim. Generated: 2021-02-25 15:15:50 UTC
diff --git a/docs/pixie/masks.html b/docs/pixie/masks.html
index a937d8f..90c6e6c 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 15:05:38 UTC
+ Made with Nim. Generated: 2021-02-25 15:15:49 UTC
diff --git a/docs/pixie/paints.html b/docs/pixie/paints.html
index 33dc305..50446f0 100644
--- a/docs/pixie/paints.html
+++ b/docs/pixie/paints.html
@@ -272,7 +272,7 @@ Angular gradient.
- Made with Nim. Generated: 2021-02-25 15:05:39 UTC
+ Made with Nim. Generated: 2021-02-25 15:15:50 UTC
diff --git a/docs/pixie/paths.html b/docs/pixie/paths.html
index c3e2d04..2bfe4b1 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 15:05:39 UTC
+ Made with Nim. Generated: 2021-02-25 15:15:51 UTC
diff --git a/docs/theindex.html b/docs/theindex.html
index 18b8505..4ad2ce1 100644
--- a/docs/theindex.html
+++ b/docs/theindex.html
@@ -917,7 +917,7 @@ window.addEventListener('DOMContentLoaded', main);
- Made with Nim. Generated: 2021-02-25 15:05:40 UTC
+ Made with Nim. Generated: 2021-02-25 15:15:51 UTC
diff --git a/src/pixie/blends.nim b/src/pixie/blends.nim
index 7c401fb..0e47b06 100644
--- a/src/pixie/blends.nim
+++ b/src/pixie/blends.nim
@@ -45,6 +45,7 @@ proc min(a, b: uint32): uint32 {.inline.} =
if a < b: a else: b
proc alphaFix(backdrop, source, mixed: ColorRGBA): ColorRGBA =
+ ## After mixing an image, adjust its alpha value to be correct.
let
sa = source.a.uint32
ba = backdrop.a.uint32
@@ -67,6 +68,7 @@ proc alphaFix(backdrop, source, mixed: ColorRGBA): ColorRGBA =
result.a = a.uint8
proc alphaFix(backdrop, source, mixed: Color): Color =
+ ## After mixing an image, adjust its alpha value to be correct.
result.a = (source.a + backdrop.a * (1.0 - source.a))
if result.a == 0:
return
@@ -85,6 +87,7 @@ proc alphaFix(backdrop, source, mixed: Color): Color =
result.b /= result.a
proc blendAlpha*(backdrop, source: uint8): uint8 {.inline.} =
+ ## Blends alphas of backdrop, source.
source + ((backdrop.uint32 * (255 - source)) div 255).uint8
proc screen(backdrop, source: uint32): uint8 {.inline.} =
@@ -448,6 +451,7 @@ proc blendWhite(backdrop, source: ColorRGBA): ColorRGBA =
rgba(255, 255, 255, 255)
proc blender*(blendMode: BlendMode): Blender =
+ ## Returns a blend function for a given blend mode.
case blendMode:
of bmNormal: blendNormal
of bmDarken: blendDarken
@@ -494,6 +498,7 @@ proc maskOverwrite(backdrop, source: uint8): uint8 =
source
proc masker*(blendMode: BlendMode): Masker =
+ ## Returns a blend masking function for a given blend masking mode.
case blendMode:
of bmNormal: maskNormal
of bmMask: maskMask
@@ -601,6 +606,7 @@ when defined(amd64) and not defined(pixieNoSimd):
source
proc blenderSimd*(blendMode: BlendMode): BlenderSimd =
+ ## Returns a blend function for a given blend mode with SIMD support.
case blendMode:
of bmNormal: blendNormalSimd
of bmMask: blendMaskSimd
@@ -609,6 +615,7 @@ when defined(amd64) and not defined(pixieNoSimd):
raise newException(PixieError, "No SIMD blender for " & $blendMode)
proc hasSimdBlender*(blendMode: BlendMode): bool =
+ ## Is there a blend function for a given blend mode with SIMD support?
blendMode in {bmNormal, bmMask, bmOverwrite}
proc maskNormalSimd(backdrop, source: M128i): M128i =
@@ -670,6 +677,7 @@ when defined(amd64) and not defined(pixieNoSimd):
mm_or_si128(backdropEven, mm_slli_epi16(backdropOdd, 8))
proc maskerSimd*(blendMode: BlendMode): MaskerSimd =
+ ## Returns a blend masking function with SIMD support.
case blendMode:
of bmNormal: maskNormalSimd
of bmMask: maskMaskSimd
@@ -678,6 +686,7 @@ when defined(amd64) and not defined(pixieNoSimd):
raise newException(PixieError, "No SIMD masker for " & $blendMode)
proc hasSimdMasker*(blendMode: BlendMode): bool =
+ ## Is there a blend masking function with SIMD support?
blendMode in {bmNormal, bmMask, bmOverwrite}
when defined(release):
diff --git a/src/pixie/images.nim b/src/pixie/images.nim
index f0cd02e..0715c70 100644
--- a/src/pixie/images.nim
+++ b/src/pixie/images.nim
@@ -511,6 +511,8 @@ proc newMask*(image: Image): Mask =
result.data[j] = image.data[j].a
proc getRgbaSmooth*(image: Image, x, y: float32): ColorRGBA =
+ ## Gets a interpolated color with float point coordinates.
+ ## Pixes outside the image are transparent.
let
minX = floor(x)
minY = floor(y)
@@ -530,6 +532,8 @@ proc getRgbaSmooth*(image: Image, x, y: float32): ColorRGBA =
lerp(bottomMix, topMix, diffY)
proc getRgbaSmoothWrapped*(image: Image, x, y: float32): ColorRGBA =
+ ## Gets a interpolated color with float point coordinates.
+ ## Pixes outside the image are repeated.
let
minX = floor(x)
minY = floor(y)