From f72fff86512f7fbb38f180d16a8ccf08ca5e06e5 Mon Sep 17 00:00:00 2001 From: Ryan Oldenburg Date: Fri, 18 Jun 2021 15:30:02 -0500 Subject: [PATCH] draw proc cleanup --- src/pixie/images.nim | 54 ++++++++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/src/pixie/images.nim b/src/pixie/images.nim index b4185b0..2ecbc0f 100644 --- a/src/pixie/images.nim +++ b/src/pixie/images.nim @@ -784,41 +784,41 @@ proc drawUber(a, b: Image | Mask, mat = mat3(), blendMode = bmNormal) = if a.width - xMax > 0: zeroMem(a.data[a.dataIndex(xMax, y)].addr, 4 * (a.width - xMax)) -proc draw*(a, b: Image, mat: Mat3, blendMode = bmNormal) {.inline.} = +proc draw*( + a, b: Image, transform: Vec2 | Mat3 = vec2(), blendMode = bmNormal +) {.inline.} = ## Draws one image onto another using matrix with color blending. - a.drawUber(b, mat, blendMode) - -proc draw*(a, b: Image, pos = vec2(0, 0), blendMode = bmNormal) {.inline.} = - ## Draws one image onto another using a position offset with color blending. - a.draw(b, translate(pos), blendMode) - -proc draw*(image: Image, mask: Mask, mat: Mat3, blendMode = bmMask) {.inline.} = - ## Draws a mask onto an image using a matrix with color blending. - image.drawUber(mask, mat, blendMode) + when type(transform) is Vec2: + a.drawUber(b, translate(transform), blendMode) + else: + a.drawUber(b, transform, blendMode) proc draw*( - image: Image, mask: Mask, pos = vec2(0, 0), blendMode = bmMask + a, b: Mask, transform: Vec2 | Mat3 = vec2(), blendMode = bmMask ) {.inline.} = - ## Draws a mask onto an image using a position offset with color blending. - image.drawUber(mask, translate(pos), blendMode) - -proc draw*(a, b: Mask, mat: Mat3, blendMode = bmMask) {.inline.} = ## Draws a mask onto a mask using a matrix with color blending. - a.drawUber(b, mat, blendMode) - -proc draw*(a, b: Mask, pos = vec2(0, 0), blendMode = bmMask) {.inline.} = - ## Draws a mask onto a mask using a position offset with color blending. - a.draw(b, translate(pos), blendMode) - -proc draw*(mask: Mask, image: Image, mat: Mat3, blendMode = bmMask) {.inline.} = - ## Draws a image onto a mask using a matrix with color blending. - mask.drawUber(image, mat, blendMode) + when type(transform) is Vec2: + a.drawUber(b, translate(transform), blendMode) + else: + a.drawUber(b, transform, blendMode) proc draw*( - mask: Mask, image: Image, pos = vec2(0, 0), blendMode = bmMask + image: Image, mask: Mask, transform: Vec2 | Mat3 = vec2(), blendMode = bmMask ) {.inline.} = - ## Draws a image onto a mask using a position offset with color blending. - mask.draw(image, translate(pos), blendMode) + ## Draws a mask onto an image using a matrix with color blending. + when type(transform) is Vec2: + image.drawUber(mask, translate(transform), blendMode) + else: + image.drawUber(mask, transform, blendMode) + +proc draw*( + mask: Mask, image: Image, transform: Vec2 | Mat3 = vec2(), blendMode = bmMask +) {.inline.} = + ## Draws a image onto a mask using a matrix with color blending. + when type(transform) is Vec2: + mask.drawUber(image, translate(transform), blendMode) + else: + mask.drawUber(image, transform, blendMode) proc drawTiled*(dest, src: Image, mat: Mat3, blendMode = bmNormal) = dest.drawCorrect(src, mat, true, blendMode)