Move fractional to common.
This commit is contained in:
parent
2f0da5773c
commit
2b67d52861
2 changed files with 8 additions and 7 deletions
|
@ -32,3 +32,9 @@ proc intersects*(a, b: Segment, at: var Vec2): bool =
|
||||||
at.y = a.at.y + (t * s1y)
|
at.y = a.at.y + (t * s1y)
|
||||||
return true
|
return true
|
||||||
return false
|
return false
|
||||||
|
|
||||||
|
proc fractional*(v: float32): float32 =
|
||||||
|
## Returns unsigned fraction part of the float.
|
||||||
|
## -13.7868723 -> 0.7868723
|
||||||
|
result = abs(v)
|
||||||
|
result = result - floor(result)
|
||||||
|
|
|
@ -41,12 +41,6 @@ proc `$`*(image: Image): string =
|
||||||
## Display the image size and channels.
|
## Display the image size and channels.
|
||||||
"<Image " & $image.width & "x" & $image.height & ">"
|
"<Image " & $image.width & "x" & $image.height & ">"
|
||||||
|
|
||||||
proc fractional(v: float32): float32 =
|
|
||||||
## Returns unsigned fraction part of the float.
|
|
||||||
## -13.7868723 -> 0.7868723
|
|
||||||
result = abs(v)
|
|
||||||
result = result - floor(result)
|
|
||||||
|
|
||||||
proc inside*(image: Image, x, y: int): bool {.inline.} =
|
proc inside*(image: Image, x, y: int): bool {.inline.} =
|
||||||
## Returns true if (x, y) is inside the image.
|
## Returns true if (x, y) is inside the image.
|
||||||
x >= 0 and x < image.width and
|
x >= 0 and x < image.width and
|
||||||
|
@ -517,7 +511,7 @@ proc draw*(a: Image, b: Image, mat: Mat3, blendMode: BlendMode) =
|
||||||
mat[2, 0].fractional == 0.0 and mat[2, 1].fractional == 0.0)
|
mat[2, 0].fractional == 0.0 and mat[2, 1].fractional == 0.0)
|
||||||
|
|
||||||
if not smooth:
|
if not smooth:
|
||||||
#echo "copy non-smooth"
|
#echo "draw ", b.width, "x", b.height, " fast"
|
||||||
case blendMode
|
case blendMode
|
||||||
of bmNormal: drawUberStatic(a, b, c, start, stepX, stepY, lines, bmNormal, true, false)
|
of bmNormal: drawUberStatic(a, b, c, start, stepX, stepY, lines, bmNormal, true, false)
|
||||||
of bmDarken: drawUberStatic(a, b, c, start, stepX, stepY, lines, bmDarken, true, false)
|
of bmDarken: drawUberStatic(a, b, c, start, stepX, stepY, lines, bmDarken, true, false)
|
||||||
|
@ -543,6 +537,7 @@ proc draw*(a: Image, b: Image, mat: Mat3, blendMode: BlendMode) =
|
||||||
of bmIntersectMask: drawUberStatic(a, b, c, start, stepX, stepY, lines, bmIntersectMask, true, false)
|
of bmIntersectMask: drawUberStatic(a, b, c, start, stepX, stepY, lines, bmIntersectMask, true, false)
|
||||||
of bmExcludeMask: drawUberStatic(a, b, c, start, stepX, stepY, lines, bmExcludeMask, true, false)
|
of bmExcludeMask: drawUberStatic(a, b, c, start, stepX, stepY, lines, bmExcludeMask, true, false)
|
||||||
else:
|
else:
|
||||||
|
#echo "draw ", b.width, "x", b.height, " smooth"
|
||||||
case blendMode
|
case blendMode
|
||||||
of bmNormal: drawUberStatic(a, b, c, start, stepX, stepY, lines, bmNormal, true, true)
|
of bmNormal: drawUberStatic(a, b, c, start, stepX, stepY, lines, bmNormal, true, true)
|
||||||
of bmDarken: drawUberStatic(a, b, c, start, stepX, stepY, lines, bmDarken, true, true)
|
of bmDarken: drawUberStatic(a, b, c, start, stepX, stepY, lines, bmDarken, true, true)
|
||||||
|
|
Loading…
Reference in a new issue