Another doc pass.

This commit is contained in:
treeform 2021-02-25 07:05:53 -08:00
parent d46fc41b93
commit 50a472ceb9
18 changed files with 55 additions and 48 deletions

File diff suppressed because one or more lines are too long

View file

@ -310,7 +310,7 @@ Unpack the first 32 bits into 4 rgba(0, 0, 0, value)
<div class="twelve-columns footer">
<span class="nim-sprite"></span>
<br/>
<small style="color: var(--hint);">Made with Nim. Generated: 2021-02-25 14:52:03 UTC</small>
<small style="color: var(--hint);">Made with Nim. Generated: 2021-02-25 15:05:38 UTC</small>
</div>
</div>
</div>

View file

@ -172,14 +172,21 @@ Returns unsigned fraction part of the float.<table frame="void"><tr><th align="l
<dt><pre><span class="Keyword">proc</span> <a href="#lerp%2Cuint8%2Cuint8%2Cfloat32"><span class="Identifier">lerp</span></a><span class="Other">(</span><span class="Identifier">a</span><span class="Other">,</span> <span class="Identifier">b</span><span class="Other">:</span> <span class="Identifier">uint8</span><span class="Other">;</span> <span class="Identifier">t</span><span class="Other">:</span> <span class="Identifier">float32</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">uint8</span> <span><span class="Other">{</span><span class="Other pragmadots">...</span><span class="Other">}</span></span><span class="pragmawrap"><span class="Other">{.</span><span class="pragma"><span class="Identifier">inline</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span><span class="Other">.}</span></span></pre></dt>
<dd>
Linearly interpolate between a and b using t.
</dd>
<a id="lerp,ColorRGBA,ColorRGBA,float32"></a>
<dt><pre><span class="Keyword">proc</span> <a href="#lerp%2CColorRGBA%2CColorRGBA%2Cfloat32"><span class="Identifier">lerp</span></a><span class="Other">(</span><span class="Identifier">a</span><span class="Other">,</span> <span class="Identifier">b</span><span class="Other">:</span> <span class="Identifier">ColorRGBA</span><span class="Other">;</span> <span class="Identifier">t</span><span class="Other">:</span> <span class="Identifier">float32</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">ColorRGBA</span> <span><span class="Other">{</span><span class="Other pragmadots">...</span><span class="Other">}</span></span><span class="pragmawrap"><span class="Other">{.</span><span class="pragma"><span class="Identifier">inline</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span><span class="Other">.}</span></span></pre></dt>
<dd>
Linearly interpolate between a and b using t.
</dd>
<a id="lerp,Color,Color,float32"></a>
<dt><pre><span class="Keyword">func</span> <a href="#lerp%2CColor%2CColor%2Cfloat32"><span class="Identifier">lerp</span></a><span class="Other">(</span><span class="Identifier">a</span><span class="Other">,</span> <span class="Identifier">b</span><span class="Other">:</span> <span class="Identifier">Color</span><span class="Other">;</span> <span class="Identifier">v</span><span class="Other">:</span> <span class="Identifier">float32</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">Color</span> <span><span class="Other">{</span><span class="Other pragmadots">...</span><span class="Other">}</span></span><span class="pragmawrap"><span class="Other">{.</span><span class="pragma"><span class="Identifier">inline</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span><span class="Other">.}</span></span></pre></dt>
<dd>
Linearly interpolate between a and b using t.
</dd>
<a id="toPremultipliedAlpha,ColorRGBA"></a>
@ -196,13 +203,6 @@ Converts a color to premultiplied alpha from straight alpha.
Converts a color from premultiplied alpha to straight alpha.
</dd>
<a id="lerp,Color,Color,float32"></a>
<dt><pre><span class="Keyword">func</span> <a href="#lerp%2CColor%2CColor%2Cfloat32"><span class="Identifier">lerp</span></a><span class="Other">(</span><span class="Identifier">a</span><span class="Other">,</span> <span class="Identifier">b</span><span class="Other">:</span> <span class="Identifier">Color</span><span class="Other">;</span> <span class="Identifier">v</span><span class="Other">:</span> <span class="Identifier">float32</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">Color</span> <span><span class="Other">{</span><span class="Other pragmadots">...</span><span class="Other">}</span></span><span class="pragmawrap"><span class="Other">{.</span><span class="pragma"><span class="Identifier">inline</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span><span class="Other">.}</span></span></pre></dt>
<dd>
</dd>
<a id="toPremultipliedAlpha,Color"></a>
<dt><pre><span class="Keyword">proc</span> <a href="#toPremultipliedAlpha%2CColor"><span class="Identifier">toPremultipliedAlpha</span></a><span class="Other">(</span><span class="Identifier">c</span><span class="Other">:</span> <span class="Identifier">Color</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">Color</span> <span><span class="Other">{</span><span class="Other pragmadots">...</span><span class="Other">}</span></span><span class="pragmawrap"><span class="Other">{.</span><span class="pragma"><span class="Identifier">inline</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span><span class="Other">.}</span></span></pre></dt>
@ -228,7 +228,7 @@ Converts a color from premultiplied alpha to straight alpha.
<div class="twelve-columns footer">
<span class="nim-sprite"></span>
<br/>
<small style="color: var(--hint);">Made with Nim. Generated: 2021-02-25 14:52:03 UTC</small>
<small style="color: var(--hint);">Made with Nim. Generated: 2021-02-25 15:05:38 UTC</small>
</div>
</div>
</div>

View file

@ -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

View file

@ -165,7 +165,7 @@ Decodes bitmap data into an Image.
<dt><pre><span class="Keyword">proc</span> <a href="#decodeBmp%2Cseq%5Buint8%5D"><span class="Identifier">decodeBmp</span></a><span class="Other">(</span><span class="Identifier">data</span><span class="Other">:</span> <span class="Identifier">seq</span><span class="Other">[</span><span class="Identifier">uint8</span><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <a href="../images.html#Image"><span class="Identifier">Image</span></a> <span><span class="Other">{</span><span class="Other pragmadots">...</span><span class="Other">}</span></span><span class="pragmawrap"><span class="Other">{.</span><span class="pragma"><span class="Identifier">inline</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">PixieError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span><span class="Other">.}</span></span></pre></dt>
<dd>
Decodes bitmap data into an Image.
</dd>
<a id="encodeBmp,Image"></a>
@ -185,7 +185,7 @@ Encodes an image into the BMP file format.
<div class="twelve-columns footer">
<span class="nim-sprite"></span>
<br/>
<small style="color: var(--hint);">Made with Nim. Generated: 2021-02-25 14:52:04 UTC</small>
<small style="color: var(--hint);">Made with Nim. Generated: 2021-02-25 15:05:39 UTC</small>
</div>
</div>
</div>

View file

@ -165,14 +165,14 @@ Decodes the JPEG into an Image.
<dt><pre><span class="Keyword">proc</span> <a href="#decodeJpg%2Cstring"><span class="Identifier">decodeJpg</span></a><span class="Other">(</span><span class="Identifier">data</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">)</span><span class="Other">:</span> <a href="../images.html#Image"><span class="Identifier">Image</span></a> <span><span class="Other">{</span><span class="Other pragmadots">...</span><span class="Other">}</span></span><span class="pragmawrap"><span class="Other">{.</span><span class="pragma"><span class="Identifier">inline</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">PixieError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span><span class="Other">.}</span></span></pre></dt>
<dd>
Decodes the JPEG data into an Image.
</dd>
<a id="encodeJpg,Image"></a>
<dt><pre><span class="Keyword">proc</span> <a href="#encodeJpg%2CImage"><span class="Identifier">encodeJpg</span></a><span class="Other">(</span><span class="Identifier">image</span><span class="Other">:</span> <a href="../images.html#Image"><span class="Identifier">Image</span></a><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">string</span> <span><span class="Other">{</span><span class="Other pragmadots">...</span><span class="Other">}</span></span><span class="pragmawrap"><span class="Other">{.</span><span class="pragma"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">PixieError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span><span class="Other">.}</span></span></pre></dt>
<dd>
Encodes Image into a JPEG data string.
</dd>
@ -185,7 +185,7 @@ Decodes the JPEG into an Image.
<div class="twelve-columns footer">
<span class="nim-sprite"></span>
<br/>
<small style="color: var(--hint);">Made with Nim. Generated: 2021-02-25 14:52:04 UTC</small>
<small style="color: var(--hint);">Made with Nim. Generated: 2021-02-25 15:05:39 UTC</small>
</div>
</div>
</div>

View file

@ -162,14 +162,14 @@ window.addEventListener('DOMContentLoaded', main);
<dt><pre><span class="Keyword">proc</span> <a href="#decodePng%2Cseq%5Buint8%5D"><span class="Identifier">decodePng</span></a><span class="Other">(</span><span class="Identifier">data</span><span class="Other">:</span> <span class="Identifier">seq</span><span class="Other">[</span><span class="Identifier">uint8</span><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <a href="../images.html#Image"><span class="Identifier">Image</span></a> <span><span class="Other">{</span><span class="Other pragmadots">...</span><span class="Other">}</span></span><span class="pragmawrap"><span class="Other">{.</span><span class="pragma"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">PixieError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span><span class="Other">.}</span></span></pre></dt>
<dd>
Decodes the PNG into an Image.
Decodes the PNG data into an Image.
</dd>
<a id="decodePng,string"></a>
<dt><pre><span class="Keyword">proc</span> <a href="#decodePng%2Cstring"><span class="Identifier">decodePng</span></a><span class="Other">(</span><span class="Identifier">data</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">)</span><span class="Other">:</span> <a href="../images.html#Image"><span class="Identifier">Image</span></a> <span><span class="Other">{</span><span class="Other pragmadots">...</span><span class="Other">}</span></span><span class="pragmawrap"><span class="Other">{.</span><span class="pragma"><span class="Identifier">inline</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">PixieError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span><span class="Other">.}</span></span></pre></dt>
<dd>
Decodes the PNG data into an Image.
</dd>
<a id="encodePng,int,int,int,pointer,int"></a>
@ -204,7 +204,7 @@ Encodes the mask data into the PNG file format.
<div class="twelve-columns footer">
<span class="nim-sprite"></span>
<br/>
<small style="color: var(--hint);">Made with Nim. Generated: 2021-02-25 14:52:04 UTC</small>
<small style="color: var(--hint);">Made with Nim. Generated: 2021-02-25 15:05:39 UTC</small>
</div>
</div>
</div>

View file

@ -174,7 +174,7 @@ Render SVG file and return the image.
<div class="twelve-columns footer">
<span class="nim-sprite"></span>
<br/>
<small style="color: var(--hint);">Made with Nim. Generated: 2021-02-25 14:52:05 UTC</small>
<small style="color: var(--hint);">Made with Nim. Generated: 2021-02-25 15:05:40 UTC</small>
</div>
</div>
</div>

View file

@ -503,7 +503,7 @@ Draws one image onto another using matrix with color blending.
<span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">PixieError</span><span class="Other">,</span> <span class="Identifier">Exception</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">RootEffect</span><span class="Other">]</span></span><span class="Other">.}</span></span></pre></dt>
<dd>
Draws one image onto another using a position offset with color blending.
</dd>
<a id="draw,Image,Mask,Mat3"></a>
@ -511,7 +511,7 @@ Draws one image onto another using matrix with color blending.
<span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">PixieError</span><span class="Other">,</span> <span class="Identifier">Exception</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">RootEffect</span><span class="Other">]</span></span><span class="Other">.}</span></span></pre></dt>
<dd>
Draws a mask onto an image using a matrix with color blending.
</dd>
<a id="draw,Image,Mask"></a>
@ -519,7 +519,7 @@ Draws one image onto another using matrix with color blending.
<span class="Identifier">inline</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">PixieError</span><span class="Other">,</span> <span class="Identifier">Exception</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">RootEffect</span><span class="Other">]</span></span><span class="Other">.}</span></span></pre></dt>
<dd>
Draws a mask onto an image using a position offset with color blending.
</dd>
<a id="draw,Mask,Mask,Mat3"></a>
@ -527,7 +527,7 @@ Draws one image onto another using matrix with color blending.
<span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">PixieError</span><span class="Other">,</span> <span class="Identifier">Exception</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">RootEffect</span><span class="Other">]</span></span><span class="Other">.}</span></span></pre></dt>
<dd>
Draws a mask onto a mask using a matrix with color blending.
</dd>
<a id="draw,Mask,Mask"></a>
@ -535,7 +535,7 @@ Draws one image onto another using matrix with color blending.
<span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">PixieError</span><span class="Other">,</span> <span class="Identifier">Exception</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">RootEffect</span><span class="Other">]</span></span><span class="Other">.}</span></span></pre></dt>
<dd>
Draws a mask onto a mask using a position offset with color blending.
</dd>
<a id="draw,Mask,Image,Mat3"></a>
@ -543,7 +543,7 @@ Draws one image onto another using matrix with color blending.
<span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">PixieError</span><span class="Other">,</span> <span class="Identifier">Exception</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">RootEffect</span><span class="Other">]</span></span><span class="Other">.}</span></span></pre></dt>
<dd>
Draws a image onto a mask using a matrix with color blending.
</dd>
<a id="draw,Mask,Image"></a>
@ -551,7 +551,7 @@ Draws one image onto another using matrix with color blending.
<span class="Identifier">inline</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">PixieError</span><span class="Other">,</span> <span class="Identifier">Exception</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">RootEffect</span><span class="Other">]</span></span><span class="Other">.}</span></span></pre></dt>
<dd>
Draws a image onto a mask using a position offset with color blending.
</dd>
<a id="resize,Image,int,int"></a>
@ -579,7 +579,7 @@ Shifts the target by offset.
<div class="twelve-columns footer">
<span class="nim-sprite"></span>
<br/>
<small style="color: var(--hint);">Made with Nim. Generated: 2021-02-25 14:52:04 UTC</small>
<small style="color: var(--hint);">Made with Nim. Generated: 2021-02-25 15:05:38 UTC</small>
</div>
</div>
</div>

View file

@ -357,7 +357,7 @@ A value of 0 stays 0. Anything else turns into 255.
<div class="twelve-columns footer">
<span class="nim-sprite"></span>
<br/>
<small style="color: var(--hint);">Made with Nim. Generated: 2021-02-25 14:52:04 UTC</small>
<small style="color: var(--hint);">Made with Nim. Generated: 2021-02-25 15:05:38 UTC</small>
</div>
</div>
</div>

View file

@ -272,7 +272,7 @@ Angular gradient.
<div class="twelve-columns footer">
<span class="nim-sprite"></span>
<br/>
<small style="color: var(--hint);">Made with Nim. Generated: 2021-02-25 14:52:05 UTC</small>
<small style="color: var(--hint);">Made with Nim. Generated: 2021-02-25 15:05:39 UTC</small>
</div>
</div>
</div>

View file

@ -628,7 +628,7 @@ Return elements in pairs: (1st, 2nd), (2nd, 3rd) ... (n - 1, last).
<div class="twelve-columns footer">
<span class="nim-sprite"></span>
<br/>
<small style="color: var(--hint);">Made with Nim. Generated: 2021-02-25 14:52:05 UTC</small>
<small style="color: var(--hint);">Made with Nim. Generated: 2021-02-25 15:05:39 UTC</small>
</div>
</div>
</div>

View file

@ -917,7 +917,7 @@ window.addEventListener('DOMContentLoaded', main);
<div class="twelve-columns footer">
<span class="nim-sprite"></span>
<br/>
<small style="color: var(--hint);">Made with Nim. Generated: 2021-02-25 14:52:05 UTC</small>
<small style="color: var(--hint);">Made with Nim. Generated: 2021-02-25 15:05:40 UTC</small>
</div>
</div>
</div>

View file

@ -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

View file

@ -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 =

View file

@ -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")

View file

@ -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*(

View file

@ -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 =