modular-scale 0.0.5 → 1.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
data/README.mdown CHANGED
@@ -12,47 +12,69 @@ Usage requires Sass. Visit [sass-lang.com](http://sass-lang.com) to learn more a
12
12
 
13
13
  `gem install modular-scale`
14
14
 
15
- Then add `require 'modular-scale'` to your Compass config file.
15
+ Add `require 'modular-scale'` to your Compass config file.
16
16
 
17
- ## Alternative installation (without Compass)
17
+ Import the file into your stylesheets: `@import 'modular-scale';`
18
18
 
19
- Compass provides a way for Sass mixins to be easily required into a project, but we also support the following:
19
+ ## Usage
20
20
 
21
- * Copy either `stylesheets/_modular-scale.sass` or `stylesheets/_modular-scale.scss` into your project's Sass directory
22
- * Import the file into your Sass stylesheet to access the mixins and functions. For example, `@import vendor/modular-scale`
21
+ Modular-scale is used as a function. Simply pass it through in place of any value to generate a value based on a modular scale.
23
22
 
24
- ## Usage
23
+ ```scss
24
+ width: modular-scale(2); // two up the modular scale
25
+ width: ms(2); // Shorthand for the line above
26
+ width: modular-scale(2, 1em); // two up the modular scale with a base size of 1em
27
+ width: modular-scale(2, 1em, $octave); // Same as above but on an octave scale
28
+ ```
29
+
30
+ You can output a list to your terminal to help you find out what values are on your scale.
31
+
32
+ ```scss
33
+ @include modular-scale-list($start, $end, $base-size, $ratio);
34
+ ```
35
+
36
+ By default, it writes 0-20 on the scale. You can also use shorthand to make things more efficient.
37
+
38
+ ```scss
39
+ @include ms-list; // shorthand without attributes
40
+ @include ms-list($start, $end, $base-size, $ratio); // shorthand with attributes
41
+ ```
42
+
43
+ As a side effect of the modular-scale functions a `exponent` function is also available.
44
+
45
+ ```scss
46
+ @include exponent($base, $exponent);
47
+ ```
25
48
 
26
- Sassy Modular Scale can be used as a function, mixin or a mixin that generates a range of classes to `@extend`.
49
+ Sassy Modular Scale can be used as a function, like so:
27
50
 
28
51
  ```scss
29
52
  // Use as a function. Fill in the multiple, base-size, and ratio
30
53
  height: modular-scale(7, 16px, $golden);
54
+ ```
31
55
 
32
- // Use as a mixin. Fill in the property, multiple, base-size, and ratio
33
- @include modular-scale(line-height, 1, 16px, $golden);
34
56
 
35
- // This method will generate a range of classes to `@extend`
36
- @include modular-scale-classes(6);
37
57
 
38
- h1 { @extend .ms-2; }
39
- h2 { @extend .ms-1; }
40
- h3 { @extend .ms-0; }
58
+ You can also 'lace' multiple ratios together by passing them in as a list (space-separated)
41
59
 
42
- // You can also 'lace' multiple ratios together by
43
- // passing them in as a list (space-separated)
60
+ ```scss
44
61
  .lace {
45
62
  width: ms(7, 16px, $golden $fourth);
46
63
  }
64
+ ```
65
+
66
+ You can also set the $base-size variable to a list to interrelate two significant known sizes in your design
67
+ *note:* the starting point of the scale will always be the *lowest* value in this list
47
68
 
48
- // You can also set the $base-size variable to a list
49
- // to interrelate two significant known sizes in your design
50
- // note: the starting point of the scale will always be the *lowest* value in this list
69
+ ```scss
51
70
  .multibases {
52
71
  width: ms(7, 16px 300px, $golden);
53
72
  }
54
-
55
- // You can use multiple $base-sizes and multiple $ratios together
73
+ ```
74
+
75
+ You can use multiple $base-sizes and multiple $ratios together
76
+
77
+ ```scss
56
78
  .multibase-multiratio {
57
79
  width: ms(7, 16px 300px, $golden $fourth);
58
80
  }
@@ -61,25 +83,33 @@ h3 { @extend .ms-0; }
61
83
 
62
84
  ## Ratios
63
85
 
64
- Below is a list of Ratios to choose from. By default, the variable `$ratio` is set to `$golden`.
65
-
66
- * $golden: 1.618
67
- * $double-octave: (4 / 1)
68
- * $major-twelfth: (3 / 1)
69
- * $major-eleventh: (8 / 3)
70
- * $major-tenth: (5 / 2)
71
- * $octave: (2 / 1)
72
- * $major-seventh: (15 / 8)
73
- * $minor-seventh: (16 / 9)
74
- * $major-sixth: (5 / 3)
75
- * $minor-sixth: (8 / 5)
76
- * $fifth: (3 / 2)
77
- * $augfourth: (1 / √2)
78
- * $fourth: (4 / 3)
79
- * $major-third: (5 / 4)
80
- * $minor-third: (6 / 5)
81
- * $major-second: (9 / 8)
82
- * $minor-second: (16 / 15)
86
+ The included ratios are called by functions. You can add your own ratios as well.
87
+
88
+ Below is a list of ratios to choose from. By default, the variable `$ratio` is set to `golden()`.
89
+
90
+ * golden()
91
+ * double-octave()
92
+ * major-twelfth()
93
+ * major-eleventh()
94
+ * major-tenth()
95
+ * octave()
96
+ * major-seventh()
97
+ * minor-seventh()
98
+ * major-sixth()
99
+ * minor-sixth()
100
+ * fifth()
101
+ * augfourth()
102
+ * fourth()
103
+ * major-third()
104
+ * minor-third()
105
+ * major-second()
106
+ * minor-second()
107
+
108
+ Add your own ratio in Sass by setting a variable and passint that to modular-scale.
109
+
110
+ ```scss
111
+ $my-variable: 1 / 3.14159265;
112
+ ```
83
113
 
84
114
  ## Inspiration
85
115
 
@@ -87,10 +117,10 @@ Sassy Modular Scale was adapted from [modularscale.com](http://modularscale.com/
87
117
 
88
118
  ## License
89
119
 
90
- Copyright (c) 2011 [Scott Kellum](http://www.scottkellum.com/) ([@scottkellum](http://twitter.com/scottkellum)), [Adam Stacoviak](http://adamstacoviak.com/) ([@adamstac](http://twitter.com/adamstac)) and [Mason Wendell](http://thecodingdesigner.com/) ([@canarymason](http://twitter.com/canarymason))
120
+ Copyright (c) 2011 [Scott Kellum](http://www.scottkellum.com/) ([@scottkellum](http://twitter.com/scottkellum)), [Adam Stacoviak](http://adamstacoviak.com/) ([@adamstac](http://twitter.com/adamstac)) and [Mason Wendell](http://thecodingdesigner.com/) ([@codingdesigner](http://twitter.com/codingdesigner))
91
121
 
92
122
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
93
123
 
94
124
  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
95
125
 
96
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
126
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/lib/modular-scale.rb CHANGED
@@ -1,9 +1,120 @@
1
1
  require 'compass'
2
+ require 'sassy-math'
2
3
  Compass::Frameworks.register("modular-scale", :path => "#{File.dirname(__FILE__)}/..")
3
4
 
5
+ # Modular Scale Functions
6
+ # module Sass::Script::Functions
7
+ # end
8
+
4
9
  module ModularScale
5
-
6
- VERSION = "0.0.5"
7
- DATE = "2011-09-15"
8
10
 
9
- end
11
+ VERSION = "1.0.rc1"
12
+ DATE = "2012-07-14"
13
+
14
+ end
15
+
16
+
17
+ # Modular Scale Sass Script
18
+ module Sass::Script
19
+ class Number < Literal
20
+ # Comparison
21
+ def <=>(other)
22
+ value <=> other.value
23
+ end
24
+ end
25
+ end
26
+
27
+ module Sass::Script::Functions
28
+ # Modular Scale
29
+ def double_octave
30
+ value = 4 / 1.0
31
+ Sass::Script::Number.new(value)
32
+ end
33
+ def major_twelfth
34
+ value = 3 / 1.0
35
+ Sass::Script::Number.new(value)
36
+ end
37
+ def major_eleventh
38
+ value = 8 / 3.0
39
+ Sass::Script::Number.new(value)
40
+ end
41
+ def major_tenth
42
+ value = 5 / 2.0
43
+ Sass::Script::Number.new(value)
44
+ end
45
+ def octave
46
+ value = 2 / 1.0
47
+ Sass::Script::Number.new(value)
48
+ end
49
+ def major_seventh
50
+ value = 15 / 8.0
51
+ Sass::Script::Number.new(value)
52
+ end
53
+ def minor_seventh
54
+ value = 16 /9.0
55
+ Sass::Script::Number.new(value)
56
+ end
57
+ def major_sixth
58
+ value = 5 / 3.0
59
+ Sass::Script::Number.new(value)
60
+ end
61
+ def minor_sixth
62
+ value = 8 / 5.0
63
+ Sass::Script::Number.new(value)
64
+ end
65
+ def fifth
66
+ value = 3 / 2.0
67
+ Sass::Script::Number.new(value)
68
+ end
69
+ def augmented_forth
70
+ value = Math.sqrt(2) / 1.0
71
+ Sass::Script::Number.new(value)
72
+ end
73
+ def fourth
74
+ value = 4 / 3.0
75
+ Sass::Script::Number.new(value)
76
+ end
77
+ def major_third
78
+ value = 5 / 4.0
79
+ Sass::Script::Number.new(value)
80
+ end
81
+ def minor_third
82
+ value = 6 / 5.0
83
+ Sass::Script::Number.new(value)
84
+ end
85
+ def major_second
86
+ value = 9 / 8.0
87
+ Sass::Script::Number.new(value)
88
+ end
89
+ def minor_second
90
+ value = 16 / 15.0
91
+ Sass::Script::Number.new(value)
92
+ end
93
+
94
+ # Lists
95
+ def sort_list(list)
96
+ sep = list.separator if list.is_a?(Sass::Script::List)
97
+ list = list.to_a.sort
98
+ Sass::Script::List.new(list, sep)
99
+ end
100
+ def reverse_list(list)
101
+ sep = list.separator if list.is_a?(Sass::Script::List)
102
+ list = list.to_a.reverse
103
+ Sass::Script::List.new(list, sep)
104
+ end
105
+ def trim_list(list, threshold, ascending)
106
+ # remove list items above or below a threshold
107
+ sep = list.separator if list.is_a?(Sass::Script::List)
108
+ list = list.to_a
109
+ if ascending.value
110
+ list = list.delete_if {
111
+ |x| x.value <= threshold.value
112
+ }
113
+ else
114
+ list = list.delete_if {
115
+ |x| x.value >= threshold.value
116
+ }
117
+ end
118
+ Sass::Script::List.new(list, sep)
119
+ end
120
+ end
@@ -1,40 +1,17 @@
1
1
  // SASSY MODULAR-SCALE
2
2
  // https://github.com/scottkellum/modular-scale
3
3
 
4
- @charset "UTF-8"
5
-
6
- // Ratios
7
- $golden: 1.618
8
- $gold: $golden
9
- $double-octave: (4 / 1)
10
- $major-twelfth: (3 / 1)
11
- $major-eleventh: (8 / 3)
12
- $major-tenth: (5 / 2)
13
- $octave: (2 / 1)
14
- $major-seventh: (15 / 8)
15
- $minor-seventh: (16 / 9)
16
- $major-sixth: (5 / 3)
17
- $minor-sixth: (8 / 5)
18
- $fifth: (3 / 2)
19
- $augfourth: (1 / 1.4142135623730950488) // (1 / √2)
20
- $fourth: (4 / 3)
21
- $major-third: (5 / 4)
22
- $minor-third: (6 / 5)
23
- $major-second: (9 / 8)
24
- $minor-second: (16 / 15)
25
-
26
4
  // Defaults
27
- $ratio: $golden !default
5
+ $ratio: golden_ratio() !default
28
6
  $base-size: 16px !default
29
- $property: font-size !default
30
- $class-slug: ms !default
7
+ $round_pixels: true !default
31
8
 
32
9
  // Modular Scale function
33
- @function modular-scale($multiple, $base-size, $ratio)
10
+ @function modular-scale($multiple, $base-size, $ratio, $round_pixels)
34
11
  // return the $base-size if $multiple is zero
35
12
  @if $multiple == 0
36
13
  @if type-of($base-size) == 'list'
37
- $base-size: sort-list($base-size)
14
+ $base-size: sort_list($base-size)
38
15
  @return nth($base-size, 1)
39
16
  // return just the simple $base-size value if it's not a list
40
17
  @return $base-size
@@ -43,36 +20,36 @@ $class-slug: ms !default
43
20
  // and multiple ratios are passed in as a list
44
21
  // calculate values in using each base-size / ratio combination
45
22
  @if type-of($base-size) == 'list' and type-of($ratio) == 'list'
46
- @if unit(ms-multibase-multiratio($multiple, $base-size, $ratio)) == 'px'
23
+ @if unit(ms-multibase-multiratio($multiple, $base-size, $ratio)) == 'px' and $round_pixels == true
47
24
  @return round(ms-multibase-multiratio($multiple, $base-size, $ratio))
48
25
  @return ms-multibase-multiratio($multiple, $base-size, $ratio)
49
-
26
+
50
27
  // if multiple base-sizes are passed in as a list
51
28
  // calculate values in using each base-size
52
29
  @if type-of($base-size) == 'list' and type-of($ratio) == 'number'
53
- @if unit(ms-multibase($multiple, $base-size, $ratio)) == 'px'
30
+ @if unit(ms-multibase($multiple, $base-size, $ratio)) == 'px' and $round_pixels == true
54
31
  @return round(ms-multibase($multiple, $base-size, $ratio))
55
32
  @return ms-multibase($multiple, $base-size, $ratio)
56
-
33
+
57
34
  // if multiple ratios are passed in as a list
58
35
  // calculate values in using each ratio
59
36
  @if type-of($base-size) == 'number' and type-of($ratio) == 'list'
60
- @if unit(ms-multiratio($multiple, $base-size, $ratio)) == 'px'
37
+ @if unit(ms-multiratio($multiple, $base-size, $ratio)) == 'px' and $round_pixels == true
61
38
  @return round(ms-multiratio($multiple, $base-size, $ratio))
62
39
  @return ms-multiratio($multiple, $base-size, $ratio)
63
-
40
+
64
41
  // If there are no lists just run the simple function
65
- @if unit(exponent($ratio, $multiple) * $base-size) == 'px'
66
- @return round(exponent($ratio, $multiple) * $base-size)
67
- @return exponent($ratio, $multiple) * $base-size
68
-
69
-
42
+ @if unit(power($ratio, $multiple) * $base-size) == 'px' and $round_pixels == true
43
+ @return round(power($ratio, $multiple) * $base-size)
44
+ @return power($ratio, $multiple) * $base-size
45
+
46
+
70
47
  // calculate values in using each base-size / ratio combination
71
48
  @function ms-multibase-multiratio($multiple, $base-size, $ratio)
72
49
  // start with an empty list to place all values in
73
50
  $scale-values: ()
74
51
  // make sure base sizes are in ascending order
75
- $base-size: sort-list($base-size)
52
+ $base-size: sort_list($base-size)
76
53
  // take each base-size in turn
77
54
  $k: 1
78
55
  @while $k <= length($base-size)
@@ -84,41 +61,41 @@ $class-slug: ms !default
84
61
  @while $j <= length($ratio)
85
62
  // reset $modular-scale for each set
86
63
  $modular-scale: nth($base-size, $k)
87
- // do the scale for each base-size using this ratio
64
+ // do the scale for each base-size using this ratio
88
65
  @if $multiple > 0
89
66
  // up $multiple times
90
- // and add the result to $scale-values
67
+ // and add the result to $scale-values
91
68
  @for $i from 1 through $multiple
92
- $modular-scale: exponent(nth($ratio, $j), $i) * nth($base-size, $k)
69
+ $modular-scale: power(nth($ratio, $j), $i) * nth($base-size, $k)
93
70
  $scale-values: append($scale-values, $modular-scale)
94
71
  // and down until the value is lower than the lowest $base-size
95
72
  // and add the result to $scale-values
96
73
  $i: -1
97
74
  $modular-scale: nth($base-size, $k)
98
75
  @while $modular-scale >= nth($base-size, 1)
99
- $modular-scale: exponent(nth($ratio, $j), $i) * nth($base-size, $k)
76
+ $modular-scale: power(nth($ratio, $j), $i) * nth($base-size, $k)
100
77
  $scale-values: append($scale-values, $modular-scale)
101
78
  $i: $i - 1
102
79
  @if $multiple < 0
103
80
  // do the scale down for each set to below 1px
104
- $i: -1
81
+ $i: 0
105
82
  $modular-scale: nth($base-size, $k)
106
- @while $modular-scale > 1
107
- $modular-scale: exponent(nth($ratio, $j), $i) * nth($base-size, $k)
83
+ @while $i >= $multiple
84
+ $modular-scale: power(nth($ratio, $j), $i) * nth($base-size, $k)
108
85
  $scale-values: append($scale-values, $modular-scale)
109
86
  $i: $i - 1
110
87
  $j: $j + 1
111
88
  $k: $k + 1
112
89
  // return trimmed and sorted final list
113
90
  @return trim-sort($multiple, $scale-values, $base-size)
114
-
115
-
91
+
92
+
116
93
  // calculate values in using each base-size
117
94
  @function ms-multibase($multiple, $base-size, $ratio)
118
95
  // start with an empty list to place all values in
119
96
  $scale-values: ()
120
97
  // make sure base sizes are in ascending order
121
- $base-size: sort-list($base-size)
98
+ $base-size: sort_list($base-size)
122
99
  // take each base-size in turn
123
100
  $k: 1
124
101
  @while $k <= length($base-size)
@@ -127,34 +104,34 @@ $class-slug: ms !default
127
104
  $scale-values: append($scale-values, nth($base-size, $k))
128
105
  // reset $modular-scale for each set
129
106
  $modular-scale: nth($base-size, $k)
130
- // do the scale for each base-size using this ratio
107
+ // do the scale for each base-size using this ratio
131
108
  @if $multiple > 0
132
109
  // up $multiple times
133
- // and add the result to $scale-values
110
+ // and add the result to $scale-values
134
111
  @for $i from 1 through $multiple
135
- $modular-scale: exponent($ratio, $i) * nth($base-size, $k)
112
+ $modular-scale: power($ratio, $i) * nth($base-size, $k)
136
113
  $scale-values: append($scale-values, $modular-scale)
137
114
  // and down until the value is lower than the lowest $base-size
138
115
  // and add the result to $scale-values
139
116
  $i: -1
140
117
  $modular-scale: nth($base-size, $k)
141
118
  @while $modular-scale >= nth($base-size, 1)
142
- $modular-scale: exponent($ratio, $i) * nth($base-size, $k)
119
+ $modular-scale: power($ratio, $i) * nth($base-size, $k)
143
120
  $scale-values: append($scale-values, $modular-scale)
144
121
  $i: $i - 1
145
122
  @if $multiple < 0
146
123
  // do the scale down for each set to below 1px
147
- $i: -1
124
+ $i: 0
148
125
  $modular-scale: nth($base-size, $k)
149
- @while $modular-scale > 1
150
- $modular-scale: exponent($ratio, $i) * nth($base-size, $k)
126
+ @while $i >= $multiple
127
+ $modular-scale: power($ratio, $i) * nth($base-size, $k)
151
128
  $scale-values: append($scale-values, $modular-scale)
152
129
  $i: $i - 1
153
130
  $k: $k + 1
154
131
  // return trimmed and sorted final list
155
132
  @return trim-sort($multiple, $scale-values, $base-size)
156
133
 
157
-
134
+
158
135
  // calculate values in using each ratio
159
136
  @function ms-multiratio($multiple, $base-size, $ratio)
160
137
  // start with an empty list to place all values in
@@ -168,11 +145,11 @@ $class-slug: ms !default
168
145
  $modular-scale: $base-size
169
146
  // do the scale using this ratio thru the multiple, and add the result to $scale-values
170
147
  @for $i from 1 through $multiple
171
- $modular-scale: exponent(nth($ratio, $j), $i) * $base-size
148
+ $modular-scale: power(nth($ratio, $j), $i) * $base-size
172
149
  $scale-values: append($scale-values, $modular-scale)
173
150
  $j: $j + 1
174
- // sort acsending
175
- $scale-values: sort-list($scale-values)
151
+ // sort acsending
152
+ $scale-values: sort_list($scale-values)
176
153
  // return the final value using the laced list
177
154
  @return nth($scale-values, $multiple)
178
155
  // If $multiple is a negative integer (down the scale)
@@ -184,137 +161,56 @@ $class-slug: ms !default
184
161
  $modular-scale: $base-size
185
162
  // do the scale using this ratio thru the multiple, and add the result to $scale-values
186
163
  @for $i from 1 through ($multiple * -1)
187
- $modular-scale: exponent(nth($ratio, $j), -$i) * $base-size
164
+ $modular-scale: power(nth($ratio, $j), -$i) * $base-size
188
165
  $scale-values: append($scale-values, $modular-scale)
189
166
  $j: $j + 1
190
167
  // sort decending
191
- $scale-values: sort-list($scale-values, 'dec')
168
+ $scale-values: reverse_list(sort_list($scale-values))
192
169
  // return the final value using the laced list
193
170
  @return nth($scale-values, $multiple * -1)
194
-
195
-
171
+
172
+
196
173
  // trim and sort the final list
197
174
  @function trim-sort($multiple, $scale-values, $base-size)
198
175
  @if $multiple > 0
199
176
  // trim list so we can count from the lowest $base-size
200
- $scale-values: trim-list($scale-values, nth($base-size, 1))
201
- // sort acsending
202
- $scale-values: sort-list($scale-values)
177
+ $scale-values: trim_list($scale-values, nth($base-size, 1), true)
178
+ // sort acsending
179
+ $scale-values: sort_list($scale-values)
203
180
  // return the final value using the laced list
204
181
  @return nth($scale-values, $multiple)
205
182
  @else
206
183
  // trim list so we can count from the lowest $base-size
207
- $scale-values: trim-list($scale-values, nth($base-size, 1), 'dec')
208
- // sort acsending
209
- $scale-values: sort-list($scale-values, 'dec')
184
+ $scale-values: trim_list($scale-values, nth($base-size, 1), false)
185
+ // sort acsending
186
+ $scale-values: reverse_list(sort_list($scale-values))
210
187
  // return the final value using the laced list
211
188
  @return nth($scale-values, -$multiple)
212
-
213
-
189
+
190
+
214
191
  /////////////////////////////////////////////////////////////////////////
215
-
192
+
216
193
  // Shortcut
217
194
  @function ms($multiple, $base-size, $ratio)
218
195
  // Return the value from the Modular Scale function
219
196
  @return modular-scale($multiple, $base-size, $ratio)
220
197
 
221
- // Mixin
222
- // Deprecated. Use the modular-scale() function instead
223
- =modular-scale($property, $multiple, $base-size, $ratio)
224
- // Print the $property and return the value from the Modular Scale function
225
- @warn "The modular-scale mixin is deprecated. Instead use the function: width: modular-scale(3)"
226
- #{$property}: modular-scale($multiple, $base-size, $ratio)
227
-
228
- // Classes Mixin
229
- =modular-scale-classes($multiple, $property, $class-slug, $base-size, $ratio)
230
- // Loop from 0 through the value of $multiple and generate a range of classes
231
- @for $i from 0 through $multiple
232
- .#{$class-slug}-#{$i}
233
- // Print the $property and return the value from the Modular Scale function
234
- #{$property}: modular-scale($i, $base-size, $ratio)
235
-
236
-
237
- /////////////////////////////////////////////////////////////////////////
198
+ // Write Modular Scale List
199
+ @function modular-scale-list($start: 0, $finish: 20, $base-size: $base-size, $ratio: $ratio)
200
+ $ms-list: unquote("MS-LIST:")
201
+ @for $i from $start through $finish
202
+ $ms-list: append($ms-list, ms($i, $base-size, $ratio))
203
+ @return $ms-list
238
204
 
205
+ @function ms-list($start: 0, $finish: 20, $base-size: $base-size, $ratio: $ratio)
206
+ @return modular-scale-list($start, $finish, $base-size, $ratio)
239
207
 
240
- // Sass exponent support
241
- @function exponent($base, $exponent)
242
- // reset value
243
- $value: $base
244
- // positive intergers get multiplied
245
- @if $exponent > 1
246
- @for $i from 2 through $exponent
247
- $value: $value * $base
248
- // negitive intergers get divided. A number divided by itself is 1
249
- @if $exponent < 1
250
- @for $i from 0 through -$exponent
251
- $value: $value / $base
252
- // return the last value written
253
- @return $value
208
+ =modular-scale-list($start: 0, $finish: 20, $base-size: $base-size, $ratio: $ratio)
209
+ @debug modular-scale-list($start, $finish, $base-size, $ratio)
254
210
 
211
+ =ms-list($start: 0, $finish: 20, $base-size: $base-size, $ratio: $ratio)
212
+ @debug modular-scale-list($start, $finish, $base-size, $ratio)
255
213
 
256
- // Sass list sorting support
257
- @function sort-list($list, $dir: 'asc')
258
- // built-in list sorting in Sass would make this go away.
259
- // declare some empty lists to put our new order and temporary values
260
- $new-order: ()
261
- $temp: ()
262
- // fill $temp with the contents of $list
263
- $temp: join($temp, $list)
264
- // if sorting ascending
265
- @if $dir == 'asc'
266
- // loop through all values in $list
267
- @for $i from 1 through length($list)
268
- // impossibly high starter value to compare
269
- $low: 1000000
270
- // check for lowest value in $temp
271
- @for $j from 1 through length($temp)
272
- @if nth($temp, $j) < $low
273
- $low: nth($temp, $j)
274
- // add lowest value to $new-order
275
- $new-order: append($new-order, $low)
276
- // empty $temp for the next comparison
277
- $temp: ()
278
- // re-populate $temp with remaining values to sort
279
- @for $k from 1 through length($list)
280
- @if nth($list, $k) > $low
281
- $temp: append($temp, nth($list, $k))
282
- @if $dir == 'dec'
283
- // loop through all values in $list
284
- @for $i from 1 through length($list)
285
- // 0 starter value
286
- $high: 0
287
- // check for highest value in $temp
288
- @for $j from 1 through length($temp)
289
- @if nth($temp, $j) > $high
290
- $high: nth($temp, $j)
291
- $new-order: append($new-order, $high)
292
- // empty $temp for the next comparison
293
- $temp: ()
294
- // re-populate $temp with remaining values to sort
295
- @for $k from 1 through length($list)
296
- @if nth($list, $k) < $high
297
- $temp: append($temp, nth($list, $k))
298
- @return $new-order
299
-
300
-
301
- // Sass list trimming support
302
- @function trim-list($list, $start, $dir: 'asc')
303
- // built-in list trimming in Sass would make this go away.
304
- // declare some empty lists to put our trimmed values
305
- $trimmed: ()
306
- // if sorting ascending
307
- @if $dir == 'asc'
308
- // loop through all values in $list
309
- @for $i from 1 through length($list)
310
- @if nth($list, $i) >= $start
311
- $trimmed: append($trimmed, nth($list, $i))
312
- @if $dir == 'dec'
313
- // loop through all values in $list
314
- @for $i from 1 through length($list)
315
- @if nth($list, $i) <= $start
316
- $trimmed: append($trimmed, nth($list, $i))
317
- @return $trimmed
318
214
 
319
215
  // Other libraries can easily query if this function is avalible
320
- $modular-scale-loaded: true
216
+ $modular-scale-loaded: true
metadata CHANGED
@@ -1,8 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: modular-scale
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
5
- prerelease:
4
+ version: 1.0.rc1
5
+ prerelease: 4
6
6
  platform: ruby
7
7
  authors:
8
8
  - Scott Kellum
@@ -11,11 +11,11 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2011-09-15 00:00:00.000000000Z
14
+ date: 2012-07-14 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: compass
18
- requirement: &70108860747360 !ruby/object:Gem::Requirement
18
+ requirement: !ruby/object:Gem::Requirement
19
19
  none: false
20
20
  requirements:
21
21
  - - ! '>='
@@ -23,13 +23,34 @@ dependencies:
23
23
  version: 0.11.5
24
24
  type: :runtime
25
25
  prerelease: false
26
- version_requirements: *70108860747360
26
+ version_requirements: !ruby/object:Gem::Requirement
27
+ none: false
28
+ requirements:
29
+ - - ! '>='
30
+ - !ruby/object:Gem::Version
31
+ version: 0.11.5
32
+ - !ruby/object:Gem::Dependency
33
+ name: sassy-math
34
+ requirement: !ruby/object:Gem::Requirement
35
+ none: false
36
+ requirements:
37
+ - - ! '>='
38
+ - !ruby/object:Gem::Version
39
+ version: '1.0'
40
+ type: :runtime
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ none: false
44
+ requirements:
45
+ - - ! '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '1.0'
27
48
  description: Sassy Modular Scale calculates the incremental values of the modular
28
49
  scale.
29
50
  email:
30
51
  - scott@scottkellum.com
31
52
  - adam@stacoviak.com
32
- - mason@zivtech.com
53
+ - mason@canarypromo.com
33
54
  executables: []
34
55
  extensions: []
35
56
  extra_rdoc_files: []
@@ -49,9 +70,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
49
70
  - - ! '>='
50
71
  - !ruby/object:Gem::Version
51
72
  version: '0'
52
- segments:
53
- - 0
54
- hash: -3912929455498838517
55
73
  required_rubygems_version: !ruby/object:Gem::Requirement
56
74
  none: false
57
75
  requirements:
@@ -60,7 +78,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
60
78
  version: 1.3.6
61
79
  requirements: []
62
80
  rubyforge_project:
63
- rubygems_version: 1.8.10
81
+ rubygems_version: 1.8.24
64
82
  signing_key:
65
83
  specification_version: 3
66
84
  summary: Sassy Modular Scale calculates the incremental values of the modular scale