Real time collaboration over the canvas between the peers over the web.
The collaborative canvas exposes the below features:
-
Session : It allows the user to create a new session to work on collaboratively as well as load an existing session that any other user might have created. Once user creates or loads the session, all the changes made to the canvas are emitted by the client to the server using
sockets. Any other user joined to the session will receive the updates. -
Properties: A user can freely draw onto the canvas as well as upload images to the canvas. By default the brush strokes added cannot be modified in terms of resizing and movement from the original location. On the other hand, images can freely resized and moved along the X and Y axis. This allows to user to better scale the image in regard to the canvas size.
-
Undo-Redo : The project also provides ability to undo-redo the changes made to the canvas. By default the objects added to the canvas which are brush strokes cannot be modified in terms of size, location by the user. Therefore they become an excellent candidate for the
undo-redofeature. -
Canvas Properties: A user can change basic properties of the canvas like:
- Color: The color of brush stroke could be easily changed. For this purpose a color pallete is provided for the user to make there choice.
- Width: The width of the brush stroke could also be easily changed by the user. The user is provided with some defaults.
- DrawingMode: By default any change made to the canvas is made in the
drawingModewhich means that objects can only be added to the canvas but cannot be modified. This means that by default the user could only upload the images with the default size onto the canvas. This is resolved by unchecking theDrawingModecheckbox. Now the image could easily resized and moved onto the canvas plane.
The project uses these core external libraries to allow for the above feature set:
- Sockets : We use websockets to provide real-time updates to the users working on the same session.
- Fabricjs : Fabricjs is used as a canvas library for enabling the users to draw with brush and upload images to the canvas. The canvas fires
object:addedandobject:modifiedamong many others to track the movement of the user on the canvas. - Reactjs : It is the main View rendering library used. Different components relating to different parts of the project are created and combined together to provide feature set.
- LowDB : In order to store the events and replay them when user presses browser refresh, we store the events in a
JSONbased object store. TheAPIis simple and intuitive to allow for the events to be stored and retrieved. - Bootstrap : Bootstrap libary is used to provide CSS support.
- Yarn : Yarn is the package manager used to track and lock the dependencies for the project.
Requirements : docker (Dockerfile) / ruby (Rakefile)
The preferred way to build the project is through the use of docker. The project contains Dockerfile which contains the build steps for the project. Therefore to build and run the project:
docker build -t tagnamewhere tagname is the name of the image built.docker run -p 8080:8080 -d tagnameto run the image with the name tagname.
To better shorten the build efforts, Rakefile is provided to perform the above tasks.
rake buildbuilds the project.rake runwill first build the project and then start the server onto the host.
Requirements: Node v 4.7 or greater, yarn, npm
-
The project contains
package.jsonwhich exposes the dependencies for the project. Before the dependencies could be installed, we need to install some external libraries for one of the dependency node-canvas which is used to store the canvas state onto the server. The dependencies could be installed for the environment using the link provided. -
After that we can do
yarn installto install all the dependencies. -
We need to run
yarn run webpackafter it to create the bundle for the client code. -
Finally we start serving the project by
yarn start.
The project runs on 8080 port. For now this port value is not configurable therefore any attempt to run the project on a different port will fail.