progress with aligning graph lines

This commit is contained in:
2025-07-10 22:48:34 +01:00
parent 3fe3aa1d4d
commit cda90e3f44
4 changed files with 19 additions and 53 deletions

BIN
dotscape

Binary file not shown.

View File

@@ -1,44 +1,12 @@
structure ClickPoints =
struct
fun helpMakeOne (start, finish, numPoints, point) =
let
val difference = finish - start
val increment = Real32.fromInt difference / Real32.fromInt numPoints
val start = Real32.fromInt start
in
(Real32.fromInt point * increment) + start
end
fun makeOne (windowWidth, windowHeight, numPoints, point) =
if windowWidth > windowHeight then
let
val difference = windowWidth - windowHeight
val half = difference div 2
val widthStart = half
val widthFinish = windowWidth - half
in
helpMakeOne (widthStart, widthFinish, numPoints, point)
end
else if windowHeight > windowWidth then
let
val difference = windowHeight - windowWidth
val half = difference div 2
val heightStart = half
val heightFinish = windowHeight - half
in
helpMakeOne (heightStart, heightFinish, numPoints, point)
end
else
helpMakeOne (0, windowWidth, numPoints, point)
fun generate (start, finish, numPoints) =
let
val difference = finish - start
val increment = Real32.fromInt difference / Real32.fromInt numPoints
val start = Real32.fromInt start
in
Vector.tabulate (numPoints + 1, fn idx =>
(Real32.fromInt idx * increment) + start)
(Real32.fromInt idx * increment))
end
fun getClickPos (clickPoints, mousePos, idx) =

View File

@@ -5,35 +5,31 @@ end
structure GraphLines :> GRAPH_LINES =
struct
fun toNdc (cur, half) = (cur - half) / half
fun helpGenGraphLinesX (pos, xClickPoints, yClickPoints, acc,
windowWidth, windowHeight) =
if pos = Vector.length xClickPoints then
Vector.concat acc
else
let
val halfWidth = windowHeight div 2
val halfWidth = Real32.fromInt halfWidth
val halfHeight = windowHeight div 2
val halfHeight = Real32.fromInt halfHeight
val halfWidth = Real32.fromInt (windowWidth div 2)
val halfHeight = Real32.fromInt (windowHeight div 2)
val curX = Vector.sub (xClickPoints, pos)
val curYNdc = toNdc (curX, halfWidth)
val curXNdc = (curX - halfWidth) / halfWidth
val minY = Vector.sub (xClickPoints, 0)
val minY = toNdc (minY, halfWidth)
val minY = (~(minY - halfHeight)) / halfHeight
val maxY = Vector.sub (xClickPoints, Vector.length xClickPoints - 1)
val maxY = toNdc (maxY, halfWidth)
val maxY = (~(maxY - halfHeight)) /halfHeight
val acc =
#[ curYNdc - 0.001, minY
, curYNdc + 0.001, minY
, curYNdc + 0.001, maxY
#[ curXNdc - 0.001, minY
, curXNdc + 0.001, minY
, curXNdc + 0.001, maxY
, curYNdc + 0.001, maxY
, curYNdc - 0.001, maxY
, curYNdc - 0.001, minY
, curXNdc + 0.001, maxY
, curXNdc - 0.001, maxY
, curXNdc - 0.001, minY
] :: acc
in
helpGenGraphLinesX
@@ -52,12 +48,14 @@ struct
val halfHeight = Real32.fromInt halfHeight
val curY = Vector.sub (yClickPoints, pos)
val curYNdc = toNdc (curY, halfHeight)
val curYNdc =(~(curY - halfHeight)) / halfHeight
val minX = Vector.sub (xClickPoints, 0)
val minX = toNdc (minX, halfWidth)
val minX = (minX - halfWidth) / halfWidth
val maxX = Vector.sub (xClickPoints, Vector.length xClickPoints - 1)
val maxX = toNdc (maxX, halfWidth)
val _ = print ("maxX = " ^ Real32.toString maxX ^ "\n")
val maxX = (maxX - halfWidth) / halfWidth
val acc =
#[ minX, curYNdc - 0.001

View File

@@ -2,8 +2,8 @@ structure Constants =
struct
val windowWidth = 1000
val windowHeight = 900
val initialWidthClickPoints = 16
val initialHeightClickPoints = 20
val initialWidthClickPoints = 4
val initialHeightClickPoints = 4
val graphVertexShaderString =
"#version 300 es\n\