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:
@@ -246,7 +246,7 @@ struct
|
||||
end
|
||||
| NO_TRIANGLE =>
|
||||
(case #triangles model of
|
||||
{x1, y1, x2, y2, x3, y3} :: trianglesTl =>
|
||||
{x1, y1, x2, y2, x3, y3, r, g, b} :: trianglesTl =>
|
||||
(* Have to slice off (x3, y3) from triangle head,
|
||||
* turn (x1, y1, x2, y2) into a triangleStage,
|
||||
* and redraw both triangle and triangleStage. *)
|
||||
@@ -309,9 +309,19 @@ struct
|
||||
| SECOND {x1, y1, x2, y2} =>
|
||||
(* clear triangle stage, add to trinagle list and redraw triangles *)
|
||||
let
|
||||
val {r, g, b, ...} = model
|
||||
val newTriangleStage = NO_TRIANGLE
|
||||
val newTriangle =
|
||||
{x1 = x1, y1 = y1, x2 = x2, y2 = y2, x3 = x, y3 = y}
|
||||
{ x1 = x1
|
||||
, y1 = y1
|
||||
, x2 = x2
|
||||
, y2 = y2
|
||||
, x3 = x
|
||||
, y3 = y
|
||||
, r = r
|
||||
, g = g
|
||||
, b = b
|
||||
}
|
||||
val newTriangles = newTriangle :: (#triangles model)
|
||||
val model =
|
||||
AppWith.redo (model, newTriangleStage, newTriangles, redoHd)
|
||||
|
||||
Reference in New Issue
Block a user