address edge case where Real32.toString 1.0 seems to give the string '1' instead of '1.0', and improve the drawing for upper case A

This commit is contained in:
2024-08-30 11:13:08 +01:00
parent c16fa58bf6
commit 42c4b92105
4 changed files with 56 additions and 16 deletions

8
a.dsc
View File

@@ -1,2 +1,6 @@
x ~0.0499999858439 y 0.400000035763 x ~0.400000035763 y 0.350000023842 x ~0.100000038743 y 0.100000038743
x 0.25 y ~0.449999958277 x 0.599999964237 y ~0.199999943376 x 0.0499999858439 y 0.0499999858439
x 0.449999958277 y ~0.349999964237 x ~0.350000023842 y ~0.0500000528991 x 0.349999964237 y ~0.0500000528991
x ~0.350000023842 y ~0.0500000528991 x ~0.450000017881 y ~0.349999964237 x 0.449999958277 y ~0.349999964237
x ~0.10000000149 y 1 x 0.20000000298 y 1 x 1 y ~1
x 1 y ~1 x 0.699999988079 y ~1 x ~0.10000000149 y 1
x 0.10000000149 y 1 x ~0.20000000298 y 1 x ~1 y ~1
x ~1 y ~1 x ~0.699999988079 y ~1 x 0.10000000149 y 1

50
a.sml
View File

@@ -1,4 +1,4 @@
structure LowerCaseA =
structure UpperCaseA =
struct
fun lerp (startX, startY, drawWidth, drawHeight, windowWidth, windowHeight) : Real32.real vector =
let
@@ -10,18 +10,42 @@ struct
val windowHeight = windowHeight / 2.0
val windowWidth = windowWidth / 2.0
in
#[ (((startX * (1.0 - 0.47499999404)) + (endX * 0.47499999404)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.700000047684)) + (endY * 0.700000047684)) / windowHeight) - 1.0,
(((startX * (1.0 - 0.299999982119)) + (endX * 0.299999982119)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.675000011921)) + (endY * 0.675000011921)) / windowHeight) - 1.0,
#[ (((startX * (1.0 - 0.724999964237)) + (endX * 0.724999964237)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.325000017881)) + (endY * 0.325000017881)) / windowHeight) - 1.0,
(((startX * (1.0 - 0.324999988079)) + (endX * 0.324999988079)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.474999964237)) + (endY * 0.474999964237)) / windowHeight) - 1.0,
(((startX * (1.0 - 0.674999952316)) + (endX * 0.674999952316)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.474999964237)) + (endY * 0.474999964237)) / windowHeight) - 1.0,
(((startX * (1.0 - 0.324999988079)) + (endX * 0.324999988079)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.474999964237)) + (endY * 0.474999964237)) / windowHeight) - 1.0,
(((startX * (1.0 - 0.274999976158)) + (endX * 0.274999976158)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.325000017881)) + (endY * 0.325000017881)) / windowHeight) - 1.0,
(((startX * (1.0 - 0.724999964237)) + (endX * 0.724999964237)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.325000017881)) + (endY * 0.325000017881)) / windowHeight) - 1.0,
(((startX * (1.0 - 0.449999988079)) + (endX * 0.449999988079)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.550000011921)) + (endY * 0.550000011921)) / windowHeight) - 1.0,
(((startX * (1.0 - 0.625)) + (endX * 0.625)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.275000035763)) + (endY * 0.275000035763)) / windowHeight) - 1.0,
(((startX * (1.0 - 0.799999952316)) + (endX * 0.799999952316)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.400000035763)) + (endY * 0.400000035763)) / windowHeight) - 1.0,
(((startX * (1.0 - 0.524999976158)) + (endX * 0.524999976158)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.524999976158)) + (endY * 0.524999976158)) / windowHeight) - 1.0
(((startY * (1.0 - 1.0)) + (endY * 1.0)) / windowHeight) - 1.0,
(((startX * (1.0 - 0.600000023842)) + (endX * 0.600000023842)) / windowWidth) - 1.0,
(((startY * (1.0 - 1.0)) + (endY * 1.0)) / windowHeight) - 1.0,
(((startX * (1.0 - 1.0)) + (endX * 1.0)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.0)) + (endY * 0.0)) / windowHeight) - 1.0,
(((startX * (1.0 - 1.0)) + (endX * 1.0)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.0)) + (endY * 0.0)) / windowHeight) - 1.0,
(((startX * (1.0 - 0.850000023842)) + (endX * 0.850000023842)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.0)) + (endY * 0.0)) / windowHeight) - 1.0,
(((startX * (1.0 - 0.449999988079)) + (endX * 0.449999988079)) / windowWidth) - 1.0,
(((startY * (1.0 - 1.0)) + (endY * 1.0)) / windowHeight) - 1.0,
(((startX * (1.0 - 0.550000011921)) + (endX * 0.550000011921)) / windowWidth) - 1.0,
(((startY * (1.0 - 1.0)) + (endY * 1.0)) / windowHeight) - 1.0,
(((startX * (1.0 - 0.40000000596)) + (endX * 0.40000000596)) / windowWidth) - 1.0,
(((startY * (1.0 - 1.0)) + (endY * 1.0)) / windowHeight) - 1.0,
(((startX * (1.0 - 0.0)) + (endX * 0.0)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.0)) + (endY * 0.0)) / windowHeight) - 1.0,
(((startX * (1.0 - 0.0)) + (endX * 0.0)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.0)) + (endY * 0.0)) / windowHeight) - 1.0,
(((startX * (1.0 - 0.15000000596)) + (endX * 0.15000000596)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.0)) + (endY * 0.0)) / windowHeight) - 1.0,
(((startX * (1.0 - 0.550000011921)) + (endX * 0.550000011921)) / windowWidth) - 1.0,
(((startY * (1.0 - 1.0)) + (endY * 1.0)) / windowHeight) - 1.0
]
end
end
end

BIN
dotscape

Binary file not shown.

View File

@@ -10,7 +10,7 @@ struct
datatype parse_result = OK of AppType.triangle list | PARSE_ERROR
val structureName = "LowerCaseA"
val structureName = "UpperCaseA"
val filename = "a.dsc"
val exportFilename = "a.sml"
@@ -18,6 +18,14 @@ struct
let
val num = (num + 1.0) / 2.0
val num = Real32.toString num
val num =
(* Problem: It seems that Real32.toString may sometimes return a string
* that is recognised as an integer, like "1" instead of "1.0".
* If that happens, we just add a ".0" to the end
* so it's recognised as a real. *)
if String.isSubstring "." num
then num
else num ^ ".0"
in
" (((startX * (1.0 - " ^ num ^ ")) + (endX * " ^ num ^ ")) / windowWidth) - 1.0"
end
@@ -26,6 +34,10 @@ struct
let
val num = (num + 1.0) / 2.0
val num = Real32.toString num
val num =
if String.isSubstring "." num
then num
else num ^ ".0"
in
" (((startY * (1.0 - " ^ num ^ ")) + (endY * " ^ num ^ ")) / windowHeight) - 1.0"
end