Merge pull request #413 from guzba/master

4.2.0
This commit is contained in:
treeform 2022-04-26 20:00:58 -07:00 committed by GitHub
commit bc0a2787f4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 23 additions and 12 deletions

View file

@ -99,7 +99,7 @@ exportSeq seq[float32]:
exportSeq seq[Span]:
procs:
typeset(seq[Span], Vec2, HorizontalAlignment, VerticalAlignment, bool)
computeBounds(seq[Span])
layoutBounds(seq[Span])
exportRefObject Image:
fields:
@ -232,7 +232,7 @@ exportRefObject Font:
scale(Font)
defaultLineHeight
typeset(Font, string, Vec2, HorizontalAlignment, VerticalAlignment, bool)
computeBounds(Font, string)
layoutBounds(Font, string)
exportRefObject Span:
fields:
@ -243,7 +243,8 @@ exportRefObject Span:
exportRefObject Arrangement:
procs:
computeBounds(Arrangement)
layoutBounds(Arrangement)
computeBounds(Arrangement, Mat3)
exportRefObject Context:
fields:

Binary file not shown.

Before

Width:  |  Height:  |  Size: 88 KiB

After

Width:  |  Height:  |  Size: 88 KiB

View file

@ -1,4 +1,4 @@
version = "4.1.0"
version = "4.2.0"
author = "Andre von Houck and Ryan Oldenburg"
description = "Full-featured 2d graphics library for Nim."
license = "MIT"
@ -6,7 +6,7 @@ license = "MIT"
srcDir = "src"
requires "nim >= 1.4.8"
requires "vmath >= 1.1.0"
requires "vmath >= 1.1.4"
requires "chroma >= 0.2.5"
requires "zippy >= 0.9.7"
requires "flatty >= 0.2.4"

View file

@ -598,7 +598,7 @@ proc textUber(
proc computeBounds*(
arrangement: Arrangement,
transform = mat3()
): Rect =
): Rect {.raises: [PixieError].} =
let fullPath = newPath()
for path in arrangement.computePaths():
fullPath.addPath(path)

View file

@ -104,6 +104,7 @@ proc fillGradientLinear(image: Image, paint: Paint) =
if paint.gradientStops.len == 0:
raise newException(PixieError, "Gradient must have at least 1 color stop")
paint.opacity = clamp(paint.opacity, 0, 1)
if paint.opacity == 0:
return
@ -177,6 +178,7 @@ proc fillGradientRadial(image: Image, paint: Paint) =
if paint.gradientStops.len == 0:
raise newException(PixieError, "Gradient must have at least 1 color stop")
paint.opacity = clamp(paint.opacity, 0, 1)
if paint.opacity == 0:
return
@ -208,6 +210,7 @@ proc fillGradientAngular(image: Image, paint: Paint) =
if paint.gradientStops.len == 0:
raise newException(PixieError, "Gradient must have at least 1 color stop")
paint.opacity = clamp(paint.opacity, 0, 1)
if paint.opacity == 0:
return

View file

@ -1,4 +1,5 @@
import blends, bumpy, chroma, common, images, internal, masks, paints, strutils, vmath, fenv
import blends, bumpy, chroma, common, fenv, images, internal, masks, paints,
strutils, vmath
when defined(amd64) and not defined(pixieNoSimd):
import nimsimd/sse2
@ -1922,6 +1923,8 @@ proc fillPath*(
windingRule = NonZero
) {.raises: [PixieError].} =
## Fills a path.
paint.opacity = clamp(paint.opacity, 0, 1)
if paint.opacity == 0:
return
@ -2000,6 +2003,8 @@ proc strokePath*(
dashes: seq[float32] = @[]
) {.raises: [PixieError].} =
## Strokes a path.
paint.opacity = clamp(paint.opacity, 0, 1)
if paint.opacity == 0:
return

View file

@ -1,4 +1,4 @@
import pixie/common, pixie/fileformats/bmp, random, strformat, flatty/binny, os
import flatty/binny, os, pixie/common, pixie/fileformats/bmp, random, strformat
randomize()

View file

@ -1,4 +1,4 @@
import chroma, pixie, pixie/fileformats/bmp, os, strutils
import chroma, os, pixie, pixie/fileformats/bmp, strutils
# block:
# var image = newImage(4, 2)

View file

@ -293,7 +293,6 @@ block:
let a = newImage(100, 100)
a.fill(color(1, 1, 1, 1))
let draws = [
# Overlaps in bounds
(vec2(-50, -50), color(1, 0, 0, 1)),

View file

@ -460,7 +460,10 @@ block:
block:
let mask = newMask(100, 100)
mask.fillPath("M 10.1 10.1 H 60.1 V 60.1 H 10.1 z")
mask.fillPath("M 30.1 30.1 H 80.1 V 80.1 H 30.1 z", blendMode = ExcludeMaskBlend)
mask.fillPath(
"M 30.1 30.1 H 80.1 V 80.1 H 30.1 z",
blendMode = ExcludeMaskBlend
)
writeFile("tests/paths/maskRectExcludeMaskAA.png", mask.encodePng())
block:
@ -704,7 +707,7 @@ block:
let image = newImage(200, 200)
image.fill(rgba(255, 255, 255, 255))
let pathStr ="""
let pathStr = """
L -16370.0 -18156.0
A 4100 4100 0 1 0 -19670 -14134
Z