Sha256: 6aff0c5ae0291ea053bfd0424e56ef13cfacaf5defe6c08612643f90585f940c

Contents?: true

Size: 1.43 KB

Versions: 344

Compression:

Stored size: 1.43 KB

Contents

// Scaling Variables
$golden:           1.618;
$minor-second:     1.067;
$major-second:     1.125;
$minor-third:      1.2;
$major-third:      1.25;
$perfect-fourth:   1.333;
$augmented-fourth: 1.414;
$perfect-fifth:    1.5;
$minor-sixth:      1.6;
$major-sixth:      1.667;
$minor-seventh:    1.778;
$major-seventh:    1.875;
$octave:           2;
$major-tenth:      2.5;
$major-eleventh:   2.667;
$major-twelfth:    3;
$double-octave:    4;

@function modular-scale($value, $increment, $ratio) {
  $v1: nth($value, 1);
  $v2: nth($value, length($value));
  $value: $v1;

  // scale $v2 to just above $v1
  @while $v2 > $v1 {
    $v2: ($v2 / $ratio); // will be off-by-1
  }
  @while $v2 < $v1 {
    $v2: ($v2 * $ratio); // will fix off-by-1
  }

  // check AFTER scaling $v2 to prevent double-counting corner-case
  $double-stranded: $v2 > $v1;

  @if $increment > 0 {
    @for $i from 1 through $increment {
      @if $double-stranded and ($v1 * $ratio) > $v2 {
        $value: $v2;
        $v2: ($v2 * $ratio);
      } @else {
        $v1: ($v1 * $ratio);
        $value: $v1;
      }
    }
  }

  @if $increment < 0 {
    // adjust $v2 to just below $v1
    @if $double-stranded {
      $v2: ($v2 / $ratio);
    }

    @for $i from $increment through -1 {
      @if $double-stranded and ($v1 / $ratio) < $v2 {
        $value: $v2;
        $v2: ($v2 / $ratio);
      } @else {
        $v1: ($v1 / $ratio);
        $value: $v1;
      }
    }
  }

  @return $value;
}

Version data entries

344 entries across 335 versions & 10 rubygems

Version Path
smock-0.1.251 app/assets/stylesheets/thirdparty/bourbon/functions/_modular-scale.scss
smock-0.1.250 app/assets/stylesheets/thirdparty/bourbon/functions/_modular-scale.scss
smock-0.1.249 app/assets/stylesheets/thirdparty/bourbon/functions/_modular-scale.scss
wrgem-0.0.48 lib/generators/wrstart/template/vendor/assets/components/bourbon/dist/functions/_modular-scale.scss
wrgem-0.0.47 lib/generators/wrstart/template/vendor/assets/components/bourbon/dist/functions/_modular-scale.scss
wrgem-0.0.46 lib/generators/wrstart/template/vendor/assets/components/bourbon/dist/functions/_modular-scale.scss
wrgem-0.0.45 lib/generators/wrstart/template/vendor/assets/components/bourbon/dist/functions/_modular-scale.scss
wrgem-0.0.44 lib/generators/wrstart/template/vendor/assets/components/bourbon/dist/functions/_modular-scale.scss
thesis-0.1.3 app/assets/stylesheets/thesis/base/bourbon/functions/_modular-scale.scss
smock-0.1.247 app/assets/stylesheets/thirdparty/bourbon/functions/_modular-scale.scss
smock-0.1.246 app/assets/stylesheets/thirdparty/bourbon/functions/_modular-scale.scss
smock-0.1.245 app/assets/stylesheets/thirdparty/bourbon/functions/_modular-scale.scss
smock-0.1.244 app/assets/stylesheets/thirdparty/bourbon/functions/_modular-scale.scss
smock-0.1.243 app/assets/stylesheets/thirdparty/bourbon/functions/_modular-scale.scss
smock-0.1.242 app/assets/stylesheets/thirdparty/bourbon/functions/_modular-scale.scss
smock-0.1.241 app/assets/stylesheets/thirdparty/bourbon/functions/_modular-scale.scss
smock-0.1.240 app/assets/stylesheets/thirdparty/bourbon/functions/_modular-scale.scss
smock-0.1.239 app/assets/stylesheets/thirdparty/bourbon/functions/_modular-scale.scss
smock-0.1.2 app/assets/stylesheets/thirdparty/bourbon/functions/_modular-scale.scss
smock-0.1.1 app/assets/stylesheets/thirdparty/bourbon/functions/_modular-scale.scss