Files
sml-projects/game-sml/fcore/block.sml
Humza Shahid da8790f0b6 Add 'game-sml/' from commit '113c3e67abe635f714f972a1e2ab0e4b24ff10f4'
git-subtree-dir: game-sml
git-subtree-mainline: aa5357714d
git-subtree-split: 113c3e67ab
2026-04-24 00:38:14 +01:00

26 lines
1.3 KiB
Standard ML

structure Block =
struct
fun lerp (startX, startY, drawWidth, drawHeight, windowWidth, windowHeight, r, g, b) : Real32.real vector =
let
val endY = windowHeight - startY
val startY = windowHeight - (startY + drawHeight)
val endX = startX + drawWidth
val windowHeight = windowHeight / 2.0
val windowWidth = windowWidth / 2.0
in
#[ (((startX * (1.0 - 1.0)) + (endX * 1.0)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.0)) + (endY * 0.0)) / windowHeight) - 1.0, r, g, b,
(((startX * (1.0 - 0.0)) + (endX * 0.0)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.0)) + (endY * 0.0)) / windowHeight) - 1.0, r, g, b,
(((startX * (1.0 - 0.0)) + (endX * 0.0)) / windowWidth) - 1.0,
(((startY * (1.0 - 1.0)) + (endY * 1.0)) / windowHeight) - 1.0, r, g, b,
(((startX * (1.0 - 0.0)) + (endX * 0.0)) / windowWidth) - 1.0,
(((startY * (1.0 - 1.0)) + (endY * 1.0)) / windowHeight) - 1.0, r, g, b,
(((startX * (1.0 - 1.0)) + (endX * 1.0)) / windowWidth) - 1.0,
(((startY * (1.0 - 1.0)) + (endY * 1.0)) / windowHeight) - 1.0, r, g, b,
(((startX * (1.0 - 1.0)) + (endX * 1.0)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.0)) + (endY * 0.0)) / windowHeight) - 1.0, r, g, b
]
end
end