progress on getting makeShape to work for 'rect'

This commit is contained in:
mohamed-ahmed 2013-11-19 00:14:37 +00:00
parent 7aa31b47b7
commit 813f10cef0
3 changed files with 18 additions and 6 deletions

View File

@ -94,16 +94,18 @@ define [
# Received event to update a shape being created
# @param {string} shape type of shape being updated
# @param {Array} data all information to update the shape
@socket.on "updShape", (shape, data) =>
@socket.on "updShape", (data) =>
shape = data.shape.type
console.log "socket on: updShape"
globals.events.trigger("connection:updShape", shape, data)
# Received event to create a shape on the whiteboard
# @param {string} shape type of shape being made
# @param {Array} data all information to make the shape
@socket.on "makeShape", (shape, data) =>
console.log "socket on: makeShape"
globals.events.trigger("connection:makeShape", shape, data)
@socket.on "whiteboardMakeShape", (data) =>
shape = data.shape.type
console.log "socket on: whiteboardMakeShape"
globals.events.trigger("connection:whiteboardMakeShape", shape, data)
# Pencil drawings are received as points from the server and painted as lines.
@socket.on "shapePoints", (type, color, thickness, points) =>

View File

@ -393,6 +393,10 @@ define [
# Make a shape `shape` with the data in `data`.
makeShape: (shape, data) ->
console.log("shape")
console.log(shape)
console.log("data")
console.log(data)
tool = null
switch shape
when "path", "line"
@ -546,7 +550,7 @@ define [
globals.events.on "connection:updShape", (shape, data) =>
@updateShape(shape, data)
globals.events.on "connection:makeShape", (shape, data) =>
globals.events.on "connection:whiteboardMakeShape", (shape, data) =>
@makeShape(shape, data)
globals.events.on "connection:shapePoints", (type, color, thickness, points) =>

View File

@ -23,7 +23,13 @@ define [
# @param {number} 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) ->
console.log("make data");
console.log(data);
x = data.shape.coordinate.firstX
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(colour, thickness)
@definition =