|
5 | 5 | // http://www.mathalino.com/sites/default/files/images/005-planegeom-pentagram.jpg
|
6 | 6 | // http://musicians4freedom.com/wp-content/uploads/2014/06/phi-dimentions-in-pentagram_0.gif
|
7 | 7 | //
|
8 |
| -@function five-pointed-star($diameter, $left, $top) { |
| 8 | +@function five-pointed-star($diameter, $left, $top, $rotate:0) { |
| 9 | + $result: (); |
9 | 10 | $radius: _($diameter / 2);
|
10 | 11 | $golden-ratio: 1.618;
|
11 | 12 | // There are two circles that make a five pointed star.
|
|
14 | 15 | // Both radius have a ratio equal to the golden ratio
|
15 | 16 | $inner-radius: $radius - $radius / $golden-ratio;
|
16 | 17 |
|
17 |
| - // Whatever the size of the star, the inner angle of the peaks is always 36° |
18 |
| - $teta: 36deg; |
19 |
| - // The other angles of the triangles are 72° |
20 |
| - $beta: 72deg; |
21 |
| - $pentagram-side: 2 * (sin($teta) * $inner-radius); |
22 |
| - // teta is also equal to the angle from the center of the star to one inner |
23 |
| - // peak and with a right angle to the base of one of the triangles |
24 |
| - $inner-top-padding-x: $pentagram-side / 2; |
25 |
| - $inner-top-padding-y: cos($teta) * $inner-radius; |
26 |
| - $outer-top-padding-x: sqrt($radius * $radius - $inner-top-padding-y * $inner-top-padding-y); |
27 |
| - $outer-top-padding-y: $inner-top-padding-y; |
28 |
| - $inner-bottom-padding-x: ($pentagram-side / 2) + (cos($beta) * $pentagram-side); |
29 |
| - $inner-bottom-padding-y: sqrt($inner-radius * $inner-radius - $inner-bottom-padding-x * $inner-bottom-padding-x); |
30 |
| - $outer-bottom-padding-x: sin($teta) * $radius; |
31 |
| - $outer-bottom-padding-y: cos($teta) * $radius; |
32 |
| - |
33 |
| - // We'll name the points of the star starting from the top and in clockwise |
34 |
| - // order |
35 |
| - $A-x: 0; |
36 |
| - $A-y: -$radius; |
37 |
| - |
38 |
| - $B-x: $inner-top-padding-x; |
39 |
| - $B-y: -$inner-top-padding-y; |
40 |
| - |
41 |
| - $C-x: $outer-top-padding-x; |
42 |
| - $C-y: -$outer-top-padding-y; |
43 |
| - |
44 |
| - $D-x: $inner-bottom-padding-x; |
45 |
| - $D-y: $inner-bottom-padding-y; |
46 |
| - |
47 |
| - $E-x: $outer-bottom-padding-x; |
48 |
| - $E-y: $outer-bottom-padding-y; |
49 |
| - |
50 |
| - $F-x: 0; |
51 |
| - $F-y: $inner-radius; |
52 |
| - |
53 |
| - $G-x: -$outer-bottom-padding-x; |
54 |
| - $G-y: $outer-bottom-padding-y; |
55 |
| - |
56 |
| - $H-x: -$inner-bottom-padding-x; |
57 |
| - $H-y: $inner-bottom-padding-y; |
58 |
| - |
59 |
| - $I-x: -$outer-top-padding-x; |
60 |
| - $I-y: -$outer-top-padding-y; |
61 |
| - |
62 |
| - $J-x: -$inner-top-padding-x; |
63 |
| - $J-y: -$inner-top-padding-y; |
64 |
| - |
65 |
| - // Converting to px and placing relative to origin |
66 |
| - $A-x: $A-x * 1px + $left; |
67 |
| - $A-y: $A-y * 1px + $top; |
68 |
| - $B-x: $B-x * 1px + $left; |
69 |
| - $B-y: $B-y * 1px + $top; |
70 |
| - $C-x: $C-x * 1px + $left; |
71 |
| - $C-y: $C-y * 1px + $top; |
72 |
| - $D-x: $D-x * 1px + $left; |
73 |
| - $D-y: $D-y * 1px + $top; |
74 |
| - $E-x: $E-x * 1px + $left; |
75 |
| - $E-y: $E-y * 1px + $top; |
76 |
| - $F-x: $F-x * 1px + $left; |
77 |
| - $F-y: $F-y * 1px + $top; |
78 |
| - $G-x: $G-x * 1px + $left; |
79 |
| - $G-y: $G-y * 1px + $top; |
80 |
| - $H-x: $H-x * 1px + $left; |
81 |
| - $H-y: $H-y * 1px + $top; |
82 |
| - $I-x: $I-x * 1px + $left; |
83 |
| - $I-y: $I-y * 1px + $top; |
84 |
| - $J-x: $J-x * 1px + $left; |
85 |
| - $J-y: $J-y * 1px + $top; |
86 |
| - |
87 |
| - @return polygon( |
88 |
| - $A-x $A-y, |
89 |
| - $B-x $B-y, |
90 |
| - $C-x $C-y, |
91 |
| - $D-x $D-y, |
92 |
| - $E-x $E-y, |
93 |
| - $F-x $F-y, |
94 |
| - $G-x $G-y, |
95 |
| - $H-x $H-y, |
96 |
| - $I-x $I-y, |
97 |
| - $J-x $J-y |
98 |
| - ); |
| 18 | + $ang: $rotate; |
| 19 | + @for $i from 0 to 11 { |
| 20 | + $r: $radius; |
| 21 | + @if ($i % 2 == 1) { |
| 22 | + $r: $inner-radius; |
| 23 | + } |
| 24 | + $result: append($result, ($left + $r * sin($ang) $top - $r * cos($ang)), comma); |
| 25 | + $ang: $ang + 36; |
| 26 | + } |
| 27 | + |
| 28 | + @return $result; |
99 | 29 | }
|
0 commit comments