From 3d472e58940338d23fd3f4c5cef604f1f01bfb61 Mon Sep 17 00:00:00 2001 From: mohamed-ahmed Date: Tue, 19 Nov 2013 19:04:25 +0000 Subject: [PATCH] 'makeShake' and 'updateShape' working for triangle --- .../public/js/models/whiteboard_paper.coffee | 4 ++-- .../public/js/models/whiteboard_rect.coffee | 1 + .../js/models/whiteboard_triangle.coffee | 18 +++++++++++++++--- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/labs/bbb-html5-client/public/js/models/whiteboard_paper.coffee b/labs/bbb-html5-client/public/js/models/whiteboard_paper.coffee index 815ef3a50f..5409cccd72 100755 --- a/labs/bbb-html5-client/public/js/models/whiteboard_paper.coffee +++ b/labs/bbb-html5-client/public/js/models/whiteboard_paper.coffee @@ -385,7 +385,7 @@ define [ when "ellipse" @currentEllipse.update(data) when "triangle" - @currentTriangle.update.apply(@currentTriangle, data) + @currentTriangle.update(data) when "text" @currentText.update.apply(@currentText, data) else @@ -414,7 +414,7 @@ define [ when "triangle" @currentTriangle = @_createTool(shape) toolModel = @currentTriangle - tool = @currentTriangle.make.apply(@currentTriangle, data) + tool = @currentTriangle.make(data) when "text" @currentText = @_createTool(shape) toolModel = @currentText diff --git a/labs/bbb-html5-client/public/js/models/whiteboard_rect.coffee b/labs/bbb-html5-client/public/js/models/whiteboard_rect.coffee index 2b35a0183c..4ca85287a7 100644 --- a/labs/bbb-html5-client/public/js/models/whiteboard_rect.coffee +++ b/labs/bbb-html5-client/public/js/models/whiteboard_rect.coffee @@ -30,6 +30,7 @@ define [ y = data.shape.coordinate.firstY color = data.shape.color thickness = data.shape.thickness + @obj = @paper.rect(x * @gw + @xOffset, y * @gh + @yOffset, 0, 0, 1) @obj.attr Utils.strokeAndThickness(color, thickness) @definition = diff --git a/labs/bbb-html5-client/public/js/models/whiteboard_triangle.coffee b/labs/bbb-html5-client/public/js/models/whiteboard_triangle.coffee index ad75c67752..4d759c2ff4 100644 --- a/labs/bbb-html5-client/public/js/models/whiteboard_triangle.coffee +++ b/labs/bbb-html5-client/public/js/models/whiteboard_triangle.coffee @@ -23,10 +23,16 @@ define [ # @param {[type]} y the y value of the top left corner # @param {string} colour the colour of the object # @param {number} thickness the thickness of the object's line(s) - make: (x, y, colour, thickness) -> + make: (data) -> + + x = data.shape.coordinate.firstX + y = data.shape.coordinate.firstY + color = data.shape.color + thickness = data.shape.thickness + path = @_buildPath(x, y, x, y, x, y) @obj = @paper.path(path) - @obj.attr Utils.strokeAndThickness(colour, thickness) + @obj.attr Utils.strokeAndThickness(color, thickness) @obj.attr({"stroke-linejoin": "round"}) @definition = @@ -40,7 +46,13 @@ define [ # @param {number} y1 the y value of the top left corner # @param {number} x2 the x value of the bottom right corner # @param {number} y2 the y value of the bottom right corner - update: (x1, y1, x2, y2) -> + update: (data) -> + + x1 = data.shape.coordinate.firstX + y1 = data.shape.coordinate.firstY + x2 = data.shape.coordinate.lastX + y2 = data.shape.coordinate.lastY + if @obj? [xTop, yTop, xBottomLeft, yBottomLeft, xBottomRight, yBottomRight] = @_getCornersFromPoints(x1, y1, x2, y2)