2021-02-27 00:42:40 +00:00
|
|
|
import benchy, chroma, pixie, pixie/internal
|
2020-12-03 20:21:58 +00:00
|
|
|
|
2021-02-08 20:31:20 +00:00
|
|
|
let image = newImage(2560, 1440)
|
|
|
|
|
|
|
|
proc reset() =
|
|
|
|
image.fill(rgba(63, 127, 191, 191))
|
|
|
|
|
|
|
|
reset()
|
2020-12-03 20:21:58 +00:00
|
|
|
|
|
|
|
timeIt "fill":
|
2021-02-08 20:31:20 +00:00
|
|
|
image.fill(rgba(255, 255, 255, 255))
|
|
|
|
doAssert image[0, 0] == rgba(255, 255, 255, 255)
|
|
|
|
|
|
|
|
reset()
|
2020-12-03 20:21:58 +00:00
|
|
|
|
2020-12-09 00:10:20 +00:00
|
|
|
timeIt "fill_rgba":
|
2021-02-08 20:31:20 +00:00
|
|
|
image.fill(rgba(63, 127, 191, 191))
|
|
|
|
doAssert image[0, 0] == rgba(63, 127, 191, 191)
|
|
|
|
|
2021-08-17 21:14:31 +00:00
|
|
|
image.fill(rgba(100, 0, 100, 100))
|
|
|
|
timeIt "isOneColor":
|
|
|
|
doAssert image.isOneColor()
|
|
|
|
|
|
|
|
image.fill(rgba(0, 0, 0, 0))
|
|
|
|
timeIt "isTransparent":
|
|
|
|
doAssert image.isTransparent()
|
|
|
|
|
2021-12-13 03:48:02 +00:00
|
|
|
image.fill(rgba(255, 255, 255, 255))
|
|
|
|
timeIt "isOpaque":
|
|
|
|
doAssert image.isOpaque()
|
|
|
|
|
2021-02-08 20:31:20 +00:00
|
|
|
reset()
|
2020-12-09 00:10:20 +00:00
|
|
|
|
2021-01-23 20:17:28 +00:00
|
|
|
timeIt "subImage":
|
2022-07-30 03:01:47 +00:00
|
|
|
discard image.subImage(0, 0, 256, 256)
|
2021-02-08 20:31:20 +00:00
|
|
|
|
|
|
|
reset()
|
2021-01-23 20:17:28 +00:00
|
|
|
|
2021-03-03 06:23:44 +00:00
|
|
|
timeIt "superImage":
|
2022-07-30 03:01:47 +00:00
|
|
|
discard image.superImage(-10, -10, 2580, 1460)
|
2021-02-08 02:41:12 +00:00
|
|
|
|
2021-02-08 20:31:20 +00:00
|
|
|
reset()
|
|
|
|
|
2021-02-08 02:41:12 +00:00
|
|
|
timeIt "minifyBy2":
|
2021-02-08 20:31:20 +00:00
|
|
|
let minified = image.minifyBy2()
|
2021-06-18 02:25:54 +00:00
|
|
|
doAssert minified[0, 0] == rgba(63, 127, 191, 191)
|
|
|
|
|
2021-06-18 02:40:07 +00:00
|
|
|
reset()
|
|
|
|
|
2021-06-18 02:25:54 +00:00
|
|
|
timeIt "magnifyBy2":
|
|
|
|
let minified = image.magnifyBy2()
|
2021-02-08 02:41:12 +00:00
|
|
|
doAssert minified[0, 0] == rgba(63, 127, 191, 191)
|
|
|
|
|
2021-02-08 20:31:20 +00:00
|
|
|
reset()
|
|
|
|
|
2021-10-25 02:36:41 +00:00
|
|
|
timeIt "flipHorizontal":
|
|
|
|
image.flipHorizontal()
|
|
|
|
|
|
|
|
reset()
|
|
|
|
|
|
|
|
timeIt "flipVertical":
|
|
|
|
image.flipVertical()
|
|
|
|
|
|
|
|
reset()
|
|
|
|
|
2022-05-25 23:54:13 +00:00
|
|
|
timeIt "rotate90":
|
|
|
|
image.rotate90()
|
|
|
|
|
|
|
|
reset()
|
|
|
|
|
2020-12-03 20:21:58 +00:00
|
|
|
timeIt "invert":
|
2021-02-08 20:31:20 +00:00
|
|
|
image.invert()
|
|
|
|
|
|
|
|
reset()
|
2020-12-03 20:32:50 +00:00
|
|
|
|
|
|
|
timeIt "applyOpacity":
|
2022-07-23 03:49:51 +00:00
|
|
|
reset()
|
2021-02-08 20:31:20 +00:00
|
|
|
image.applyOpacity(0.5)
|
|
|
|
|
|
|
|
reset()
|
2020-12-03 20:32:50 +00:00
|
|
|
|
2021-01-25 17:49:29 +00:00
|
|
|
timeIt "toPremultipliedAlpha":
|
2021-02-27 00:42:40 +00:00
|
|
|
image.data.toPremultipliedAlpha()
|
2021-02-08 20:31:20 +00:00
|
|
|
|
|
|
|
reset()
|
2021-01-24 22:03:35 +00:00
|
|
|
|
2021-01-25 17:49:29 +00:00
|
|
|
timeIt "toStraightAlpha":
|
2021-02-27 00:42:40 +00:00
|
|
|
image.data.toStraightAlpha()
|
2021-02-08 20:31:20 +00:00
|
|
|
|
|
|
|
reset()
|
|
|
|
|
2022-07-26 04:40:42 +00:00
|
|
|
timeIt "ceil":
|
|
|
|
reset()
|
|
|
|
image.ceil()
|
|
|
|
|
2022-07-24 16:54:40 +00:00
|
|
|
block:
|
|
|
|
let image = newImage(200, 200)
|
|
|
|
image.fill(rgbx(255, 0, 0, 255))
|
|
|
|
|
|
|
|
timeIt "blur":
|
|
|
|
image.blur(20)
|
2021-02-10 03:13:23 +00:00
|
|
|
|
|
|
|
reset()
|
|
|
|
|
2021-10-12 00:20:43 +00:00
|
|
|
timeIt "mix integers":
|
2021-01-25 00:20:46 +00:00
|
|
|
for i in 0 ..< 100000:
|
2021-02-08 20:31:20 +00:00
|
|
|
let c = image[0, 0]
|
2021-01-25 00:20:46 +00:00
|
|
|
var z: int
|
|
|
|
for t in 0 .. 100:
|
2021-10-12 00:20:43 +00:00
|
|
|
z += mix(c, c, t.float32 / 100).a.int
|
2021-01-25 00:20:46 +00:00
|
|
|
doAssert z > 0
|
|
|
|
|
2021-10-12 00:20:43 +00:00
|
|
|
timeIt "mix floats":
|
2022-07-23 22:29:50 +00:00
|
|
|
for i in 0 ..< 1000:
|
|
|
|
let c = image[0, 0].color
|
2021-01-25 00:20:46 +00:00
|
|
|
var z: int
|
|
|
|
for t in 0 .. 100:
|
2022-07-23 22:29:50 +00:00
|
|
|
z += mix(c, c, t.float32 / 100).rgba().a.int
|
2021-01-25 00:20:46 +00:00
|
|
|
doAssert z > 0
|