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:
2024-12-29 20:18:29 +00:00
parent cd1cef793e
commit 43eb5f4448
10 changed files with 197 additions and 65 deletions

View File

@@ -7,16 +7,36 @@ structure ParseFile :> PARSE_FILE =
struct
datatype triangle_token = X | Y | COORD of Real32.real | UNKNOWN of string
val zero: Real32.real = 0.0
fun extractTriangle lst =
case lst of
[ X, COORD x1
, Y, COORD y1
, X, COORD x2
[ X
, COORD x1
, Y
, COORD y1
, Y, COORD y2
, X, COORD x3
, Y, COORD y3
] => SOME {x1 = x1, y1 = y1, x2 = x2, y2 = y2, x3 = x3, y3 = y3}
, X
, COORD x2
, Y
, COORD y2
, X
, COORD x3
, Y
, COORD y3
] =>
SOME
{ x1 = x1
, y1 = y1
, x2 = x2
, y2 = y2
, x3 = x3
, y3 = y3
, r = zero
, g = zero
, b = zero
}
| _ => NONE
fun tokeniseString str =
@@ -61,9 +81,7 @@ struct
end
fun parseLine line =
let
val lst = helpParseLine (line, 0, [], 0)
in
extractTriangle lst
let val lst = helpParseLine (line, 0, [], 0)
in extractTriangle lst
end
end