tested export functionality, and fixed it so that it works as intended (previous error was that the drawn object was located on the wrong part of the Y-axis)
This commit is contained in:
27
a.sml
Normal file
27
a.sml
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
structure LowerCaseA =
|
||||||
|
struct
|
||||||
|
fun lerp (startX, startY, drawWidth, drawHeight, windowWidth, windowHeight) : Real32.real vector =
|
||||||
|
let
|
||||||
|
val startX = Real32.fromInt startX
|
||||||
|
val startY = Real32.fromInt startY
|
||||||
|
val startY = windowHeight - (startY + drawHeight)
|
||||||
|
val endX = startX + drawWidth
|
||||||
|
val endY = startY + drawHeight
|
||||||
|
val windowHeight = windowHeight / 2.0
|
||||||
|
val windowWidth = windowWidth / 2.0
|
||||||
|
in
|
||||||
|
#[ (((startX * (1.0 - 0.47499999404)) + (endX * 0.47499999404)) / windowWidth) - 1.0,
|
||||||
|
(((startY * (1.0 - 0.700000047684)) + (endY * 0.700000047684)) / windowHeight) - 1.0,
|
||||||
|
(((startX * (1.0 - 0.299999982119)) + (endX * 0.299999982119)) / windowWidth) - 1.0,
|
||||||
|
(((startY * (1.0 - 0.675000011921)) + (endY * 0.675000011921)) / windowHeight) - 1.0,
|
||||||
|
(((startX * (1.0 - 0.449999988079)) + (endX * 0.449999988079)) / windowWidth) - 1.0,
|
||||||
|
(((startY * (1.0 - 0.550000011921)) + (endY * 0.550000011921)) / windowHeight) - 1.0,
|
||||||
|
(((startX * (1.0 - 0.625)) + (endX * 0.625)) / windowWidth) - 1.0,
|
||||||
|
(((startY * (1.0 - 0.275000035763)) + (endY * 0.275000035763)) / windowHeight) - 1.0,
|
||||||
|
(((startX * (1.0 - 0.799999952316)) + (endX * 0.799999952316)) / windowWidth) - 1.0,
|
||||||
|
(((startY * (1.0 - 0.400000035763)) + (endY * 0.400000035763)) / windowHeight) - 1.0,
|
||||||
|
(((startX * (1.0 - 0.524999976158)) + (endX * 0.524999976158)) / windowWidth) - 1.0,
|
||||||
|
(((startY * (1.0 - 0.524999976158)) + (endY * 0.524999976158)) / windowHeight) - 1.0
|
||||||
|
]
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -14,31 +14,33 @@ struct
|
|||||||
val filename = "a.dsc"
|
val filename = "a.dsc"
|
||||||
val exportFilename = "a.sml"
|
val exportFilename = "a.sml"
|
||||||
|
|
||||||
datatype dir = X | Y
|
fun ndcToLerpX num =
|
||||||
|
|
||||||
fun ndcToLerp (num, dir) =
|
|
||||||
let
|
let
|
||||||
val num = (num + 1.0) / 2.0
|
val num = (num + 1.0) / 2.0
|
||||||
val num = Real32.toString num
|
val num = Real32.toString num
|
||||||
in
|
in
|
||||||
case dir of
|
" (((startX * (1.0 - " ^ num ^ ")) + (endX * " ^ num ^ ")) / windowWidth) - 1.0"
|
||||||
X =>
|
end
|
||||||
" ((startX * (1.0 - " ^ num ^ ")) + (endX * " ^ num ^ ")) / windowWidth"
|
|
||||||
| Y =>
|
fun ndcToLerpY num =
|
||||||
" ((startY * (1.0 - " ^ num ^ ")) + (endY * " ^ num ^ ")) / windowHeight"
|
let
|
||||||
|
val num = (num + 1.0) / 2.0
|
||||||
|
val num = Real32.toString num
|
||||||
|
in
|
||||||
|
" (((startY * (1.0 - " ^ num ^ ")) + (endY * " ^ num ^ ")) / windowHeight) - 1.0"
|
||||||
end
|
end
|
||||||
|
|
||||||
fun helpExportTriangles (io, triangles) =
|
fun helpExportTriangles (io, triangles) =
|
||||||
case triangles of
|
case triangles of
|
||||||
{x1, y1, x2, y2, x3, y3} :: tl =>
|
{x1, y1, x2, y2, x3, y3} :: tl =>
|
||||||
let
|
let
|
||||||
val x1 = ndcToLerp (x1, X)
|
val x1 = ndcToLerpX x1
|
||||||
val x2 = ndcToLerp (x2, X)
|
val x2 = ndcToLerpX x2
|
||||||
val x3 = ndcToLerp (x3, X)
|
val x3 = ndcToLerpX x3
|
||||||
|
|
||||||
val y1 = ndcToLerp (y1, Y)
|
val y1 = ndcToLerpY y1
|
||||||
val y2 = ndcToLerp (y2, Y)
|
val y2 = ndcToLerpY y2
|
||||||
val y3 = ndcToLerp (y3, Y)
|
val y3 = ndcToLerpY y3
|
||||||
|
|
||||||
val line = String.concat
|
val line = String.concat
|
||||||
[ x1, ",\n", y1, ",\n"
|
[ x1, ",\n", y1, ",\n"
|
||||||
@@ -66,8 +68,11 @@ struct
|
|||||||
\ let\n\
|
\ let\n\
|
||||||
\ val startX = Real32.fromInt startX\n\
|
\ val startX = Real32.fromInt startX\n\
|
||||||
\ val startY = Real32.fromInt startY\n\
|
\ val startY = Real32.fromInt startY\n\
|
||||||
|
\ val startY = windowHeight - (startY + drawHeight)\n\
|
||||||
\ val endX = startX + drawWidth\n\
|
\ val endX = startX + drawWidth\n\
|
||||||
\ val endY = startY + drawHeight\n\
|
\ val endY = startY + drawHeight\n\
|
||||||
|
\ val windowHeight = windowHeight / 2.0\n\
|
||||||
|
\ val windowWidth = windowWidth / 2.0\n\
|
||||||
\ in\n\
|
\ in\n\
|
||||||
\ #["
|
\ #["
|
||||||
val _ = TextIO.output (io, functionStartString)
|
val _ = TextIO.output (io, functionStartString)
|
||||||
|
|||||||
Reference in New Issue
Block a user