Remove .wh on Images and Masks (it was odd one).
This commit is contained in:
parent
301c6bd31c
commit
935a0eb5c2
4 changed files with 14 additions and 18 deletions
|
@ -39,10 +39,6 @@ proc newImage*(mask: Mask): Image {.raises: [PixieError].} =
|
||||||
let v = mask.data[i]
|
let v = mask.data[i]
|
||||||
result.data[i] = rgbx(v, v, v, v)
|
result.data[i] = rgbx(v, v, v, v)
|
||||||
|
|
||||||
proc wh*(image: Image): Vec2 {.inline, raises: [].} =
|
|
||||||
## Return with and height as a size vector.
|
|
||||||
vec2(image.width.float32, image.height.float32)
|
|
||||||
|
|
||||||
proc copy*(image: Image): Image {.raises: [PixieError].} =
|
proc copy*(image: Image): Image {.raises: [PixieError].} =
|
||||||
## Copies the image data into a new image.
|
## Copies the image data into a new image.
|
||||||
result = newImage(image.width, image.height)
|
result = newImage(image.width, image.height)
|
||||||
|
|
|
@ -22,10 +22,6 @@ proc newMask*(width, height: int): Mask {.raises: [PixieError].} =
|
||||||
result.height = height
|
result.height = height
|
||||||
result.data = newSeq[uint8](width * height)
|
result.data = newSeq[uint8](width * height)
|
||||||
|
|
||||||
proc wh*(mask: Mask): Vec2 {.inline, raises: [].} =
|
|
||||||
## Return with and height as a size vector.
|
|
||||||
vec2(mask.width.float32, mask.height.float32)
|
|
||||||
|
|
||||||
proc copy*(mask: Mask): Mask {.raises: [PixieError].} =
|
proc copy*(mask: Mask): Mask {.raises: [PixieError].} =
|
||||||
## Copies the image data into a new image.
|
## Copies the image data into a new image.
|
||||||
result = newMask(mask.width, mask.height)
|
result = newMask(mask.width, mask.height)
|
||||||
|
|
|
@ -1149,7 +1149,7 @@ iterator walk(
|
||||||
numHits: int,
|
numHits: int,
|
||||||
windingRule: WindingRule,
|
windingRule: WindingRule,
|
||||||
y: int,
|
y: int,
|
||||||
size: Vec2
|
width: float32
|
||||||
): (float32, float32, int32) =
|
): (float32, float32, int32) =
|
||||||
var
|
var
|
||||||
prevAt: float32
|
prevAt: float32
|
||||||
|
@ -1170,14 +1170,14 @@ iterator walk(
|
||||||
count += winding
|
count += winding
|
||||||
|
|
||||||
when defined(pixieLeakCheck):
|
when defined(pixieLeakCheck):
|
||||||
if prevAt != size.x and count != 0:
|
if prevAt != width and count != 0:
|
||||||
echo "Leak detected: ", count, " @ (", prevAt, ", ", y, ")"
|
echo "Leak detected: ", count, " @ (", prevAt, ", ", y, ")"
|
||||||
|
|
||||||
proc computeCoverages(
|
proc computeCoverages(
|
||||||
coverages: var seq[uint8],
|
coverages: var seq[uint8],
|
||||||
hits: var seq[(float32, int16)],
|
hits: var seq[(float32, int16)],
|
||||||
numHits: var int,
|
numHits: var int,
|
||||||
size: Vec2,
|
width: float32,
|
||||||
y, startX: int,
|
y, startX: int,
|
||||||
aa: bool,
|
aa: bool,
|
||||||
partitioning: Partitioning,
|
partitioning: Partitioning,
|
||||||
|
@ -1196,7 +1196,7 @@ proc computeCoverages(
|
||||||
let partitionIndex = partitioning.getIndexForY(y)
|
let partitionIndex = partitioning.getIndexForY(y)
|
||||||
var
|
var
|
||||||
yLine = y.float32 + initialOffset - offset
|
yLine = y.float32 + initialOffset - offset
|
||||||
scanline = line(vec2(0, yLine), vec2(size.x, yLine))
|
scanline = line(vec2(0, yLine), vec2(width, yLine))
|
||||||
for m in 0 ..< quality:
|
for m in 0 ..< quality:
|
||||||
yLine += offset
|
yLine += offset
|
||||||
scanline.a.y = yLine
|
scanline.a.y = yLine
|
||||||
|
@ -1212,13 +1212,13 @@ proc computeCoverages(
|
||||||
if segment.to != at:
|
if segment.to != at:
|
||||||
if numHits == hits.len:
|
if numHits == hits.len:
|
||||||
hits.setLen(hits.len * 2)
|
hits.setLen(hits.len * 2)
|
||||||
hits[numHits] = (min(at.x, size.x), winding)
|
hits[numHits] = (min(at.x, width), winding)
|
||||||
inc numHits
|
inc numHits
|
||||||
|
|
||||||
sort(hits, 0, numHits - 1)
|
sort(hits, 0, numHits - 1)
|
||||||
|
|
||||||
if aa:
|
if aa:
|
||||||
for (prevAt, at, count) in hits.walk(numHits, windingRule, y, size):
|
for (prevAt, at, count) in hits.walk(numHits, windingRule, y, width):
|
||||||
var fillStart = prevAt.int
|
var fillStart = prevAt.int
|
||||||
|
|
||||||
let
|
let
|
||||||
|
@ -1403,7 +1403,7 @@ proc fillHits(
|
||||||
) =
|
) =
|
||||||
let blender = blendMode.blender()
|
let blender = blendMode.blender()
|
||||||
var filledTo: int
|
var filledTo: int
|
||||||
for (prevAt, at, count) in hits.walk(numHits, windingRule, y, image.wh):
|
for (prevAt, at, count) in hits.walk(numHits, windingRule, y, image.width.float32):
|
||||||
let
|
let
|
||||||
fillStart = prevAt.int
|
fillStart = prevAt.int
|
||||||
fillLen = at.int - fillStart
|
fillLen = at.int - fillStart
|
||||||
|
@ -1451,7 +1451,7 @@ proc fillHits(
|
||||||
) =
|
) =
|
||||||
let masker = blendMode.masker()
|
let masker = blendMode.masker()
|
||||||
var filledTo: int
|
var filledTo: int
|
||||||
for (prevAt, at, count) in hits.walk(numHits, windingRule, y, mask.wh):
|
for (prevAt, at, count) in hits.walk(numHits, windingRule, y, mask.width.float32):
|
||||||
let
|
let
|
||||||
fillStart = prevAt.int
|
fillStart = prevAt.int
|
||||||
fillLen = at.int - fillStart
|
fillLen = at.int - fillStart
|
||||||
|
@ -1515,7 +1515,7 @@ proc fillShapes(
|
||||||
coverages,
|
coverages,
|
||||||
hits,
|
hits,
|
||||||
numHits,
|
numHits,
|
||||||
image.wh,
|
image.width.float32,
|
||||||
y,
|
y,
|
||||||
startX,
|
startX,
|
||||||
aa,
|
aa,
|
||||||
|
@ -1572,7 +1572,7 @@ proc fillShapes(
|
||||||
coverages,
|
coverages,
|
||||||
hits,
|
hits,
|
||||||
numHits,
|
numHits,
|
||||||
mask.wh,
|
mask.width.float32,
|
||||||
y,
|
y,
|
||||||
startX,
|
startX,
|
||||||
aa,
|
aa,
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
import pixie, pixie/fileformats/png, strformat, unicode
|
import pixie, pixie/fileformats/png, strformat, unicode
|
||||||
|
|
||||||
|
proc wh(image: Image): Vec2 =
|
||||||
|
## Return with and height as a size vector.
|
||||||
|
vec2(image.width.float32, image.height.float32)
|
||||||
|
|
||||||
proc doDiff(rendered: Image, name: string) =
|
proc doDiff(rendered: Image, name: string) =
|
||||||
rendered.writeFile(&"tests/fonts/rendered/{name}.png")
|
rendered.writeFile(&"tests/fonts/rendered/{name}.png")
|
||||||
let
|
let
|
||||||
|
|
Loading…
Reference in a new issue