1 Raphael.fn.star = function (cx, cy, rout, rin, n) {
2 rin = rin || rout * .5;
3 n = +n < 3 || !n ? 5 : n;
4 var points = ["M", cx, cy + rin, "L"],
6 for (var i = 1; i < n * 2; i++) {
7 R = i % 2 ? rout : rin;
8 points = points.concat([+(cx + R * Math.sin(i * Math.PI / n)).toFixed(3), +(cy + R * Math.cos(i * Math.PI / n)).toFixed(3)]);
11 return this.path(points);
13 Raphael.fn.flower = function (cx, cy, rout, rin, n) {
14 rin = rin || rout * .5;
15 n = +n < 3 || !n ? 5 : n;
16 var points = ["M", cx, cy + rin, "Q"],
18 for (var i = 1; i < n * 2 + 1; i++) {
19 R = i % 2 ? rout : rin;
20 points = points.concat([+(cx + R * Math.sin(i * Math.PI / n)).toFixed(3), +(cy + R * Math.cos(i * Math.PI / n)).toFixed(3)]);
23 return this.path(points);
25 Raphael.fn.spike = function (cx, cy, rout, rin, n) {
26 rin = rin || rout * .5;
27 n = +n < 3 || !n ? 5 : n;
28 var points = ["M", cx, cy - rout, "Q"],
30 for (var i = 1; i < n * 2 + 1; i++) {
31 R = i % 2 ? rin : rout;
32 points = points.concat([cx + R * Math.sin(i * Math.PI / n - Math.PI), cy + R * Math.cos(i * Math.PI / n - Math.PI)]);
35 return this.path(points);
37 Raphael.fn.polygon = function (cx, cy, r, n) {
38 n = +n < 3 || !n ? 5 : n;
39 var points = ["M", cx, cy - r, "L"],
41 for (var i = 1; i < n; i++) {
42 points = points.concat([cx + r * Math.sin(i * Math.PI * 2 / n - Math.PI), cy + r * Math.cos(i * Math.PI * 2 / n - Math.PI)]);
45 return this.path(points);
47 Raphael.fn.line = function (x1, y1, x2, y2) {
48 return this.path(["M", x1, y1, "L", x2, y2]);