Fixed some errors
This commit is contained in:
parent
d5ab7d1009
commit
17e4ea629f
@ -1,6 +1,5 @@
|
||||
<template name="whiteboard">
|
||||
{{#if getInSession "display_whiteboard"}}
|
||||
<p>The whiteboard</p>
|
||||
<div id="whiteboard-paper" style="position: fixed; top: 10%; left: 30%;">
|
||||
<p>
|
||||
{{png}}
|
||||
|
19
labs/meteor-client/client/whiteboard_models/whiteboard_ellipse.coffee
Normal file → Executable file
19
labs/meteor-client/client/whiteboard_models/whiteboard_ellipse.coffee
Normal file → Executable file
@ -17,16 +17,17 @@ class @WhiteboardEllipseModel extends WhiteboardToolModel
|
||||
# @param {string} colour the colour of the object
|
||||
# @param {number} thickness the thickness of the object's line(s)
|
||||
make: (info) ->
|
||||
x = info.payload.data.coordinate.first_x
|
||||
y = info.payload.data.coordinate.first_y
|
||||
color = info.payload.data.line.color
|
||||
thickness = info.payload.data.line.weight
|
||||
if info?.payload?.data?.coordinate?
|
||||
x = info.payload.data.coordinate.first_x
|
||||
y = info.payload.data.coordinate.first_y
|
||||
color = info.payload.data.line.color
|
||||
thickness = info.payload.data.line.weight
|
||||
|
||||
@obj = @paper.ellipse(x * @gw + @xOffset, y * @gh + @yOffset, 0, 0)
|
||||
@obj.attr Utils.strokeAndThickness(color, thickness)
|
||||
@definition =
|
||||
shape: "ellipse"
|
||||
data: [x, y, y, x, @obj.attrs["stroke"], @obj.attrs["stroke-width"]]
|
||||
@obj = @paper.ellipse(x * @gw + @xOffset, y * @gh + @yOffset, 0, 0)
|
||||
@obj.attr Utils.strokeAndThickness(color, thickness)
|
||||
@definition =
|
||||
shape: "ellipse"
|
||||
data: [x, y, y, x, @obj.attrs["stroke"], @obj.attrs["stroke-width"]]
|
||||
@obj
|
||||
|
||||
# Update ellipse drawn
|
||||
|
86
labs/meteor-client/client/whiteboard_models/whiteboard_line.coffee
Normal file → Executable file
86
labs/meteor-client/client/whiteboard_models/whiteboard_line.coffee
Normal file → Executable file
@ -24,23 +24,23 @@ class @WhiteboardLineModel extends WhiteboardToolModel
|
||||
# @param {number} thickness the thickness of the line to be drawn
|
||||
make: (info) ->
|
||||
console.log "in line MAKE(info): " + info
|
||||
if info?.payload?.data?.coordinate?
|
||||
x = info.payload.data.coordinate.first_x
|
||||
y = info.payload.data.coordinate.first_y
|
||||
color = info.payload.data.line.color
|
||||
thickness = info.payload.data.line.weight
|
||||
|
||||
x = info.payload.data.coordinate.first_x
|
||||
y = info.payload.data.coordinate.first_y
|
||||
color = info.payload.data.line.color
|
||||
thickness = info.payload.data.line.weight
|
||||
x1 = x * @gw + @xOffset
|
||||
y1 = y * @gh + @yOffset
|
||||
path = "M" + x1 + " " + y1 + " L" + x1 + " " + y1
|
||||
pathPercent = "M" + x + " " + y + " L" + x + " " + y
|
||||
@obj = @paper.path(path)
|
||||
@obj.attr Utils.strokeAndThickness(color, thickness)
|
||||
@obj.attr({"stroke-linejoin": "round"})
|
||||
|
||||
x1 = x * @gw + @xOffset
|
||||
y1 = y * @gh + @yOffset
|
||||
path = "M" + x1 + " " + y1 + " L" + x1 + " " + y1
|
||||
pathPercent = "M" + x + " " + y + " L" + x + " " + y
|
||||
@obj = @paper.path(path)
|
||||
@obj.attr Utils.strokeAndThickness(color, thickness)
|
||||
@obj.attr({"stroke-linejoin": "round"})
|
||||
|
||||
@definition =
|
||||
shape: "path"
|
||||
data: [pathPercent, @obj.attrs["stroke"], @obj.attrs["stroke-width"]]
|
||||
@definition =
|
||||
shape: "path"
|
||||
data: [pathPercent, @obj.attrs["stroke"], @obj.attrs["stroke-width"]]
|
||||
|
||||
@obj
|
||||
|
||||
@ -56,44 +56,44 @@ class @WhiteboardLineModel extends WhiteboardToolModel
|
||||
# 2) undefined
|
||||
update: (info) ->
|
||||
console.log "in line-UPDATE(info): " + info
|
||||
if info?.payload?.data?.coordinate?
|
||||
x1 = info.payload.data.coordinate.first_x
|
||||
y1 = info.payload.data.coordinate.first_y
|
||||
x2 = info.payload.data.coordinate.last_x
|
||||
y2 = info.payload.data.coordinate.last_y
|
||||
|
||||
x1 = info.payload.data.coordinate.first_x
|
||||
y1 = info.payload.data.coordinate.first_y
|
||||
x2 = info.payload.data.coordinate.last_x
|
||||
y2 = info.payload.data.coordinate.last_y
|
||||
if @obj?
|
||||
|
||||
if @obj?
|
||||
# if adding points from the pencil
|
||||
if _.isBoolean(info.adding)
|
||||
add = info.adding
|
||||
|
||||
# if adding points from the pencil
|
||||
if _.isBoolean(info.adding)
|
||||
add = info.adding
|
||||
pathPercent = "L" + x1 + " " + y1
|
||||
@definition.data[0] += pathPercent
|
||||
|
||||
pathPercent = "L" + x1 + " " + y1
|
||||
@definition.data[0] += pathPercent
|
||||
x1 = x1 * @gw + @xOffset
|
||||
y1 = y1 * @gh + @yOffset
|
||||
|
||||
x1 = x1 * @gw + @xOffset
|
||||
y1 = y1 * @gh + @yOffset
|
||||
# if adding to the line
|
||||
if add
|
||||
path = @obj.attrs.path + "L" + x1 + " " + y1
|
||||
@obj.attr path: path
|
||||
|
||||
# if adding to the line
|
||||
if add
|
||||
path = @obj.attrs.path + "L" + x1 + " " + y1
|
||||
@obj.attr path: path
|
||||
# if simply updating the last portion (for drawing a straight line)
|
||||
else
|
||||
@obj.attrs.path.pop()
|
||||
path = @obj.attrs.path.join(" ")
|
||||
path = path + "L" + x1 + " " + y1
|
||||
@obj.attr path: path
|
||||
|
||||
# if simply updating the last portion (for drawing a straight line)
|
||||
# adding lines from the line tool
|
||||
else
|
||||
@obj.attrs.path.pop()
|
||||
path = @obj.attrs.path.join(" ")
|
||||
path = path + "L" + x1 + " " + y1
|
||||
path = @_buildPath(x1, y1, x2, y2)
|
||||
@definition.data[0] = path
|
||||
|
||||
path = @_scaleLinePath(path, @gw, @gh, @xOffset, @yOffset)
|
||||
@obj.attr path: path
|
||||
|
||||
# adding lines from the line tool
|
||||
else
|
||||
path = @_buildPath(x1, y1, x2, y2)
|
||||
@definition.data[0] = path
|
||||
|
||||
path = @_scaleLinePath(path, @gw, @gh, @xOffset, @yOffset)
|
||||
@obj.attr path: path
|
||||
|
||||
# Draw a line on the paper
|
||||
# @param {number,string} x1 1) the x value of the first point
|
||||
# 2) the string path
|
||||
|
54
labs/meteor-client/client/whiteboard_models/whiteboard_triangle.coffee
Normal file → Executable file
54
labs/meteor-client/client/whiteboard_models/whiteboard_triangle.coffee
Normal file → Executable file
@ -14,20 +14,20 @@ class @WhiteboardTriangleModel extends WhiteboardToolModel
|
||||
# @param {string} colour the colour of the object
|
||||
# @param {number} thickness the thickness of the object's line(s)
|
||||
make: (info) ->
|
||||
if info?.payload?.data?.coordinate?
|
||||
x = info.payload.data.coordinate.first_x
|
||||
y = info.payload.data.coordinate.first_y
|
||||
color = info.payload.data.line.color
|
||||
thickness = info.payload.data.line.weight
|
||||
|
||||
x = info.payload.data.coordinate.first_x
|
||||
y = info.payload.data.coordinate.first_y
|
||||
color = info.payload.data.line.color
|
||||
thickness = info.payload.data.line.weight
|
||||
path = @_buildPath(x, y, x, y, x, y)
|
||||
@obj = @paper.path(path)
|
||||
@obj.attr Utils.strokeAndThickness(color, thickness)
|
||||
@obj.attr({"stroke-linejoin": "round"})
|
||||
|
||||
path = @_buildPath(x, y, x, y, x, y)
|
||||
@obj = @paper.path(path)
|
||||
@obj.attr Utils.strokeAndThickness(color, thickness)
|
||||
@obj.attr({"stroke-linejoin": "round"})
|
||||
|
||||
@definition =
|
||||
shape: "triangle"
|
||||
data: [x, y, x, y, @obj.attrs["stroke"], @obj.attrs["stroke-width"]]
|
||||
@definition =
|
||||
shape: "triangle"
|
||||
data: [x, y, x, y, @obj.attrs["stroke"], @obj.attrs["stroke-width"]]
|
||||
|
||||
@obj
|
||||
|
||||
@ -37,24 +37,24 @@ class @WhiteboardTriangleModel extends WhiteboardToolModel
|
||||
# @param {number} x2 the x value of the bottom right corner
|
||||
# @param {number} y2 the y value of the bottom right corner
|
||||
update: (info) ->
|
||||
if info?.payload?.data?.coordinate?
|
||||
x1 = info.payload.data.coordinate.first_x
|
||||
y1 = info.payload.data.coordinate.first_y
|
||||
x2 = info.payload.data.coordinate.last_x
|
||||
y2 = info.payload.data.coordinate.last_y
|
||||
|
||||
x1 = info.payload.data.coordinate.first_x
|
||||
y1 = info.payload.data.coordinate.first_y
|
||||
x2 = info.payload.data.coordinate.last_x
|
||||
y2 = info.payload.data.coordinate.last_y
|
||||
if @obj?
|
||||
[xTop, yTop, xBottomLeft, yBottomLeft, xBottomRight, yBottomRight] = @_getCornersFromPoints(x1, y1, x2, y2)
|
||||
|
||||
if @obj?
|
||||
[xTop, yTop, xBottomLeft, yBottomLeft, xBottomRight, yBottomRight] = @_getCornersFromPoints(x1, y1, x2, y2)
|
||||
path = @_buildPath(xTop * @gw + @xOffset, yTop * @gh + @yOffset,
|
||||
xBottomLeft * @gw + @xOffset, yBottomLeft * @gh + @yOffset,
|
||||
xBottomRight * @gw + @xOffset, yBottomRight * @gh + @yOffset)
|
||||
@obj.attr path: path
|
||||
|
||||
path = @_buildPath(xTop * @gw + @xOffset, yTop * @gh + @yOffset,
|
||||
xBottomLeft * @gw + @xOffset, yBottomLeft * @gh + @yOffset,
|
||||
xBottomRight * @gw + @xOffset, yBottomRight * @gh + @yOffset)
|
||||
@obj.attr path: path
|
||||
|
||||
@definition.data[0] = x1
|
||||
@definition.data[1] = y1
|
||||
@definition.data[2] = x2
|
||||
@definition.data[3] = y2
|
||||
@definition.data[0] = x1
|
||||
@definition.data[1] = y1
|
||||
@definition.data[2] = x2
|
||||
@definition.data[3] = y2
|
||||
|
||||
# Draw a triangle on the whiteboard
|
||||
# @param {number} x1 the x value of the top left corner
|
||||
|
Loading…
Reference in New Issue
Block a user