rm
This commit is contained in:
parent
1a0f2c0c3d
commit
1c48875d42
|
@ -1,47 +0,0 @@
|
|||
import benchy, chroma, vmath
|
||||
|
||||
include pixie/images
|
||||
|
||||
block:
|
||||
let
|
||||
a = newImage(1000, 1000)
|
||||
b = newImage(50, 50)
|
||||
a.fill(rgba(255, 0, 0, 255))
|
||||
b.fill(rgba(0, 255, 0, 255))
|
||||
|
||||
timeIt "drawCorrect small-on-big":
|
||||
a.drawCorrect(b, translate(vec2(25, 25)), blendMode = NormalBlend)
|
||||
keep(b)
|
||||
|
||||
block:
|
||||
let
|
||||
a = newImage(1000, 1000)
|
||||
b = newImage(50, 50)
|
||||
a.fill(rgba(255, 0, 0, 255))
|
||||
b.fill(rgba(0, 255, 0, 255))
|
||||
|
||||
timeIt "drawUber small-on-big":
|
||||
a.drawUber(b, translate(vec2(25, 25)), blendMode = NormalBlend)
|
||||
keep(b)
|
||||
|
||||
block:
|
||||
let
|
||||
a = newImage(1000, 1000)
|
||||
b = newImage(50, 50)
|
||||
a.fill(rgba(255, 0, 0, 255))
|
||||
b.fill(rgba(0, 255, 0, 255))
|
||||
|
||||
timeIt "drawCorrect small-on-big smooth":
|
||||
a.drawCorrect(b, translate(vec2(25.1, 25.1)), blendMode = NormalBlend)
|
||||
keep(b)
|
||||
|
||||
block:
|
||||
let
|
||||
a = newImage(1000, 1000)
|
||||
b = newImage(50, 50)
|
||||
a.fill(rgba(255, 0, 0, 255))
|
||||
b.fill(rgba(0, 255, 0, 255))
|
||||
|
||||
timeIt "drawUber small-on-big smooth":
|
||||
a.drawUber(b, translate(vec2(25.1, 25.1)), blendMode = NormalBlend)
|
||||
keep(b)
|
|
@ -1,77 +0,0 @@
|
|||
import benchy, pixie, pixie/internal
|
||||
|
||||
proc blurSlower*(
|
||||
image: Image, radius: float32, outOfBounds: SomeColor = ColorRGBX()
|
||||
) =
|
||||
## Applies Gaussian blur to the image given a radius.
|
||||
let radius = round(radius).int
|
||||
if radius == 0:
|
||||
return
|
||||
|
||||
let
|
||||
kernel = gaussianKernel(radius)
|
||||
outOfBounds = outOfBounds.asRgbx()
|
||||
|
||||
proc `*`(sample: ColorRGBX, a: uint32): array[4, uint32] {.inline.} =
|
||||
[
|
||||
sample.r * a,
|
||||
sample.g * a,
|
||||
sample.b * a,
|
||||
sample.a * a
|
||||
]
|
||||
|
||||
template `+=`(values: var array[4, uint32], sample: array[4, uint32]) =
|
||||
values[0] += sample[0]
|
||||
values[1] += sample[1]
|
||||
values[2] += sample[2]
|
||||
values[3] += sample[3]
|
||||
|
||||
template rgbx(values: array[4, uint32]): ColorRGBX =
|
||||
rgbx(
|
||||
(values[0] div 1024 div 255).uint8,
|
||||
(values[1] div 1024 div 255).uint8,
|
||||
(values[2] div 1024 div 255).uint8,
|
||||
(values[3] div 1024 div 255).uint8
|
||||
)
|
||||
|
||||
# Blur in the X direction.
|
||||
let blurX = newImage(image.width, image.height)
|
||||
for y in 0 ..< image.height:
|
||||
for x in 0 ..< image.width:
|
||||
var values: array[4, uint32]
|
||||
for xx in x - radius ..< min(x + radius, 0):
|
||||
values += outOfBounds * kernel[xx - x + radius]
|
||||
for xx in max(x - radius, 0) .. min(x + radius, image.width - 1):
|
||||
values += image.unsafe[xx, y] * kernel[xx - x + radius]
|
||||
for xx in max(x - radius, image.width) .. x + radius:
|
||||
values += outOfBounds * kernel[xx - x + radius]
|
||||
blurX.unsafe[x, y] = rgbx(values)
|
||||
|
||||
# Blur in the Y direction.
|
||||
for y in 0 ..< image.height:
|
||||
for x in 0 ..< image.width:
|
||||
var values: array[4, uint32]
|
||||
for yy in y - radius ..< min(y + radius, 0):
|
||||
values += outOfBounds * kernel[yy - y + radius]
|
||||
for yy in max(y - radius, 0) .. min(y + radius, image.height - 1):
|
||||
values += blurX.unsafe[x, yy] * kernel[yy - y + radius]
|
||||
for yy in max(y - radius, image.height) .. y + radius:
|
||||
values += outOfBounds * kernel[yy - y + radius]
|
||||
image.unsafe[x, y] = rgbx(values)
|
||||
|
||||
let image = newImage(1920, 1080)
|
||||
|
||||
proc reset() =
|
||||
let path = newPath()
|
||||
path.rect(100, 100, 1720, 880)
|
||||
image.fillPath(path, rgba(255, 255, 255, 255))
|
||||
|
||||
reset()
|
||||
|
||||
timeIt "blurSlower":
|
||||
image.blurSlower(40)
|
||||
|
||||
reset()
|
||||
|
||||
timeIt "blur":
|
||||
image.blur(40)
|
|
@ -1,24 +0,0 @@
|
|||
import benchy, pixie
|
||||
|
||||
let image = newImage(2560, 1440)
|
||||
image.fill(rgba(50, 100, 150, 200))
|
||||
|
||||
timeIt "x then y":
|
||||
var sum: uint64
|
||||
for x in 0 ..< image.width:
|
||||
for y in 0 ..< image.height:
|
||||
let pixel = image.unsafe[x, y]
|
||||
sum += pixel.r + pixel.g + pixel.b + pixel.a
|
||||
if sum == 0:
|
||||
echo "0"
|
||||
keep sum
|
||||
|
||||
timeIt "y then x":
|
||||
var sum: uint64
|
||||
for y in 0 ..< image.height:
|
||||
for x in 0 ..< image.width:
|
||||
let pixel = image.unsafe[x, y]
|
||||
sum += pixel.r + pixel.g + pixel.b + pixel.a
|
||||
if sum == 0:
|
||||
echo "0"
|
||||
keep sum
|
Loading…
Reference in a new issue