|
1 | 1 | // Nepal |
2 | 2 | // http://www.crwflags.com/fotw/flags/np.html |
| 3 | +// http://www.vexilla-mundi.com/nepal_flag.html |
| 4 | +// http://crwflags.com/fotw/flags/np%27.html |
| 5 | +// This one is one of the hardest of the lot. The peculiar shape is done |
| 6 | +// through clip-path. We first cut the blue shape in the main div, then we cut |
| 7 | +// the red one in an :after. The two symbols are positionned through :before |
| 8 | +// and :first-letter. Symbols are simply displayed on the first line each one |
| 9 | +// is then placed at the correct position using text-shadow. |
| 10 | +// A lot of geometry is involved, don't hesitate to draw it on a sheet of |
| 11 | +// paper. |
3 | 12 | @mixin flag-npl() { |
4 | 13 | @include ratio(2 / 3); |
5 | 14 | $unit: $h800; |
6 | 15 | $red: #c8102e; |
7 | 16 | $blue: #0c2340; |
8 | 17 | $white: #FFFFFF; |
9 | 18 |
|
10 | | - background: $blue; |
11 | 19 |
|
12 | 20 | // We'll name points from A to E, starting on the top and rotating clockwise |
13 | 21 | $DE: 600 * $unit; |
|
40 | 48 | $C-x: $CJ; |
41 | 49 | $C-y: $AJ; |
42 | 50 |
|
| 51 | + background: $blue; |
43 | 52 | clip-path: polygon( |
44 | 53 | $A-x $A-y, |
45 | 54 | $B-x $B-y, |
|
78 | 87 | $E-x-offset: - $border-width; |
79 | 88 | $E-y-offset: $border-width; |
80 | 89 |
|
81 | | - &:before { |
82 | | - content: ""; |
83 | | - display: block; |
| 90 | + &:after { |
| 91 | + content: ''; |
| 92 | + z-index: 5; |
84 | 93 | position: absolute; |
85 | 94 | top: 0; |
86 | 95 | left: 0; |
|
98 | 107 | } |
99 | 108 |
|
100 | 109 |
|
| 110 | + // Let's roughly calculate the scale difference between the red and blue |
| 111 | + // shapes and apply it to everything we calculated here. |
| 112 | + $red-rectangle-area: $AE * $DE; |
| 113 | + $blue-rectangle-area: ($AE + 2 * $border-width) * ($DE + 2 * $border-width); |
| 114 | + $blue-red-ratio: $red-rectangle-area / $blue-rectangle-area; |
| 115 | + |
| 116 | + $star-width: 256 * $unit * $blue-red-ratio; |
| 117 | + $star-height: $star-width; |
| 118 | + $crescent-width: 240 * $unit * $blue-red-ratio; |
| 119 | + $crescent-height: 80 * $unit * $blue-red-ratio; |
| 120 | + $crescent-left: $border-width + 150 * $unit * $blue-red-ratio - $crescent-width / 2; |
| 121 | + $crescent-top: - $star-height / 2 + 240 * $unit; |
| 122 | + |
| 123 | + // Let's consider M the center of [CD] and L the point where the |
| 124 | + // perpendicular to (DE) goes through M |
| 125 | + $DM: $CD / 2; |
| 126 | + $LM: sin($alpha-CDE) * $DM; |
| 127 | + $star-top: - $star-height / 2 + ($height - $LM) + $border-width; |
| 128 | + $star-left: - $crescent-width + $crescent-left; |
101 | 129 |
|
| 130 | + &:before { |
| 131 | + content: $UTF8_NPL_CRESCENT+$UTF8_NPL_STAR; |
| 132 | + position: relative; // needed for first-letter and z-index to work |
| 133 | + z-index: 10; |
| 134 | + color: transparent; |
| 135 | + font-family: Symbols; |
| 136 | + font-size: $star-width; |
| 137 | + line-height: $star-width; |
| 138 | + text-shadow: $star-left $star-top 0 $white; |
| 139 | + } |
| 140 | + |
| 141 | + &:first-letter { |
| 142 | + font-family: Symbols; |
| 143 | + color: transparent; |
| 144 | + line-height: $star-width; // Use a line-height equal to the biggest of the two |
| 145 | + font-size: $crescent-width; |
| 146 | + text-shadow: $crescent-left $crescent-top 0 $white; |
| 147 | + } |
102 | 148 | }; |
0 commit comments