use memset
This commit is contained in:
parent
fce9f12147
commit
9fbd37bb53
2 changed files with 5 additions and 15 deletions
|
@ -70,9 +70,11 @@ proc `[]=`*(image: Image, x, y: int, rgba: ColorRGBA) {.inline.} =
|
|||
|
||||
proc fill*(image: Image, rgba: ColorRgba) =
|
||||
## Fills the image with a solid color.
|
||||
nimSetMem(image.data[0].addr, cast[int32](rgba), image.data.len)
|
||||
# for c in image.data.mitems:
|
||||
# c = rgba
|
||||
if rgba.r == rgba.g and rgba.r == rgba.b and rgba.r == rgba.a:
|
||||
nimSetMem(image.data[0].addr, rgba.r.cint, image.data.len * 4)
|
||||
else:
|
||||
for c in image.data.mitems:
|
||||
c = rgba
|
||||
|
||||
proc invert*(image: Image) =
|
||||
## Inverts all of the colors and alpha.
|
||||
|
|
|
@ -48,18 +48,6 @@ timeIt "fill":
|
|||
a.fill(rgba(255, 255, 255, 255))
|
||||
doAssert a[0, 0] == rgba(255, 255, 255, 255)
|
||||
|
||||
timeIt "fillOriginal rgba(0, 0, 0, 0)":
|
||||
var a = newImage(2560, 1440)
|
||||
for i in 0 ..< iterations:
|
||||
a.fillOriginal(rgba(0, 0, 0, 0))
|
||||
doAssert a[0, 0] == rgba(0, 0, 0, 0)
|
||||
|
||||
timeIt "fill rgba(0, 0, 0, 0)":
|
||||
var a = newImage(2560, 1440)
|
||||
for i in 0 ..< iterations:
|
||||
a.fill(rgba(0, 0, 0, 0))
|
||||
doAssert a[0, 0] == rgba(0, 0, 0, 0)
|
||||
|
||||
timeIt "invertOriginal":
|
||||
var a = newImage(2560, 1440)
|
||||
for i in 0 ..< iterations:
|
||||
|
|
Loading…
Reference in a new issue