modular-scale 2.0.0.alpha4 → 2.0.0.alpha5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/modular-scale.rb +5 -4
- data/stylesheets/_modular-scale-tests.scss +35 -0
- data/stylesheets/modular-scale.zip +0 -0
- data/stylesheets/modular-scale/_function-list.scss +12 -4
- data/stylesheets/modular-scale/_function.scss +11 -7
- data/stylesheets/modular-scale/_generate-list.scss +36 -11
- data/stylesheets/modular-scale/_pow.scss +2 -1
- data/stylesheets/modular-scale/_sort-list.scss +2 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a41d2f097a0279165903f7426bd0892afdc08cd0
|
4
|
+
data.tar.gz: eb01990d61ee5012f089180b06bd0a7ee9e4a002
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5eb6c45de955c5a6eca68e69d0da7fda2f6c1a7b0657a84e78a1c3ee188b8c2a32b82b1671850728d680e18975f66873497380f646af0b49ba50c859476d6903
|
7
|
+
data.tar.gz: 34d3e455fe63c42dc8d441ec158dbf086432ab1574ad4345bdf8d6126d8cf4532c2e4a1337715e9262c8d157797d8179c6dec17568b0e015e9c67f5db15dbf9b
|
data/lib/modular-scale.rb
CHANGED
@@ -16,7 +16,7 @@ Compass::Frameworks.register('modular-scale', :path => extension_path)
|
|
16
16
|
# a prerelease version
|
17
17
|
# Date is in the form of YYYY-MM-DD
|
18
18
|
module ModularScale
|
19
|
-
VERSION = "2.0.0.
|
19
|
+
VERSION = "2.0.0.alpha5"
|
20
20
|
DATE = "2013-12-20"
|
21
21
|
end
|
22
22
|
|
@@ -110,11 +110,12 @@ module Sass::Script::Functions
|
|
110
110
|
|
111
111
|
if rvalue < 0
|
112
112
|
r = r.keep_if { |a| a <= rbases[0] }
|
113
|
-
|
113
|
+
# Final value
|
114
|
+
r = r[rvalue - 1]
|
115
|
+
else
|
116
|
+
r = r[rvalue]
|
114
117
|
end
|
115
118
|
|
116
|
-
# Final value
|
117
|
-
r = r[rvalue]
|
118
119
|
|
119
120
|
Sass::Script::Number.new(r)
|
120
121
|
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
@if ms-list(-3, 3, 10 16, $major-third) != (6.5536 8 8.192 10 10.24 12.5 12.8) {
|
2
|
+
@warn "function ms-list(): FAIL";
|
3
|
+
@debug "function ms-list(-3, 3, 10 16, $major-third)";
|
4
|
+
@debug "Result: (#{ms-list(-3, 3, 10 16, $major-third)})";
|
5
|
+
@debug "Intended: (6.5536 8 8.192 10 10.24 12.5 12.8)";
|
6
|
+
}@else {
|
7
|
+
@debug "function ms-list(): PASS";
|
8
|
+
}
|
9
|
+
|
10
|
+
@if "#{ms(2, 16, $minor-sixth)}" != "40.96" {
|
11
|
+
@warn "function ms(): FAIL";
|
12
|
+
@debug "function ms(2, 16, $minor-sixth)";
|
13
|
+
@debug "Result: #{ms(2, 16, $minor-sixth)}";
|
14
|
+
@debug "Intended: 40.96";
|
15
|
+
}@else {
|
16
|
+
@debug "function ms(): PASS";
|
17
|
+
}
|
18
|
+
|
19
|
+
@if ms(2, 14 18, $major-second) != 15.75 {
|
20
|
+
@warn "function ms() multi-base: FAIL";
|
21
|
+
@debug "function ms(2, 14 18, $major-second)";
|
22
|
+
@debug "Result: #{ms(2, 14 18, $major-second)}";
|
23
|
+
@debug "Intended: 15.75";
|
24
|
+
}@else {
|
25
|
+
@debug "function ms() multi-base: PASS";
|
26
|
+
}
|
27
|
+
|
28
|
+
@if ms(-4, 12, $major-tenth $octave) != 1.92 {
|
29
|
+
@warn "function ms() multi-ratio: FAIL";
|
30
|
+
@debug "function ms(-4, 12, $major-tenth $octave)";
|
31
|
+
@debug "Result: #{ms(-4, 12, $major-tenth $octave)}";
|
32
|
+
@debug "Intended: 1.92";
|
33
|
+
}@else {
|
34
|
+
@debug "function ms() multi-ratio: PASS";
|
35
|
+
}
|
Binary file
|
@@ -1,6 +1,7 @@
|
|
1
1
|
// Outputs a list of values instead of a single value
|
2
2
|
@function ms-list($Start: 0, $End: 0, $Bases: $ms-base, $Ratios: $ms-ratio) {
|
3
3
|
|
4
|
+
// Seed results
|
4
5
|
$Positive-return: ();
|
5
6
|
$Negitive-return: ();
|
6
7
|
$Return: ();
|
@@ -37,17 +38,24 @@
|
|
37
38
|
|
38
39
|
// Sort the generated lists
|
39
40
|
$Negitive-return: ms-sort-list($Negitive-return);
|
41
|
+
|
42
|
+
// Reverse negitive list results.
|
43
|
+
$MS-new-return: ();
|
44
|
+
@each $i in $Negitive-return {
|
45
|
+
$MS-new-return: join($i, $MS-new-return);
|
46
|
+
}
|
47
|
+
$Negitive-return: $MS-new-return;
|
40
48
|
|
41
49
|
// Trim list
|
42
50
|
$Trim-list: ();
|
43
51
|
@if $End < 0 {
|
44
|
-
@for $i from abs($End) through abs($Start) {
|
45
|
-
$Trim-list: join(
|
52
|
+
@for $i from abs($End) through (abs($Start) + 2) {
|
53
|
+
$Trim-list: join(nth($Negitive-return, $i), $Trim-list);
|
46
54
|
}
|
47
55
|
}
|
48
56
|
@else {
|
49
|
-
@for $i from
|
50
|
-
$Trim-list: join(
|
57
|
+
@for $i from 2 through (abs($Start) + 1) {
|
58
|
+
$Trim-list: join(nth($Negitive-return, $i), $Trim-list);
|
51
59
|
}
|
52
60
|
}
|
53
61
|
$Negitive-return: $Trim-list;
|
@@ -28,17 +28,21 @@
|
|
28
28
|
// Sort the generated lists
|
29
29
|
$Return: ms-sort-list($Return);
|
30
30
|
|
31
|
+
// Reverse list if its negitive.
|
32
|
+
@if $Value < 0 {
|
33
|
+
$MS-new-return: ();
|
34
|
+
@each $i in $Return {
|
35
|
+
$MS-new-return: join($i, $MS-new-return);
|
36
|
+
}
|
37
|
+
$Return: $MS-new-return;
|
38
|
+
}
|
39
|
+
|
31
40
|
// Normalize value for counting from 1
|
32
41
|
// Because CSS counts things from 1
|
33
42
|
// So Sass does as well
|
34
43
|
// So I get to write fun stuff like this
|
35
|
-
|
36
|
-
|
37
|
-
}
|
38
|
-
@else {
|
39
|
-
$Value: $Value - 1;
|
40
|
-
}
|
41
|
-
|
44
|
+
$Value: abs($Value) + 1;
|
45
|
+
|
42
46
|
// Find the correct value in the list
|
43
47
|
$Return: nth($Return, $Value);
|
44
48
|
|
@@ -1,3 +1,17 @@
|
|
1
|
+
@function ms-reverse-list($list) {
|
2
|
+
@if length($list) > 1 {
|
3
|
+
@if nth($list, 1) > nth($list, length($list)) {
|
4
|
+
$MS-reversed-list: ();
|
5
|
+
@each $Value in $list {
|
6
|
+
$MS-reversed-list: join($Value, $MS-reversed-list);
|
7
|
+
}
|
8
|
+
@return $MS-reversed-list;
|
9
|
+
}
|
10
|
+
}
|
11
|
+
@return $list;
|
12
|
+
}
|
13
|
+
|
14
|
+
|
1
15
|
@function ms-generate-list($Value: 0, $Bases: $ms-base, $Ratios: $ms-ratio) {
|
2
16
|
|
3
17
|
// Create blank lists
|
@@ -14,12 +28,12 @@
|
|
14
28
|
$Base-counter: 0;
|
15
29
|
|
16
30
|
// Seed list with an initial value
|
17
|
-
@if $Base ==
|
31
|
+
@if $Base == $Base {
|
18
32
|
$MS-base-list: $Base;
|
19
33
|
}
|
20
34
|
|
21
35
|
// Find values on a positive scale
|
22
|
-
@if $Value
|
36
|
+
@if $Value >= 0 {
|
23
37
|
|
24
38
|
// Find lower values on the scale
|
25
39
|
$Base-counter: -1;
|
@@ -28,6 +42,9 @@
|
|
28
42
|
$Base-counter: $Base-counter - 1;
|
29
43
|
}
|
30
44
|
|
45
|
+
// Ensure the list is smallest to largest
|
46
|
+
$MS-base-list: ms-reverse-list($MS-base-list);
|
47
|
+
|
31
48
|
// Find higher possible values on the scale
|
32
49
|
$Base-counter: 1;
|
33
50
|
@while ms-calc($Base-counter, $Base, $Ratio) <= ms-calc($Value, nth($Bases, 1), $Ratio) {
|
@@ -46,6 +63,9 @@
|
|
46
63
|
$Base-counter: $Base-counter + 1;
|
47
64
|
}
|
48
65
|
|
66
|
+
// Ensure the list is smallest to largest
|
67
|
+
$MS-base-list: ms-reverse-list($MS-base-list);
|
68
|
+
|
49
69
|
// Find higher possible values on the scale
|
50
70
|
$Base-counter: -1;
|
51
71
|
@while ms-calc($Base-counter, $Base, $Ratio) >= ms-calc($Value, nth($Bases, 1), $Ratio) {
|
@@ -56,18 +76,23 @@
|
|
56
76
|
}
|
57
77
|
$Base-counter: $Base-counter - 1;
|
58
78
|
}
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
79
|
+
|
80
|
+
// Trim outlier base.
|
81
|
+
@if length($Bases) > 1 {
|
82
|
+
@for $i from 2 through length($Bases) {
|
83
|
+
@if nth($MS-base-list, 1) > nth($Bases, 1) {
|
84
|
+
$MS-new-list: ();
|
85
|
+
@for $i from 2 through length($MS-base-list) {
|
86
|
+
$MS-new-list: join($MS-new-list, nth($MS-base-list, $i));
|
87
|
+
}
|
88
|
+
$MS-base-list: $MS-new-list;
|
89
|
+
}
|
67
90
|
}
|
68
|
-
$MS-base-list: $ms-reversed-list;
|
69
91
|
}
|
70
92
|
}
|
93
|
+
|
94
|
+
// reverse list if its largest to smallest
|
95
|
+
$MS-base-list: ms-reverse-list($MS-base-list);
|
71
96
|
|
72
97
|
// Add new possibilities to the master list
|
73
98
|
$MS-list: append($MS-list, $MS-base-list, comma);
|
@@ -28,7 +28,8 @@
|
|
28
28
|
// If the number is 0 or negitive
|
29
29
|
// divide instead of multiply.
|
30
30
|
@else {
|
31
|
-
|
31
|
+
// Libsass doesn’t allow negitive values in loops
|
32
|
+
@for $i from (-1 + 1) to (abs($Exponent) + 1) {
|
32
33
|
$Return: $Return / $Base;
|
33
34
|
}
|
34
35
|
}
|
@@ -41,7 +41,6 @@
|
|
41
41
|
}
|
42
42
|
}
|
43
43
|
|
44
|
-
|
45
44
|
// Run through remainder values in the list
|
46
45
|
@while $A-counter <= length($A) {
|
47
46
|
$Current: nth($A, $A-counter);
|
@@ -62,6 +61,8 @@
|
|
62
61
|
@return $Return;
|
63
62
|
}
|
64
63
|
|
64
|
+
|
65
|
+
|
65
66
|
// Pull it all together
|
66
67
|
@function ms-sort-list($Lists) {
|
67
68
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: modular-scale
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.0.
|
4
|
+
version: 2.0.0.alpha5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- First Last
|
@@ -33,6 +33,7 @@ extra_rdoc_files: []
|
|
33
33
|
files:
|
34
34
|
- license.md
|
35
35
|
- lib/modular-scale.rb
|
36
|
+
- stylesheets/_modular-scale-tests.scss
|
36
37
|
- stylesheets/_modular-scale.scss
|
37
38
|
- stylesheets/modular-scale/_calc.scss
|
38
39
|
- stylesheets/modular-scale/_function-list.scss
|