diff --git a/dotscape b/dotscape index cace00e..43a368b 100755 Binary files a/dotscape and b/dotscape differ diff --git a/functional-core/app/app-update.sml b/functional-core/app/app-update.sml index 359cfdd..a70ce8e 100644 --- a/functional-core/app/app-update.sml +++ b/functional-core/app/app-update.sml @@ -17,11 +17,16 @@ struct let val drawVec = case ClickPoints.getClickPositionFromMouse model of - SOME (xpos, ypos) => - ClickPoints.getDrawDot (xpos, ypos, 1.0, 0.0, 0.0, model) + SOME (hIdx, vIdx) => + let + val xpos = Vector.sub (#xClickPoints model, hIdx) + val ypos = Vector.sub (#yClickPoints model, vIdx) + in + ClickPoints.getDrawDot (xpos, ypos, 1.0, 0.0, 0.0, model) + end | NONE => Vector.fromList [] val drawVec = TriangleStage.toVector (model, drawVec) - + val drawMsg = DRAW_DOT drawVec in (model, DRAW drawMsg) @@ -29,11 +34,15 @@ struct fun mouseLeftClick (model: app_type) = case ClickPoints.getClickPositionFromMouse model of - SOME (xpos, ypos) => + SOME (hIdx, vIdx) => let + val {windowWidth, windowHeight, xClickPoints, yClickPoints, ...} = + model + + val xpos = Vector.sub (xClickPoints, hIdx) + val ypos = Vector.sub (yClickPoints, vIdx) val dotVec = ClickPoints.getDrawDot (xpos, ypos, 0.0, 0.0, 1.0, model) - - val {windowWidth, windowHeight, ...} = model + val halfWidth = Real32.fromInt (windowWidth div 2) val halfHeight = Real32.fromInt (windowHeight div 2) val hpos = diff --git a/functional-core/app/click-points.sml b/functional-core/app/click-points.sml index 924ae13..dd77aa7 100644 --- a/functional-core/app/click-points.sml +++ b/functional-core/app/click-points.sml @@ -1,8 +1,7 @@ signature CLICK_POINTS = sig val generate: int * int -> Real32.real vector - val getClickPositionFromMouse: AppType.app_type - -> (Real32.real * Real32.real) option + val getClickPositionFromMouse: AppType.app_type -> (int * int) option val getDrawDot: Real32.real * Real32.real @@ -46,14 +45,14 @@ struct if mousePos < curPos - range orelse mousePos > curPos + range then getClickPos (clickPoints, mousePos, idx + 1) else - SOME (Vector.sub (clickPoints, idx)) + SOME idx end fun getClickPositionFromMouse (app: AppType.app_type) = case getClickPos (#xClickPoints app, #mouseX app, 0) of - SOME xPos => + SOME hIdx => (case getClickPos (#yClickPoints app, #mouseY app, 0) of - SOME yPos => SOME (xPos, yPos) + SOME vIdx => SOME (hIdx, vIdx) | NONE => NONE) | NONE => NONE