improve graph lines
This commit is contained in:
@@ -236,36 +236,43 @@ struct
|
||||
end
|
||||
|
||||
local
|
||||
fun loop (windowWidth, windowHeight, squares, acc) =
|
||||
fun loop (windowWidth, windowHeight, squares, acc, canvasWidth,
|
||||
canvasHeight, xClickPoints, yClickPoints) =
|
||||
case squares of
|
||||
{x, y, ex, ey, data = _} :: tl =>
|
||||
let
|
||||
val x = Real32.fromInt x
|
||||
val y = Real32.fromInt y
|
||||
val ex = Real32.fromInt ex
|
||||
val ey = Real32.fromInt ey
|
||||
val ex = if ex = x then x + 1 else ex
|
||||
val ey = if ey = y then y + 1 else ey
|
||||
|
||||
val x = Vector.sub (xClickPoints, x)
|
||||
val ex = Vector.sub (xClickPoints, ex)
|
||||
val y = Vector.sub (yClickPoints, y)
|
||||
val ey = Vector.sub (yClickPoints, ey)
|
||||
|
||||
val startX = Ndc.fromPixelX (x, windowWidth, windowHeight)
|
||||
val endX = Ndc.fromPixelX (ex, windowWidth, windowHeight)
|
||||
val endX = Ndc.fromPixelX (ex , windowWidth, windowHeight)
|
||||
val startY = Ndc.fromPixelY (y, windowWidth, windowHeight)
|
||||
val endY = Ndc.fromPixelY (ey, windowWidth, windowHeight)
|
||||
val endY = Ndc.fromPixelY (ey , windowWidth, windowHeight)
|
||||
|
||||
val vec =
|
||||
Ndc.ltrbToVertexRgb (startX, startY, endX, endY, 0.0, 0.0, 0.0)
|
||||
val acc = vec :: acc
|
||||
in
|
||||
loop (windowWidth, windowHeight, tl, acc)
|
||||
loop (windowWidth, windowHeight, tl, acc, canvasWidth, canvasHeight,
|
||||
xClickPoints, yClickPoints)
|
||||
end
|
||||
| [] => Vector.concat acc
|
||||
in
|
||||
fun toTriangles (windowWidth, windowHeight, squares, size) =
|
||||
fun toTriangles (windowWidth, windowHeight, squares, size, canvasWidth,
|
||||
canvasHeight, xClickPoints, yClickPoints) =
|
||||
let
|
||||
val qtree = build (0, 0, size, squares)
|
||||
val squares = toList qtree
|
||||
val msg = List.length squares
|
||||
val () = print (Int.toString msg ^ "\n")
|
||||
in
|
||||
loop (windowWidth, windowHeight, squares, [])
|
||||
loop (windowWidth, windowHeight, squares, [], canvasWidth, canvasHeight,
|
||||
xClickPoints, yClickPoints)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user