change Ndc.fromPixelX and Ndc.fromPixelY functions to not try and centre pixels (centering is handled in the click points instead)
This commit is contained in:
@@ -24,33 +24,17 @@ struct
|
|||||||
|
|
||||||
fun fromPixelX (xpos, windowWidth, windowHeight) =
|
fun fromPixelX (xpos, windowWidth, windowHeight) =
|
||||||
let
|
let
|
||||||
val halfWidth = Real32.fromInt (windowWidth div 2)
|
val halfWidth = Real32.fromInt windowWidth / 2.0
|
||||||
val xpos = xpos - halfWidth
|
val xpos = xpos - halfWidth
|
||||||
in
|
in
|
||||||
if windowWidth > windowHeight then
|
xpos / halfWidth
|
||||||
let
|
|
||||||
val difference = windowWidth - windowHeight
|
|
||||||
val offset = Real32.fromInt (difference div 2)
|
|
||||||
in
|
|
||||||
xpos / (halfWidth - offset)
|
|
||||||
end
|
|
||||||
else
|
|
||||||
xpos / halfWidth
|
|
||||||
end
|
end
|
||||||
|
|
||||||
fun fromPixelY (ypos, windowWidth, windowHeight) =
|
fun fromPixelY (ypos, windowWidth, windowHeight) =
|
||||||
let
|
let
|
||||||
val halfHeight = Real32.fromInt (windowHeight div 2)
|
val halfHeight = Real32.fromInt windowHeight / 2.0
|
||||||
val ypos = ~(ypos - halfHeight)
|
val ypos = ~(ypos - halfHeight)
|
||||||
in
|
in
|
||||||
if windowHeight > windowWidth then
|
ypos / halfHeight
|
||||||
let
|
|
||||||
val difference = windowHeight - windowWidth
|
|
||||||
val offset = Real32.fromInt (difference div 2)
|
|
||||||
in
|
|
||||||
ypos / (halfHeight - offset)
|
|
||||||
end
|
|
||||||
else
|
|
||||||
ypos / halfHeight
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user