forked from thoughtbot/bourbon
/
_golden-ratio.css.scss
32 lines (31 loc) · 967 Bytes
/
_golden-ratio.css.scss
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
@function golden-ratio($value, $increment) {
@if $increment > 0 {
@for $i from 1 through $increment {
$value: ($value * 1.618);
}
}
@if $increment < 0 {
$increment: abs($increment);
@for $i from 1 through $increment {
$value: ($value / 1.618);
}
}
@if $increment == 0 {
@warn "Increment value cannot be zero; must be ...-3, -2, -1, 1, 2, 3...";
}
@return $value;
}
// div {
// Increment Up GR with positive value
// font-size: golden-ratio(14px, 1); // returns: 22.652px
//
// Increment Down GR with negative value
// font-size: golden-ratio(14px, -1); // returns: 8.653px
//
// Can be used with ceil(round up) or floor(round down)
// font-size: floor( golden-ratio(14px, 1) ); // returns: 22px
// font-size: ceil( golden-ratio(14px, 1) ); // returns: 23px
// }
//
// modularscale.com
// goldenratiocalculator.com