Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/pixie/images.nim
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,16 @@ proc invert*(image: Image) {.hasSimd, raises: [].} =
# We need to convert back to premultiplied alpha after inverting.
image.data.toPremultipliedAlpha()

proc ceil*(image: Image) {.hasSimd, raises: [].} =
## A value of 0 stays 0. Anything else turns into 255.
for i in 0 ..< image.data.len:
var rgbx = image.data[i]
rgbx.r = if rgbx.r == 0: 0 else: 255
rgbx.g = if rgbx.g == 0: 0 else: 255
rgbx.b = if rgbx.b == 0: 0 else: 255
rgbx.a = if rgbx.a == 0: 0 else: 255
image.data[i] = rgbx

proc blur*(
image: Image, radius: float32, outOfBounds: SomeColor = color(0, 0, 0, 0)
) {.raises: [PixieError].} =
Expand Down
13 changes: 8 additions & 5 deletions src/pixie/paths.nim
Original file line number Diff line number Diff line change
Expand Up @@ -2021,6 +2021,8 @@ proc fillShapes(
i += 2

if onlySimpleFillPairs:
numHits = 0

var i: int
while i < numEntryIndices:
let
Expand Down Expand Up @@ -2126,13 +2128,14 @@ proc fillShapes(
let
fillBegin = leftCoverEnd.clamp(0, image.width)
fillEnd = rightCoverBegin.clamp(0, image.width)
if fillEnd - fillBegin > 0:
hits[0] = (fixed32(fillBegin.float32), 1.int16)
hits[1] = (fixed32(fillEnd.float32), -1.int16)
image.fillHits(rgbx, 0, y, hits, 2, NonZero, blendMode)

hits[numHits] = (fixed32(fillBegin.float32), 1.int16)
hits[numHits + 1] = (fixed32(fillEnd.float32), -1.int16)
numHits += 2
i += 2

if numHits > 0:
image.fillHits(rgbx, 0, y, hits, numHits, NonZero, blendMode)

inc y
continue

Expand Down