client/js/renderer/shapebuilder.js
changeset 435 e529b633c339
parent 328 3e69a85d73e9
child 441 4732f078d0fe
--- a/client/js/renderer/shapebuilder.js	Sat Apr 25 04:37:06 2015 +0200
+++ b/client/js/renderer/shapebuilder.js	Mon Apr 27 17:22:46 2015 +0200
@@ -39,12 +39,12 @@
         },
         "diamond":{
             getShape: function() {
-                var d = new paper.Path.Rectangle([-2, -2], [2, 2]);
+                var d = new paper.Path.Rectangle([-Math.SQRT2, -Math.SQRT2], [Math.SQRT2, Math.SQRT2]);
                 d.rotate(45);
                 return d;
             },
             getImageShape: function(center, radius) {
-                var d = new paper.Path.Rectangle([-radius, -radius], [radius*2, radius*2]);
+                var d = new paper.Path.Rectangle([-radius*Math.SQRT2/2, -radius*Math.SQRT2/2], [radius*Math.SQRT2, radius*Math.SQRT2]);
                 d.rotate(45);
                 return d;
             }
@@ -63,15 +63,15 @@
                     return new paper.Path(path);
                 },
                 getImageShape: function(center, radius) {
-                    // No calcul for the moment 
+                    // No calcul for the moment
                     return new paper.Path();
                 }
             };
         }
     };
-    
+
     var ShapeBuilder = function (shape){
-        if(typeof shape==="undefined"){
+        if(shape === null || typeof shape === "undefined"){
             shape = "circle";
         }
         if(shape.substr(0,4)==="svg:"){
@@ -82,7 +82,7 @@
         }
         return builders[shape];
     };
-    
+
     return ShapeBuilder;
 
 });