86 lines
4.9 KiB
Standard ML
86 lines
4.9 KiB
Standard ML
structure AAA =
|
|
struct
|
|
fun xToNdc (xOffset, xpos, scale, halfWidth) =
|
|
((xpos * scale + xOffset) - halfWidth) / halfWidth
|
|
|
|
fun endXToNdc (xOffset, startX, endX, scale, halfWidth) =
|
|
(((endX - startX) * scale + xOffset) - halfWidth) / halfWidth
|
|
|
|
fun yToNdc (yOffset, ypos, scale, halfHeight) =
|
|
~(((ypos * scale + yOffset) - halfHeight) / halfHeight)
|
|
|
|
fun endYToNdc (yOffset, startY, endY, scale, halfHeight) =
|
|
~((((endY - startY) * scale + yOffset) - halfHeight) / halfHeight)
|
|
|
|
fun lerp (xOffset, yOffset, scale, windowWidth, windowHeight) =
|
|
let
|
|
val windowWidth = Real32.fromInt windowWidth
|
|
val halfWidth = windowWidth / 2.0
|
|
val windowHeight = Real32.fromInt windowHeight
|
|
val halfHeight = windowHeight / 2.0
|
|
in
|
|
#[
|
|
xToNdc (xOffset, 0.000000000000000, scale, halfWidth),
|
|
yToNdc (yOffset, 10.000000000000000, scale, halfHeight),
|
|
endXToNdc (xOffset, xToNdc (xOffset, 0.000000000000000, scale, halfWidth), 0.000000000000000, scale, halfWidth),
|
|
yToNdc (yOffset, 10.000000000000000, scale, halfHeight),
|
|
xToNdc (xOffset, 0.000000000000000, scale, halfWidth),
|
|
yToNdc (yOffset, 0.000000000000000, scale, halfHeight),
|
|
xToNdc (xOffset, 0.000000000000000, scale, halfWidth),
|
|
yToNdc (yOffset, 0.000000000000000, scale, halfHeight),
|
|
endXToNdc (xOffset, xToNdc (xOffset, 0.000000000000000, scale, halfWidth), 0.000000000000000, scale, halfWidth),
|
|
yToNdc (yOffset, 10.000000000000000, scale, halfHeight),
|
|
endXToNdc (xOffset, xToNdc (xOffset, 0.000000000000000, scale, halfWidth), 0.000000000000000, scale, halfWidth),
|
|
yToNdc (yOffset, 0.000000000000000, scale, halfHeight),
|
|
xToNdc (xOffset, 0.000000000000000, scale, halfWidth),
|
|
yToNdc (yOffset, 1.000000000000000, scale, halfHeight),
|
|
endXToNdc (xOffset, xToNdc (xOffset, 0.000000000000000, scale, halfWidth), 9.000000000000000, scale, halfWidth),
|
|
yToNdc (yOffset, 1.000000000000000, scale, halfHeight),
|
|
xToNdc (xOffset, 0.000000000000000, scale, halfWidth),
|
|
yToNdc (yOffset, 0.000000000000000, scale, halfHeight),
|
|
xToNdc (xOffset, 0.000000000000000, scale, halfWidth),
|
|
yToNdc (yOffset, 0.000000000000000, scale, halfHeight),
|
|
endXToNdc (xOffset, xToNdc (xOffset, 0.000000000000000, scale, halfWidth), 9.000000000000000, scale, halfWidth),
|
|
yToNdc (yOffset, 1.000000000000000, scale, halfHeight),
|
|
endXToNdc (xOffset, xToNdc (xOffset, 0.000000000000000, scale, halfWidth), 9.000000000000000, scale, halfWidth),
|
|
yToNdc (yOffset, 0.000000000000000, scale, halfHeight),
|
|
xToNdc (xOffset, 0.000000000000000, scale, halfWidth),
|
|
yToNdc (yOffset, 10.000000000000000, scale, halfHeight),
|
|
endXToNdc (xOffset, xToNdc (xOffset, 0.000000000000000, scale, halfWidth), 9.000000000000000, scale, halfWidth),
|
|
yToNdc (yOffset, 10.000000000000000, scale, halfHeight),
|
|
xToNdc (xOffset, 0.000000000000000, scale, halfWidth),
|
|
yToNdc (yOffset, 9.000000000000000, scale, halfHeight),
|
|
xToNdc (xOffset, 0.000000000000000, scale, halfWidth),
|
|
yToNdc (yOffset, 9.000000000000000, scale, halfHeight),
|
|
endXToNdc (xOffset, xToNdc (xOffset, 0.000000000000000, scale, halfWidth), 9.000000000000000, scale, halfWidth),
|
|
yToNdc (yOffset, 10.000000000000000, scale, halfHeight),
|
|
endXToNdc (xOffset, xToNdc (xOffset, 0.000000000000000, scale, halfWidth), 9.000000000000000, scale, halfWidth),
|
|
yToNdc (yOffset, 9.000000000000000, scale, halfHeight),
|
|
xToNdc (xOffset, 2.000000000000000, scale, halfWidth),
|
|
yToNdc (yOffset, 3.000000000000000, scale, halfHeight),
|
|
endXToNdc (xOffset, xToNdc (xOffset, 2.000000000000000, scale, halfWidth), 7.000000000000000, scale, halfWidth),
|
|
yToNdc (yOffset, 3.000000000000000, scale, halfHeight),
|
|
xToNdc (xOffset, 2.000000000000000, scale, halfWidth),
|
|
yToNdc (yOffset, 2.000000000000000, scale, halfHeight),
|
|
xToNdc (xOffset, 2.000000000000000, scale, halfWidth),
|
|
yToNdc (yOffset, 2.000000000000000, scale, halfHeight),
|
|
endXToNdc (xOffset, xToNdc (xOffset, 2.000000000000000, scale, halfWidth), 7.000000000000000, scale, halfWidth),
|
|
yToNdc (yOffset, 3.000000000000000, scale, halfHeight),
|
|
endXToNdc (xOffset, xToNdc (xOffset, 2.000000000000000, scale, halfWidth), 7.000000000000000, scale, halfWidth),
|
|
yToNdc (yOffset, 2.000000000000000, scale, halfHeight),
|
|
xToNdc (xOffset, 9.000000000000000, scale, halfWidth),
|
|
yToNdc (yOffset, 10.000000000000000, scale, halfHeight),
|
|
endXToNdc (xOffset, xToNdc (xOffset, 9.000000000000000, scale, halfWidth), 9.000000000000000, scale, halfWidth),
|
|
yToNdc (yOffset, 10.000000000000000, scale, halfHeight),
|
|
xToNdc (xOffset, 9.000000000000000, scale, halfWidth),
|
|
yToNdc (yOffset, 0.000000000000000, scale, halfHeight),
|
|
xToNdc (xOffset, 9.000000000000000, scale, halfWidth),
|
|
yToNdc (yOffset, 0.000000000000000, scale, halfHeight),
|
|
endXToNdc (xOffset, xToNdc (xOffset, 9.000000000000000, scale, halfWidth), 9.000000000000000, scale, halfWidth),
|
|
yToNdc (yOffset, 10.000000000000000, scale, halfHeight),
|
|
endXToNdc (xOffset, xToNdc (xOffset, 9.000000000000000, scale, halfWidth), 9.000000000000000, scale, halfWidth),
|
|
yToNdc (yOffset, 0.000000000000000, scale, halfHeight)
|
|
]
|
|
end
|
|
end
|