add function in imperative shell to save export string, and fix errors in generating export string from functional core
This commit is contained in:
@@ -525,7 +525,7 @@ struct
|
|||||||
val b = colToRealString b
|
val b = colToRealString b
|
||||||
|
|
||||||
val x = String.concat ["(((x + ", x, ") - halfWidth) / halfWidth)"]
|
val x = String.concat ["(((x + ", x, ") - halfWidth) / halfWidth)"]
|
||||||
val y = String.concat ["(~(y + ", y, ") - halfHeight) / halfHeight)"]
|
val y = String.concat ["((~(y + ", y, ") - halfHeight) / halfHeight)"]
|
||||||
|
|
||||||
val ex = String.concat
|
val ex = String.concat
|
||||||
[ "((((("
|
[ "((((("
|
||||||
@@ -570,7 +570,7 @@ struct
|
|||||||
val bintree = merge (qtree, squares)
|
val bintree = merge (qtree, squares)
|
||||||
|
|
||||||
val coords = BinTree.foldr (toExportStringFolder, bintree, [])
|
val coords = BinTree.foldr (toExportStringFolder, bintree, [])
|
||||||
val coords = String.concatWith "," coords
|
val coords = String.concatWith ",\n" coords
|
||||||
|
|
||||||
val header = String.concat
|
val header = String.concat
|
||||||
[ "structure AAA = \nstruct\n"
|
[ "structure AAA = \nstruct\n"
|
||||||
@@ -582,7 +582,7 @@ struct
|
|||||||
, " #[\n"
|
, " #[\n"
|
||||||
]
|
]
|
||||||
|
|
||||||
val footer = String.concat [" ]\n", " end\n", "end\n"]
|
val footer = String.concat ["\n ]\n", " end\n", "end\n"]
|
||||||
in
|
in
|
||||||
String.concat [header, coords, footer]
|
String.concat [header, coords, footer]
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -12,41 +12,6 @@ struct
|
|||||||
val filename = "green.dsc"
|
val filename = "green.dsc"
|
||||||
val exportFilename = "green.sml"
|
val exportFilename = "green.sml"
|
||||||
|
|
||||||
fun ndcToLerpX num =
|
|
||||||
let
|
|
||||||
val num = (num + 1.0) / 2.0
|
|
||||||
val num = Real32.toString num
|
|
||||||
val num =
|
|
||||||
(* Problem: It seems that Real32.toString may sometimes return a string
|
|
||||||
* that is recognised as an integer, like "1" instead of "1.0".
|
|
||||||
* If that happens, we just add a ".0" to the end
|
|
||||||
* so it's recognised as a real. *)
|
|
||||||
if String.isSubstring "." num then num
|
|
||||||
else num ^ ".0"
|
|
||||||
in
|
|
||||||
" (((startX * (1.0 - " ^ num ^ ")) + (endX * " ^ num
|
|
||||||
^ ")) / windowWidth) - 1.0"
|
|
||||||
end
|
|
||||||
|
|
||||||
fun ndcToLerpY num =
|
|
||||||
let
|
|
||||||
val num = (num + 1.0) / 2.0
|
|
||||||
val num = Real32.toString num
|
|
||||||
val num = if String.isSubstring "." num then num else num ^ ".0"
|
|
||||||
in
|
|
||||||
" (((startY * (1.0 - " ^ num ^ ")) + (endY * " ^ num
|
|
||||||
^ ")) / windowHeight) - 1.0"
|
|
||||||
end
|
|
||||||
|
|
||||||
fun colToString col =
|
|
||||||
let val col = Real32.toString col
|
|
||||||
in if String.isSubstring "." col then col else col ^ ".0"
|
|
||||||
end
|
|
||||||
|
|
||||||
fun exportSquares squares = ()
|
|
||||||
|
|
||||||
fun parse (io, acc) = ()
|
|
||||||
|
|
||||||
fun loadIO (io, str) =
|
fun loadIO (io, str) =
|
||||||
case TextIO.inputLine io of
|
case TextIO.inputLine io of
|
||||||
SOME line => loadIO (io, str ^ line)
|
SOME line => loadIO (io, str ^ line)
|
||||||
@@ -76,6 +41,14 @@ struct
|
|||||||
TextIO.closeOut io
|
TextIO.closeOut io
|
||||||
end
|
end
|
||||||
|
|
||||||
|
fun exportSquares squaresString =
|
||||||
|
let
|
||||||
|
val io = TextIO.openOut exportFilename
|
||||||
|
val () = TextIO.output (io, squaresString)
|
||||||
|
in
|
||||||
|
TextIO.closeOut io
|
||||||
|
end
|
||||||
|
|
||||||
fun getDirList (dir, acc, rootPath) =
|
fun getDirList (dir, acc, rootPath) =
|
||||||
case OS.FileSys.readDir dir of
|
case OS.FileSys.readDir dir of
|
||||||
SOME path =>
|
SOME path =>
|
||||||
@@ -112,7 +85,7 @@ struct
|
|||||||
case Mailbox.recv fileMailbox of
|
case Mailbox.recv fileMailbox of
|
||||||
SAVE_SQUARES str => saveSquares str
|
SAVE_SQUARES str => saveSquares str
|
||||||
| LOAD_SQUARES => loadSquares (filename, inputMailbox)
|
| LOAD_SQUARES => loadSquares (filename, inputMailbox)
|
||||||
| EXPORT_SQUARES triangles => exportSquares triangles
|
| EXPORT_SQUARES str => exportSquares str
|
||||||
| LOAD_FILES path => loadFiles (path, inputMailbox)
|
| LOAD_FILES path => loadFiles (path, inputMailbox)
|
||||||
| SELECT_PATH path => selectPath (path, inputMailbox)
|
| SELECT_PATH path => selectPath (path, inputMailbox)
|
||||||
in
|
in
|
||||||
|
|||||||
Reference in New Issue
Block a user