the test suite is mostly green again

This commit is contained in:
Zahary Karadjov 2012-03-16 05:33:21 +02:00
commit 72f2a6e275
19 changed files with 46 additions and 67 deletions

View file

@ -17,15 +17,15 @@ type
proc `==` *(a, b: TColor): bool {.borrow.}
## compares two colors.
template extract(a: TColor, r, g, b: expr) =
template extract(a: TColor, r, g, b: expr) {.immediate.}=
var r = a.int shr 16 and 0xff
var g = a.int shr 8 and 0xff
var b = a.int and 0xff
template rawRGB(r, g, b: expr): expr =
template rawRGB(r, g, b: int): expr =
TColor(r shl 16 or g shl 8 or b)
template colorOp(op: expr) =
template colorOp(op: expr) {.immediate.} =
extract(a, ar, ag, ab)
extract(b, br, bg, bb)
result = rawRGB(op(ar, br), op(ag, bg), op(ab, bb))