Skip to content

Commit a58a850

Browse files
committed
Adding comments on the clever way to draw stars
1 parent ebce2b9 commit a58a850

File tree

9 files changed

+321
-262
lines changed

9 files changed

+321
-262
lines changed

app/assets/fonts/Symbols.ttf

0 Bytes
Binary file not shown.

app/assets/fonts/Symbols.woff

-4 Bytes
Binary file not shown.

app/assets/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ <h1 class="c-header__title"><a href="https://pixelastic.github.io/css-flags/">CS
431431
</a>
432432
</div>
433433
<div class="c-flaglist--item c-flaglist--item__hard">
434-
<a href="https://github.com/pixelastic/css-flags/blob/master/app/styles/_flags/ic".scss">
434+
<a href="https://github.com/pixelastic/css-flags/blob/master/app/styles/_flags/ic.scss">
435435
<div class="c-flaglist--showcase">
436436
<div class="c-flaglist--showcase-inner">
437437
<div class="c-flag c-flag__ic"></div>

app/styles/_flags/chn.scss

+5-3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
$red: #de2910;
77
$yellow: #FDDA24;
88
$star-size: 6 * $unit;
9+
$star-offset-top: 5 * $unit;
10+
$star-offset-left: 5 * $unit;
911
$star-size-small: 2 * $unit;
1012

1113
background-color: $red;
@@ -16,12 +18,12 @@
1618
width: $width;
1719
height: $height;
1820
background: $yellow;
19-
clip-path: polygon(link_list(
20-
five-pointed-star($star-size, 5 * $unit, 5 * $unit),
21+
clip-path: polygon(link_polygons(
22+
five-pointed-star($star-size, $star-offset-left, $star-offset-top),
2123
five-pointed-star($star-size-small, 10 * $unit, 2 * $unit, -120.96),
2224
five-pointed-star($star-size-small, 12 * $unit, 4 * $unit, -98.13),
2325
five-pointed-star($star-size-small, 12 * $unit, 7 * $unit, -74.055),
2426
five-pointed-star($star-size-small, 10 * $unit, 9 * $unit, -54.34)
2527
));
2628
}
27-
};
29+
};

app/styles/_helpers/helper.scss

+5-3
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@
55
@return $value / ($value * 0 + 1);
66
}
77

8-
// Link polygen point lists to a single one
8+
// Link polygon point lists to a single one
99
// @args: lists with positions
10-
// @returns: New single list which can be used in polygen()
11-
@function link_list($args...) {
10+
// @returns: New single list which can be used in polygon()
11+
// Inspired by:
12+
// https://css-tricks.com/cutting-inner-part-element-using-clip-path/
13+
@function link_polygons($args...) {
1214
$result: ();
1315
$len: length($args);
1416

app/styles/_helpers/stars.scss

+10-8
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,29 @@
22
// @args size: Diameter of the circle in which the star is
33
// @args left: X coord of the star center
44
// @args top: Y coord of the star center
5+
// @args rotate: Angle to rotate the star
56
// http://www.mathalino.com/sites/default/files/images/005-planegeom-pentagram.jpg
67
// http://musicians4freedom.com/wp-content/uploads/2014/06/phi-dimentions-in-pentagram_0.gif
78
//
8-
@function five-pointed-star($diameter, $left, $top, $rotate:0) {
9+
@function five-pointed-star($diameter, $left, $top, $alpha:0) {
910
$result: ();
10-
$radius: _($diameter / 2);
11+
$whole-radius: _($diameter / 2);
1112
$golden-ratio: 1.618;
1213
// There are two circles that make a five pointed star.
1314
// A outer circle, where all the peaks are located
1415
// And an inner circle, where all the inner bases are located
1516
// Both radius have a ratio equal to the golden ratio
16-
$inner-radius: $radius - $radius / $golden-ratio;
17+
$inner-radius: $whole-radius - $whole-radius / $golden-ratio;
1718

18-
$ang: $rotate;
1919
@for $i from 0 to 11 {
20-
$r: $radius;
20+
$radius: $whole-radius;
2121
@if ($i % 2 == 1) {
22-
$r: $inner-radius;
22+
$radius: $inner-radius;
2323
}
24-
$result: append($result, ($left + $r * sin($ang) $top - $r * cos($ang)), comma);
25-
$ang: $ang + 36;
24+
$result: append($result,
25+
($left + $radius * sin($alpha) $top - $radius * cos($alpha)),
26+
comma);
27+
$alpha: $alpha + 36;
2628
}
2729

2830
@return $result;

app/styles/yarn.lock

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
2+
# yarn lockfile v1
3+
4+

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
"phantomcss": "^0.11.0",
5252
"postcss-brunch": "^0.5.0",
5353
"postcss-round-subpixels": "^1.2.0",
54-
"sass-brunch": "^1.9.0",
54+
"sass-brunch": "^2.10.4",
5555
"svg2ttf": "4.0.1",
5656
"svgicons2svgfont": "^5.0.0",
5757
"to-factory": "^1.0.0",

0 commit comments

Comments
 (0)