| author | rougeronj |
| Wed, 03 Jun 2015 17:27:46 +0200 | |
| changeset 471 | e0c7be5dc02c |
| parent 441 | 4732f078d0fe |
| child 458 | 423bdf56d103 |
| permissions | -rw-r--r-- |
| 326 | 1 |
|
2 |
define([], function () { |
|
3 |
'use strict'; |
|
4 |
||
| 441 | 5 |
var cloud_path = "M0,0c-0.1218516546,-0.0336420601 -0.2451649928,0.0048580836 -0.3302944641,0.0884969975c-0.0444763883,-0.0550844815 -0.1047003238,-0.0975985034 -0.1769360893,-0.1175406746c-0.1859066673,-0.0513257002 -0.3774236254,0.0626045858 -0.4272374613,0.2541588105c-0.0036603877,0.0140753132 -0.0046241235,0.028229722 -0.0065872453,0.042307536c-0.1674179627,-0.0179317735 -0.3276106855,0.0900599386 -0.3725537463,0.2628868425c-0.0445325077,0.1712456429 0.0395025693,0.3463497959 0.1905420475,0.4183458793c-0.0082101538,0.0183442886 -0.0158652506,0.0372432828 -0.0211098452,0.0574080693c-0.0498130336,0.1915540431 0.0608692569,0.3884647499 0.2467762814,0.4397904033c0.0910577256,0.0251434257 0.1830791813,0.0103792696 0.2594677475,-0.0334472349c0.042100113,0.0928009202 0.1205930075,0.1674914182 0.2240666796,0.1960572479c0.1476344161,0.0407610407 0.297446165,-0.0238077445 0.3783262342,-0.1475652419c0.0327623278,0.0238981846 0.0691792333,0.0436665447 0.1102008706,0.0549940004c0.1859065794,0.0513256592 0.3770116432,-0.0627203154 0.4268255671,-0.2542745401c0.0250490557,-0.0963230532 0.0095494076,-0.1938010889 -0.0356681889,-0.2736906101c0.0447507424,-0.0439678867 0.0797796014,-0.0996624318 0.0969425462,-0.1656617192c0.0498137481,-0.1915564561 -0.0608688118,-0.3884669813 -0.2467755669,-0.4397928163c-0.0195699622,-0.0054005426 -0.0391731675,-0.0084429542 -0.0586916488,-0.0102888295c0.0115683912,-0.1682147574 -0.0933564223,-0.3269222408 -0.2572937178,-0.3721841203z"; |
| 326 | 6 |
/* ShapeBuilder Begin */ |
7 |
||
8 |
var builders = { |
|
9 |
"circle":{ |
|
10 |
getShape: function() { |
|
11 |
return new paper.Path.Circle([0, 0], 1); |
|
12 |
}, |
|
13 |
getImageShape: function(center, radius) { |
|
14 |
return new paper.Path.Circle(center, radius); |
|
15 |
} |
|
16 |
}, |
|
17 |
"rectangle":{ |
|
18 |
getShape: function() { |
|
19 |
return new paper.Path.Rectangle([-2, -2], [2, 2]); |
|
20 |
}, |
|
21 |
getImageShape: function(center, radius) { |
|
22 |
return new paper.Path.Rectangle([-radius, -radius], [radius*2, radius*2]); |
|
23 |
} |
|
24 |
}, |
|
25 |
"ellipse":{ |
|
26 |
getShape: function() { |
|
27 |
return new paper.Path.Ellipse(new paper.Rectangle([-2, -1], [2, 1])); |
|
28 |
}, |
|
29 |
getImageShape: function(center, radius) { |
|
30 |
return new paper.Path.Ellipse(new paper.Rectangle([-radius, -radius/2], [radius*2, radius])); |
|
31 |
} |
|
32 |
}, |
|
33 |
"polygon":{ |
|
34 |
getShape: function() { |
|
35 |
return new paper.Path.RegularPolygon([0, 0], 6, 1); |
|
36 |
}, |
|
37 |
getImageShape: function(center, radius) { |
|
38 |
return new paper.Path.RegularPolygon([0, 0], 6, radius); |
|
39 |
} |
|
40 |
}, |
|
41 |
"diamond":{ |
|
42 |
getShape: function() { |
|
|
435
e529b633c339
Add shape management, correction on shape manip[ulation on the client, correct 404 error on space creation, increment version
ymh <ymh.work@gmail.com>
parents:
328
diff
changeset
|
43 |
var d = new paper.Path.Rectangle([-Math.SQRT2, -Math.SQRT2], [Math.SQRT2, Math.SQRT2]); |
| 326 | 44 |
d.rotate(45); |
45 |
return d; |
|
46 |
}, |
|
47 |
getImageShape: function(center, radius) { |
|
|
435
e529b633c339
Add shape management, correction on shape manip[ulation on the client, correct 404 error on space creation, increment version
ymh <ymh.work@gmail.com>
parents:
328
diff
changeset
|
48 |
var d = new paper.Path.Rectangle([-radius*Math.SQRT2/2, -radius*Math.SQRT2/2], [radius*Math.SQRT2, radius*Math.SQRT2]); |
| 326 | 49 |
d.rotate(45); |
50 |
return d; |
|
51 |
} |
|
52 |
}, |
|
53 |
"star":{ |
|
54 |
getShape: function() { |
|
55 |
return new paper.Path.Star([0, 0], 8, 1, 0.7); |
|
56 |
}, |
|
57 |
getImageShape: function(center, radius) { |
|
58 |
return new paper.Path.Star([0, 0], 8, radius*1, radius*0.7); |
|
59 |
} |
|
60 |
}, |
|
| 441 | 61 |
"cloud": { |
62 |
getShape: function() { |
|
63 |
var path = new paper.Path(cloud_path); |
|
64 |
return path; |
|
65 |
||
66 |
}, |
|
67 |
getImageShape: function(center, radius) { |
|
68 |
var path = new paper.Path(cloud_path); |
|
69 |
path.scale(radius); |
|
70 |
path.translate(center); |
|
71 |
return path; |
|
72 |
} |
|
73 |
}, |
|
| 327 | 74 |
"svg": function(path){ |
75 |
return { |
|
76 |
getShape: function() { |
|
77 |
return new paper.Path(path); |
|
78 |
}, |
|
79 |
getImageShape: function(center, radius) { |
|
|
435
e529b633c339
Add shape management, correction on shape manip[ulation on the client, correct 404 error on space creation, increment version
ymh <ymh.work@gmail.com>
parents:
328
diff
changeset
|
80 |
// No calcul for the moment |
| 327 | 81 |
return new paper.Path(); |
82 |
} |
|
| 328 | 83 |
}; |
| 327 | 84 |
} |
| 326 | 85 |
}; |
|
435
e529b633c339
Add shape management, correction on shape manip[ulation on the client, correct 404 error on space creation, increment version
ymh <ymh.work@gmail.com>
parents:
328
diff
changeset
|
86 |
|
| 326 | 87 |
var ShapeBuilder = function (shape){ |
|
435
e529b633c339
Add shape management, correction on shape manip[ulation on the client, correct 404 error on space creation, increment version
ymh <ymh.work@gmail.com>
parents:
328
diff
changeset
|
88 |
if(shape === null || typeof shape === "undefined"){ |
| 327 | 89 |
shape = "circle"; |
90 |
} |
|
| 328 | 91 |
if(shape.substr(0,4)==="svg:"){ |
92 |
return builders.svg(shape.substr(4)); |
|
| 327 | 93 |
} |
| 326 | 94 |
if(!(shape in builders)){ |
95 |
shape = "circle"; |
|
96 |
} |
|
97 |
return builders[shape]; |
|
98 |
}; |
|
|
435
e529b633c339
Add shape management, correction on shape manip[ulation on the client, correct 404 error on space creation, increment version
ymh <ymh.work@gmail.com>
parents:
328
diff
changeset
|
99 |
|
| 326 | 100 |
return ShapeBuilder; |
101 |
||
102 |
}); |