client/js/renderer/noderepr.js
changeset 326 e4afd8643576
parent 293 fba23fde14ba
child 327 239d372644a0
--- a/client/js/renderer/noderepr.js	Fri Aug 29 16:02:19 2014 +0200
+++ b/client/js/renderer/noderepr.js	Tue Sep 09 17:49:31 2014 +0200
@@ -1,6 +1,6 @@
 
 
-define(['jquery', 'underscore', 'requtils', 'renderer/baserepresentation'], function ($, _, requtils, BaseRepresentation) {
+define(['jquery', 'underscore', 'requtils', 'renderer/baserepresentation', 'renderer/shapebuilder'], function ($, _, requtils, BaseRepresentation, ShapeBuilder) {
     'use strict';
 
     var Utils = requtils.getUtils();
@@ -16,9 +16,13 @@
 
     _(NodeRepr.prototype).extend({
         _init: function() {
+            //console.log("INIT",this.model.get("shape"), ShapeBuilder);
             this.renderer.node_layer.activate();
             this.type = "Node";
-            this.circle = new paper.Path.Circle([0, 0], 1);
+            this.shapeBuilder = new ShapeBuilder(this.model.get("shape"));
+            // "circle" "rectangle" "ellipse" "regularpolygon" "star"
+            //this.shapeBuilder = new ShapeBuilder("diamond");
+            this.circle = this.shapeBuilder.getShape();
             this.circle.__representation = this;
             if (this.options.show_node_circles) {
                 this.circle.strokeWidth = this.options.node_stroke_width;
@@ -187,7 +191,7 @@
                 _clip = null,
                 baseRadius = null,
                 centerPoint = null;
-
+                
                 if (hasClipPath) {
                     _clip = new paper.Path();
                     var instructions = clipPath.match(/[a-z][^a-z]+/gi) || [],
@@ -276,7 +280,7 @@
                     _clip.__representation = this;
                 }
                 if (this.options.clip_node_images) {
-                    var _circleClip = new paper.Path.Circle(centerPoint, baseRadius);
+                    var _circleClip = this.shapeBuilder.getImageShape(centerPoint, baseRadius);
                     _raster = new paper.Group(_circleClip, _raster);
                     _raster.opacity = 0.99;
                     _raster.clipped = true;