add function in imperative shell to save export string, and fix errors in generating export string from functional core
This commit is contained in:
@@ -12,41 +12,6 @@ struct
|
||||
val filename = "green.dsc"
|
||||
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) =
|
||||
case TextIO.inputLine io of
|
||||
SOME line => loadIO (io, str ^ line)
|
||||
@@ -76,6 +41,14 @@ struct
|
||||
TextIO.closeOut io
|
||||
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) =
|
||||
case OS.FileSys.readDir dir of
|
||||
SOME path =>
|
||||
@@ -112,7 +85,7 @@ struct
|
||||
case Mailbox.recv fileMailbox of
|
||||
SAVE_SQUARES str => saveSquares str
|
||||
| LOAD_SQUARES => loadSquares (filename, inputMailbox)
|
||||
| EXPORT_SQUARES triangles => exportSquares triangles
|
||||
| EXPORT_SQUARES str => exportSquares str
|
||||
| LOAD_FILES path => loadFiles (path, inputMailbox)
|
||||
| SELECT_PATH path => selectPath (path, inputMailbox)
|
||||
in
|
||||
|
||||
Reference in New Issue
Block a user