Add 'dotscape/' from commit 'f306501a68a51b634e895c5fdac70788ae899d75'
git-subtree-dir: dotscape git-subtree-mainline:6b91d64fc3git-subtree-split:f306501a68
This commit is contained in:
38
dotscape/fcore/ndc.sml
Normal file
38
dotscape/fcore/ndc.sml
Normal file
@@ -0,0 +1,38 @@
|
||||
structure Ndc =
|
||||
struct
|
||||
(* ndc = normalised device coordinates *)
|
||||
|
||||
fun ltrbToVertex (left, top, right, bottom) =
|
||||
#[ left, bottom
|
||||
, right, bottom
|
||||
, left, top
|
||||
|
||||
, left, top
|
||||
, right, bottom
|
||||
, right, top
|
||||
]
|
||||
|
||||
fun ltrbToVertexRgb (startX, startY, endX, endY, r, g, b) =
|
||||
#[ startX, endY, r, g, b
|
||||
, endX, endY, r, g, b
|
||||
, startX, startY, r, g, b
|
||||
|
||||
, startX, startY, r, g, b
|
||||
, endX, endY, r, g, b
|
||||
, endX, startY, r, g, b
|
||||
]
|
||||
|
||||
fun fromPixelX (xpos, windowWidth, windowHeight) =
|
||||
let
|
||||
val halfWidth = Real32.fromInt windowWidth / 2.0
|
||||
in
|
||||
(xpos - halfWidth) / halfWidth
|
||||
end
|
||||
|
||||
fun fromPixelY (ypos, windowWidth, windowHeight) =
|
||||
let
|
||||
val halfHeight = Real32.fromInt windowHeight / 2.0
|
||||
in
|
||||
~((ypos - halfHeight) / halfHeight)
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user