add [r, g, b] field to triangle, so we can draw coloured objects (next: add ability to change current colour)
This commit is contained in:
@@ -10,9 +10,9 @@ struct
|
||||
|
||||
datatype parse_result = OK of AppType.triangle list | PARSE_ERROR
|
||||
|
||||
val structureName = "UnknownChar"
|
||||
val filename = "fonts/unknown-char.dsc"
|
||||
val exportFilename = "fonts/unknown-char.sml"
|
||||
val structureName = "Green"
|
||||
val filename = "green.dsc"
|
||||
val exportFilename = "green.sml"
|
||||
|
||||
fun ndcToLerpX num =
|
||||
let
|
||||
@@ -40,9 +40,14 @@ struct
|
||||
^ ")) / 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 helpExportTriangles (io, triangles) =
|
||||
case triangles of
|
||||
{x1, y1, x2, y2, x3, y3} :: tl =>
|
||||
{x1, y1, x2, y2, x3, y3, r, g, b} :: tl =>
|
||||
let
|
||||
val x1 = ndcToLerpX x1
|
||||
val x2 = ndcToLerpX x2
|
||||
@@ -52,6 +57,10 @@ struct
|
||||
val y2 = ndcToLerpY y2
|
||||
val y3 = ndcToLerpY y3
|
||||
|
||||
val r = colToString r
|
||||
val g = colToString g
|
||||
val b = colToString b
|
||||
|
||||
val line = String.concat
|
||||
[ x1
|
||||
, ",\n"
|
||||
@@ -64,9 +73,15 @@ struct
|
||||
, x3
|
||||
, ",\n"
|
||||
, y3
|
||||
, ", \n"
|
||||
, r
|
||||
, ", "
|
||||
, g
|
||||
, ", "
|
||||
, b
|
||||
, case tl of
|
||||
[] => ", r, g, b\n"
|
||||
| _ => ", r, g, b,\n"
|
||||
[] => "\n"
|
||||
| _ => ",\n"
|
||||
]
|
||||
|
||||
val _ = TextIO.output (io, line)
|
||||
@@ -126,14 +141,17 @@ struct
|
||||
val inputMsg =
|
||||
case triangles of
|
||||
OK triangles => USE_TRIANGLES triangles
|
||||
| PARSE_ERROR => TRIANGLES_LOAD_ERROR
|
||||
| PARSE_ERROR =>
|
||||
let val _ = print "parse error\n"
|
||||
in TRIANGLES_LOAD_ERROR
|
||||
end
|
||||
in
|
||||
Mailbox.send (inputMailbox, inputMsg)
|
||||
end
|
||||
|
||||
fun helpSaveTriangles (triangles, io) =
|
||||
case triangles of
|
||||
{x1, y1, x2, y2, x3, y3} :: tl =>
|
||||
{x1, y1, x2, y2, x3, y3, r, g, b} :: tl =>
|
||||
let
|
||||
val triString = String.concat
|
||||
[ "x "
|
||||
@@ -150,6 +168,14 @@ struct
|
||||
, Real32.toString x3
|
||||
, " y "
|
||||
, Real32.toString y3
|
||||
|
||||
, " r "
|
||||
, Real32.toString r
|
||||
, " g "
|
||||
, Real32.toString g
|
||||
, " b "
|
||||
, Real32.toString b
|
||||
|
||||
, "\n"
|
||||
]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user