equal
deleted
inserted
replaced
37 return new paper.Path.RegularPolygon([0, 0], 6, radius); |
37 return new paper.Path.RegularPolygon([0, 0], 6, radius); |
38 } |
38 } |
39 }, |
39 }, |
40 "diamond":{ |
40 "diamond":{ |
41 getShape: function() { |
41 getShape: function() { |
42 var d = new paper.Path.Rectangle([-2, -2], [2, 2]); |
42 var d = new paper.Path.Rectangle([-Math.SQRT2, -Math.SQRT2], [Math.SQRT2, Math.SQRT2]); |
43 d.rotate(45); |
43 d.rotate(45); |
44 return d; |
44 return d; |
45 }, |
45 }, |
46 getImageShape: function(center, radius) { |
46 getImageShape: function(center, radius) { |
47 var d = new paper.Path.Rectangle([-radius, -radius], [radius*2, radius*2]); |
47 var d = new paper.Path.Rectangle([-radius*Math.SQRT2/2, -radius*Math.SQRT2/2], [radius*Math.SQRT2, radius*Math.SQRT2]); |
48 d.rotate(45); |
48 d.rotate(45); |
49 return d; |
49 return d; |
50 } |
50 } |
51 }, |
51 }, |
52 "star":{ |
52 "star":{ |
61 return { |
61 return { |
62 getShape: function() { |
62 getShape: function() { |
63 return new paper.Path(path); |
63 return new paper.Path(path); |
64 }, |
64 }, |
65 getImageShape: function(center, radius) { |
65 getImageShape: function(center, radius) { |
66 // No calcul for the moment |
66 // No calcul for the moment |
67 return new paper.Path(); |
67 return new paper.Path(); |
68 } |
68 } |
69 }; |
69 }; |
70 } |
70 } |
71 }; |
71 }; |
72 |
72 |
73 var ShapeBuilder = function (shape){ |
73 var ShapeBuilder = function (shape){ |
74 if(typeof shape==="undefined"){ |
74 if(shape === null || typeof shape === "undefined"){ |
75 shape = "circle"; |
75 shape = "circle"; |
76 } |
76 } |
77 if(shape.substr(0,4)==="svg:"){ |
77 if(shape.substr(0,4)==="svg:"){ |
78 return builders.svg(shape.substr(4)); |
78 return builders.svg(shape.substr(4)); |
79 } |
79 } |
80 if(!(shape in builders)){ |
80 if(!(shape in builders)){ |
81 shape = "circle"; |
81 shape = "circle"; |
82 } |
82 } |
83 return builders[shape]; |
83 return builders[shape]; |
84 }; |
84 }; |
85 |
85 |
86 return ShapeBuilder; |
86 return ShapeBuilder; |
87 |
87 |
88 }); |
88 }); |