diff --git a/dotscape b/dotscape index 3b4b98d..6755356 100755 Binary files a/dotscape and b/dotscape differ diff --git a/fcore/common-update.sml b/fcore/common-update.sml index a2544eb..2750bb9 100644 --- a/fcore/common-update.sml +++ b/fcore/common-update.sml @@ -29,6 +29,18 @@ struct (model, [FILE msg]) end + fun getCollisionMsg (model: app_type) = + let + val {squares, canvasWidth, canvasHeight, modalNum, ...} = model + val exportString = + CollisionTree.toCollisionString (squares, canvasWidth, canvasHeight, modalNum) + val msg = EXPORT_COLLISIONS exportString + + val model = AppWith.modalNum (model, 0) + in + (model, [FILE msg]) + end + (* unimplemented *) fun useSquaresInNormalMode (model, squares) = (model, []) diff --git a/fcore/normal-mode.sml b/fcore/normal-mode.sml index d74b6b8..40a2a0f 100644 --- a/fcore/normal-mode.sml +++ b/fcore/normal-mode.sml @@ -363,6 +363,7 @@ struct | KEY_CTRL_S => CommonUpdate.getSaveSquaresMsg model | KEY_CTRL_L => CommonUpdate.getLoadSquaresMsg model | KEY_CTRL_E => CommonUpdate.getExportSquaresMsg model + | KEY_CTRL_C => CommonUpdate.getCollisionMsg model | USE_SQUARES {squares, canvasWidth, canvasHeight} => useSquares (model, squares, canvasWidth, canvasHeight) | SQUARES_LOAD_ERROR => CommonUpdate.squaresLoadError model diff --git a/fcore/quad-tree.sml b/fcore/quad-tree.sml index 85f5dca..7cfefc4 100644 --- a/fcore/quad-tree.sml +++ b/fcore/quad-tree.sml @@ -666,7 +666,6 @@ struct val qtree = buildTree (0, 0, size, squares) val bintree = merge (qtree, squares) - val scale = if scale = 0 then 1 else scale val f = toCollisionStringFolder scale val collisions = BinTree.foldr (f, bintree, []) val collisions = String.concatWith ",\n" collisions diff --git a/green.sml b/green.sml deleted file mode 100644 index 32b611d..0000000 --- a/green.sml +++ /dev/null @@ -1,55 +0,0 @@ -structure AAA = -struct - fun xToNdc (xOffset, xpos, scale, halfWidth) = - ((xpos * scale + xOffset) - halfWidth) / halfWidth - - fun endXToNdc (xOffset, startX, endX, scale, halfWidth) = - (((endX - startX) * scale + xOffset) - halfWidth) / halfWidth - - fun yToNdc (yOffset, ypos, scale, halfHeight) = - ~(((ypos * scale + yOffset) - halfHeight) / halfHeight) - - fun endYToNdc (yOffset, startY, endY, scale, halfHeight) = - ~((((endY - startY) * scale + yOffset) - halfHeight) / halfHeight) - - fun lerp (xOffset, yOffset, scale, windowWidth, windowHeight) = - let - val windowWidth = Real32.fromInt windowWidth - val halfWidth = windowWidth / 2.0 - val windowHeight = Real32.fromInt windowHeight - val halfHeight = windowHeight / 2.0 - in - #[ -xToNdc (xOffset, 1.000000000000000, scale, halfWidth), -yToNdc (yOffset, 2.000000000000000, scale, halfHeight), -0.000000000000000, -0.000000000000000, -0.000000000000000, -endXToNdc (xOffset, xToNdc (xOffset, 1.000000000000000, scale, halfWidth), 1.000000000000000, scale, halfWidth), -yToNdc (yOffset, 2.000000000000000, scale, halfHeight), -0.000000000000000, -0.000000000000000, -0.000000000000000, -xToNdc (xOffset, 1.000000000000000, scale, halfWidth), -yToNdc (yOffset, 1.000000000000000, scale, halfHeight), -0.000000000000000, -0.000000000000000, -0.000000000000000, -xToNdc (xOffset, 1.000000000000000, scale, halfWidth), -yToNdc (yOffset, 1.000000000000000, scale, halfHeight), -0.000000000000000, -0.000000000000000, -0.000000000000000, -endXToNdc (xOffset, xToNdc (xOffset, 1.000000000000000, scale, halfWidth), 1.000000000000000, scale, halfWidth), -yToNdc (yOffset, 2.000000000000000, scale, halfHeight), -0.000000000000000, -0.000000000000000, -0.000000000000000, -endXToNdc (xOffset, xToNdc (xOffset, 1.000000000000000, scale, halfWidth), 1.000000000000000, scale, halfWidth), -yToNdc (yOffset, 1.000000000000000, scale, halfHeight), -0.000000000000000, -0.000000000000000, -0.000000000000000 - ] - end -end diff --git a/message-types/file-msg.sml b/message-types/file-msg.sml index aa359ef..683a06d 100644 --- a/message-types/file-msg.sml +++ b/message-types/file-msg.sml @@ -4,6 +4,7 @@ struct SAVE_SQUARES of string | LOAD_SQUARES | EXPORT_SQUARES of string + | EXPORT_COLLISIONS of string | LOAD_FILES of string | SELECT_PATH of string end diff --git a/message-types/input-msg.sml b/message-types/input-msg.sml index ac589dc..c234c25 100644 --- a/message-types/input-msg.sml +++ b/message-types/input-msg.sml @@ -19,6 +19,7 @@ struct | KEY_CTRL_L | KEY_CTRL_E | KEY_CTRL_O + | KEY_CTRL_C | NUM of int | ARROW_UP | ARROW_LEFT