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 b = colToRealString b
val x = String.concat ["((", x, " - halfWidth) / halfWidth)"]
val y = String.concat ["(~(", y, " - halfHeight) / halfHeight)"]
val x = String.concat ["(((x + ", x, ") - halfWidth) / halfWidth)"]
val y = String.concat ["(~(y + ", y, ") - halfHeight) / halfHeight)"]
val ex = String.concat
[ "((((("
, "("
, ex
, "+ x)"
, " - "
, x
, ") "
@@ -544,7 +546,9 @@ struct
, "("
, "("
, "("
, "("
, ey
, "+ y)"
, " - "
, y
, ")"
@@ -554,14 +558,9 @@ struct
]
in
(* based on triangle order formed by `Ndc.ltrbToVertexRgb` function *)
x :: ey :: r :: g :: b ::
ex :: ey :: r :: g :: b ::
x :: y :: r :: g :: b ::
x :: y :: r :: g :: b ::
ex :: ey :: r :: g :: b ::
ex :: y :: r :: g :: b ::
acc
x :: ey :: r :: g :: b :: ex :: ey :: r :: g :: b :: x :: y :: r :: g :: b
:: x :: y :: r :: g :: b :: ex :: ey :: r :: g :: b :: ex :: y :: r :: g
:: b :: acc
end
fun toExportString (squares, canvasWidth, canvasHeight) =
@@ -573,8 +572,17 @@ struct
val coords = BinTree.foldr (toExportStringFolder, bintree, [])
val coords = String.concatWith "," coords
val header = ""
val footer = ""
val header = String.concat
[ "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
String.concat [header, coords, footer]
end