add function which generates a drawable vector given a mouse position
This commit is contained in:
BIN
dot-to-dot
BIN
dot-to-dot
Binary file not shown.
@@ -13,7 +13,11 @@ end
|
|||||||
message-types/input-msg.sml
|
message-types/input-msg.sml
|
||||||
|
|
||||||
functional-core/app-type.sml
|
functional-core/app-type.sml
|
||||||
functional-core/app-update.sml
|
ann
|
||||||
|
"allowVectorExps true"
|
||||||
|
in
|
||||||
|
functional-core/app-update.sml
|
||||||
|
end
|
||||||
|
|
||||||
ann
|
ann
|
||||||
"allowVectorExps true"
|
"allowVectorExps true"
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ struct
|
|||||||
]
|
]
|
||||||
|
|
||||||
local
|
local
|
||||||
fun getVerticalClickPos (idx, horizontalPos, mouseX, mouseY) =
|
fun getVerticalClickPos (idx, horizontalPos, mouseX, mouseY, r, g, b) =
|
||||||
if idx = Vector.length clickPoints then
|
if idx = Vector.length clickPoints then
|
||||||
#[]
|
#[]
|
||||||
else
|
else
|
||||||
@@ -31,27 +31,27 @@ struct
|
|||||||
val curVerticalPos = Vector.sub (clickPoints, idx)
|
val curVerticalPos = Vector.sub (clickPoints, idx)
|
||||||
in
|
in
|
||||||
if mouseY < curVerticalPos - 10 orelse mouseY > curVerticalPos + 10 then
|
if mouseY < curVerticalPos - 10 orelse mouseY > curVerticalPos + 10 then
|
||||||
getVerticalClickPos (idx + 1, horizontalPos, mouseX, mouseY)
|
getVerticalClickPos
|
||||||
|
(idx + 1, horizontalPos, mouseX, mouseY, r, g, b)
|
||||||
else
|
else
|
||||||
let
|
let
|
||||||
val left = Real32.fromInt ((horizontalPos - 10) div 500)
|
val left = Real32.fromInt (horizontalPos - 10) / 500.0
|
||||||
val right = Real32.fromInt ((horizontalPos + 10) div 500)
|
val right = Real32.fromInt (horizontalPos + 10) / 500.0
|
||||||
val bottom = Real32.fromInt ((curVerticalPos - 10) div 500)
|
val bottom = Real32.fromInt (curVerticalPos - 10) / 500.0
|
||||||
val top = Real32.fromInt ((curVerticalPos + 10) div 500)
|
val top = Real32.fromInt (curVerticalPos + 10) / 500.0
|
||||||
in
|
in
|
||||||
val highlightSquare = #[
|
#[ left, bottom, r, g, b,
|
||||||
left, bottom, (* lower left *)
|
right, bottom, r, g, b,
|
||||||
right, bottom, (* lower right *)
|
left, top, r, g, b,
|
||||||
left, top, (* upper left *)
|
|
||||||
|
|
||||||
left, top, (* upper left *)
|
left, top, r, g, b,
|
||||||
right, bottom, (* lower right *)
|
right, bottom, r, g, b,
|
||||||
right, top (* upper right *)
|
right, top, r, g, b
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
fun getHorizontalClickPos (idx, mouseX, mouseY) =
|
fun getHorizontalClickPos (idx, mouseX, mouseY, r, g, b) =
|
||||||
if idx = Vector.length clickPoints then
|
if idx = Vector.length clickPoints then
|
||||||
#[]
|
#[]
|
||||||
else
|
else
|
||||||
@@ -59,9 +59,9 @@ struct
|
|||||||
val curPos = Vector.sub (clickPoints, idx)
|
val curPos = Vector.sub (clickPoints, idx)
|
||||||
in
|
in
|
||||||
if mouseX < curPos - 10 orelse mouseX > curPos + 10 then
|
if mouseX < curPos - 10 orelse mouseX > curPos + 10 then
|
||||||
getHorizontalClickPos (idx + 1, mouseX, mouseY)
|
getHorizontalClickPos (idx + 1, mouseX, mouseY, r, g, b)
|
||||||
else
|
else
|
||||||
getVerticalClickPos (0, curPos, mouseX, mouseY)
|
getVerticalClickPos (0, curPos, mouseX, mouseY, r, g, b)
|
||||||
end
|
end
|
||||||
in
|
in
|
||||||
(*
|
(*
|
||||||
@@ -70,6 +70,7 @@ struct
|
|||||||
* If a square wasn't found at the clicked position,
|
* If a square wasn't found at the clicked position,
|
||||||
* an empty vector is returned.
|
* an empty vector is returned.
|
||||||
*)
|
*)
|
||||||
fun getClickPos (mouseX, mouseY) = getHorizontalClickPos (0, mouseX, mouseY)
|
fun getClickPos (mouseX, mouseY, r, g, b) =
|
||||||
|
getHorizontalClickPos (0, mouseX, mouseY, r, g, b)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user