finished coding export string, I think/hope

This commit is contained in:
2025-07-12 19:08:36 +01:00
parent 9a748c8e0d
commit a97f838a64
2 changed files with 20 additions and 12 deletions

BIN
dotscape

Binary file not shown.

View File

@@ -524,12 +524,14 @@ struct
val g = colToRealString g val g = colToRealString g
val b = colToRealString b val b = colToRealString b
val x = String.concat ["((", x, " - halfWidth) / halfWidth)"] val x = String.concat ["(((x + ", x, ") - halfWidth) / halfWidth)"]
val y = String.concat ["(~(", y, " - halfHeight) / halfHeight)"] val y = String.concat ["(~(y + ", y, ") - halfHeight) / halfHeight)"]
val ex = String.concat val ex = String.concat
[ "(((((" [ "((((("
, "("
, ex , ex
, "+ x)"
, " - " , " - "
, x , x
, ") " , ") "
@@ -544,7 +546,9 @@ struct
, "(" , "("
, "(" , "("
, "(" , "("
, "("
, ey , ey
, "+ y)"
, " - " , " - "
, y , y
, ")" , ")"
@@ -554,14 +558,9 @@ struct
] ]
in in
(* based on triangle order formed by `Ndc.ltrbToVertexRgb` function *) (* based on triangle order formed by `Ndc.ltrbToVertexRgb` function *)
x :: ey :: r :: g :: b :: x :: ey :: r :: g :: b :: ex :: ey :: r :: g :: b :: x :: y :: r :: g :: b
ex :: ey :: r :: g :: b :: :: x :: y :: r :: g :: b :: ex :: ey :: r :: g :: b :: ex :: y :: r :: g
x :: y :: r :: g :: b :: :: b :: acc
x :: y :: r :: g :: b ::
ex :: ey :: r :: g :: b ::
ex :: y :: r :: g :: b ::
acc
end end
fun toExportString (squares, canvasWidth, canvasHeight) = fun toExportString (squares, canvasWidth, canvasHeight) =
@@ -573,8 +572,17 @@ struct
val coords = BinTree.foldr (toExportStringFolder, bintree, []) val coords = BinTree.foldr (toExportStringFolder, bintree, [])
val coords = String.concatWith "," coords val coords = String.concatWith "," coords
val header = "" val header = String.concat
val footer = "" [ "structure AAA = \nstruct\n"
, " fun lerp (x, y, scale, windowWidth, windowHeight) =\n"
, " let\n"
, " val halfWidth = Real32.fromInt windowWidth / 2.0\n"
, " val halfHeight = Real32.fromInt windowHeight / 2.0\n"
, " in\n"
, " #[\n"
]
val footer = String.concat [" end\n", "end\n"]
in in
String.concat [header, coords, footer] String.concat [header, coords, footer]
end end