morepretty

This commit is contained in:
Ryan Oldenburg 2022-05-29 21:22:19 -05:00
parent a2b7316176
commit f16c8226ef
5 changed files with 25 additions and 15 deletions

View file

@ -1,5 +1,5 @@
import pixie/common, pixie/images, pixie/masks, sequtils, strutils, chroma,
std/decls, flatty/binny
import chroma, flatty/binny, pixie/common, pixie/images, pixie/masks, sequtils,
std/decls, strutils
when defined(amd64) and not defined(pixieNoSimd):
import nimsimd/sse2
@ -906,13 +906,17 @@ proc magnifyXBy2(mask: Mask): Mask =
let n = 3 * mask.unsafe[x, y].uint16
if x == 0:
result.unsafe[x * 2 + 0, y] = mask.unsafe[x, y]
result.unsafe[x * 2 + 1, y] = ((n + mask.unsafe[x + 1, y].uint16 + 2) div 4).uint8
result.unsafe[x * 2 + 1, y] =
((n + mask.unsafe[x + 1, y].uint16 + 2) div 4).uint8
elif x == mask.width - 1:
result.unsafe[x * 2 + 0, y] = ((n + mask.unsafe[x - 1, y].uint16 + 2) div 4).uint8
result.unsafe[x * 2 + 0, y] =
((n + mask.unsafe[x - 1, y].uint16 + 2) div 4).uint8
result.unsafe[x * 2 + 1, y] = mask.unsafe[x, y]
else:
result.unsafe[x * 2 + 0, y] = ((n + mask.unsafe[x - 1, y].uint16) div 4).uint8
result.unsafe[x * 2 + 1, y] = ((n + mask.unsafe[x + 1, y].uint16) div 4).uint8
result.unsafe[x * 2 + 0, y] =
((n + mask.unsafe[x - 1, y].uint16) div 4).uint8
result.unsafe[x * 2 + 1, y] =
((n + mask.unsafe[x + 1, y].uint16) div 4).uint8
proc magnifyYBy2(mask: Mask): Mask =
## Smooth magnify by power of 2 only in the Y direction.
@ -922,13 +926,17 @@ proc magnifyYBy2(mask: Mask): Mask =
let n = 3 * mask.unsafe[x, y].uint16
if y == 0:
result.unsafe[x, y * 2 + 0] = mask.unsafe[x, y]
result.unsafe[x, y * 2 + 1] = ((n + mask.unsafe[x, y + 1].uint16 + 2) div 4).uint8
result.unsafe[x, y * 2 + 1] =
((n + mask.unsafe[x, y + 1].uint16 + 2) div 4).uint8
elif y == mask.height - 1:
result.unsafe[x, y * 2 + 0] = ((n + mask.unsafe[x, y - 1].uint16 + 2) div 4).uint8
result.unsafe[x, y * 2 + 0] =
((n + mask.unsafe[x, y - 1].uint16 + 2) div 4).uint8
result.unsafe[x, y * 2 + 1] = mask.unsafe[x, y]
else:
result.unsafe[x, y * 2 + 0] = ((n + mask.unsafe[x, y - 1].uint16) div 4).uint8
result.unsafe[x, y * 2 + 1] = ((n + mask.unsafe[x, y + 1].uint16) div 4).uint8
result.unsafe[x, y * 2 + 0] =
((n + mask.unsafe[x, y - 1].uint16) div 4).uint8
result.unsafe[x, y * 2 + 1] =
((n + mask.unsafe[x, y + 1].uint16) div 4).uint8
proc yCbCrToRgbx(py, pcb, pcr: uint8): ColorRGBX =
## Takes a 3 component yCbCr outputs and populates image.

View file

@ -519,7 +519,6 @@ proc parseSvg*(
var rootProps = initSvgProperties()
rootProps = root.parseSvgProperties(rootProps)
if viewBoxMinX != 0 or viewBoxMinY != 0:
let viewBoxMin = vec2(-viewBoxMinX.float32, -viewBoxMinY.float32)
rootprops.transform = rootprops.transform * translate(viewBoxMin)

View file

@ -1,5 +1,5 @@
import flatty/binny, flatty/encode, math, pixie/common, pixie/paths, sets,
strutils, tables, unicode, vmath
strutils, tables, unicode, vmath
## See https://docs.microsoft.com/en-us/typography/opentype/spec/
@ -663,7 +663,7 @@ proc parseNameTable(buf: string, offset: int): NameTable =
if record.platformID == 3 and
record.encodingID == 1 and
record.languageID == 1033:
record.text = fromUTF16BE(record.text)
record.text = fromUTF16BE(record.text)
record.text = record.text
result.nameRecords.add(record)

View file

@ -1,4 +1,4 @@
import pixie, pixie/fileformats/png, strformat, unicode, os
import os, pixie, pixie/fileformats/png, strformat, unicode
proc wh(image: Image): Vec2 =
## Return with and height as a size vector.

View file

@ -29,5 +29,8 @@ for file in files:
doDiff(readImage(&"tests/fileformats/svg/{file}.svg"), file)
block:
let svg = parseSvg(readFile("tests/fileformats/svg/accessibility-outline.svg"), 512, 512)
let svg = parseSvg(
readFile("tests/fileformats/svg/accessibility-outline.svg"),
512, 512
)
doDiff(newImage(svg), "accessibility-outline")