modular-scale 1.0.4 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -7,7 +7,7 @@ Compass::Frameworks.register("modular-scale", :path => "#{File.dirname(__FILE__)
7
7
  # end
8
8
 
9
9
  module ModularScale
10
- VERSION = "1.0.4"
10
+ VERSION = "1.0.5"
11
11
  DATE = "2012-08-13"
12
12
  end
13
13
 
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: 1.0.4
4
+ version: 1.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -36,7 +36,7 @@ dependencies:
36
36
  requirements:
37
37
  - - ! '>='
38
38
  - !ruby/object:Gem::Version
39
- version: '1.2'
39
+ version: '1.5'
40
40
  type: :runtime
41
41
  prerelease: false
42
42
  version_requirements: !ruby/object:Gem::Requirement
@@ -44,7 +44,7 @@ dependencies:
44
44
  requirements:
45
45
  - - ! '>='
46
46
  - !ruby/object:Gem::Version
47
- version: '1.2'
47
+ version: '1.5'
48
48
  description: Sassy Modular Scale calculates the incremental values of the modular
49
49
  scale.
50
50
  email:
@@ -57,7 +57,6 @@ extra_rdoc_files: []
57
57
  files:
58
58
  - README.mdown
59
59
  - lib/modular-scale.rb
60
- - stylesheets/_modular-scale.sass
61
60
  homepage: https://github.com/scottkellum/modular-scale
62
61
  licenses: []
63
62
  post_install_message:
@@ -1,226 +0,0 @@
1
- // SASSY MODULAR-SCALE
2
- // https://github.com/scottkellum/modular-scale
3
-
4
- // Defaults
5
- $ratio: golden_ratio() !default
6
- $base-size: 16px !default
7
- $round-pixels: true !default
8
-
9
- // Modular Scale function
10
- @function modular-scale($multiple, $base-size: $base-size, $ratio: $ratio, $round-pixels: $round-pixels)
11
- // return the $base-size if $multiple is zero
12
- @if $multiple == 0
13
- @if type-of($base-size) == 'list'
14
- $base-size: sort_list($base-size)
15
- @return nth($base-size, 1)
16
- // return just the simple $base-size value if it's not a list
17
- @return $base-size
18
-
19
- // if multiple base-sizes are passed in as a list
20
- // and multiple ratios are passed in as a list
21
- // calculate values in using each base-size / ratio combination
22
- @if type-of($base-size) == 'list' and type-of($ratio) == 'list'
23
- @if unit(ms-multibase-multiratio($multiple, $base-size, $ratio)) == 'px' and $round-pixels == true
24
- @return round(ms-multibase-multiratio($multiple, $base-size, $ratio))
25
- @return ms-multibase-multiratio($multiple, $base-size, $ratio)
26
-
27
- // if multiple base-sizes are passed in as a list
28
- // calculate values in using each base-size
29
- @if type-of($base-size) == 'list' and type-of($ratio) == 'number'
30
- @if unit(ms-multibase($multiple, $base-size, $ratio)) == 'px' and $round-pixels == true
31
- @return round(ms-multibase($multiple, $base-size, $ratio))
32
- @return ms-multibase($multiple, $base-size, $ratio)
33
-
34
- // if multiple ratios are passed in as a list
35
- // calculate values in using each ratio
36
- @if type-of($base-size) == 'number' and type-of($ratio) == 'list'
37
- @if unit(ms-multiratio($multiple, $base-size, $ratio)) == 'px' and $round-pixels == true
38
- @return round(ms-multiratio($multiple, $base-size, $ratio))
39
- @return ms-multiratio($multiple, $base-size, $ratio)
40
-
41
- // If there are no lists just run the simple function
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
-
47
- // calculate values in using each base-size / ratio combination
48
- @function ms-multibase-multiratio($multiple, $base-size: $base-size, $ratio: $ratio)
49
- // start with an empty list to place all values in
50
- $scale-values: ()
51
- // make sure base sizes are in ascending order
52
- $base-size: sort_list($base-size)
53
- // take each base-size in turn
54
- $k: 1
55
- @while $k <= length($base-size)
56
- // add each $base-size to the list except the first
57
- @if $k > 1
58
- $scale-values: append($scale-values, nth($base-size, $k))
59
- // take each ratio in turn
60
- $j: 1
61
- @while $j <= length($ratio)
62
- // reset $modular-scale for each set
63
- $modular-scale: nth($base-size, $k)
64
- // do the scale for each base-size using this ratio
65
- @if $multiple > 0
66
- // up $multiple times
67
- // and add the result to $scale-values
68
- @for $i from 1 through $multiple
69
- $modular-scale: power(nth($ratio, $j), $i) * nth($base-size, $k)
70
- $scale-values: append($scale-values, $modular-scale)
71
- // and down until the value is lower than the lowest $base-size
72
- // and add the result to $scale-values
73
- $i: -1
74
- $modular-scale: nth($base-size, $k)
75
- @while $modular-scale >= nth($base-size, 1)
76
- $modular-scale: power(nth($ratio, $j), $i) * nth($base-size, $k)
77
- $scale-values: append($scale-values, $modular-scale)
78
- $i: $i - 1
79
- @if $multiple < 0
80
- // do the scale down for each set to below 1px
81
- $i: 0
82
- $modular-scale: nth($base-size, $k)
83
- @while $i >= $multiple
84
- $modular-scale: power(nth($ratio, $j), $i) * nth($base-size, $k)
85
- $scale-values: append($scale-values, $modular-scale)
86
- $i: $i - 1
87
- $j: $j + 1
88
- $k: $k + 1
89
- // return trimmed and sorted final list
90
- @return trim-sort($multiple, $scale-values, $base-size)
91
-
92
-
93
- // calculate values in using each base-size
94
- @function ms-multibase($multiple, $base-size: $base-size, $ratio: $ratio)
95
- // start with an empty list to place all values in
96
- $scale-values: ()
97
- // make sure base sizes are in ascending order
98
- $base-size: sort_list($base-size)
99
- // take each base-size in turn
100
- $k: 1
101
- @while $k <= length($base-size)
102
- // add each $base-size to the list except the first
103
- @if $k > 1
104
- $scale-values: append($scale-values, nth($base-size, $k))
105
- // reset $modular-scale for each set
106
- $modular-scale: nth($base-size, $k)
107
- // do the scale for each base-size using this ratio
108
- @if $multiple > 0
109
- // up $multiple times
110
- // and add the result to $scale-values
111
- @for $i from 1 through $multiple
112
- $modular-scale: power($ratio, $i) * nth($base-size, $k)
113
- $scale-values: append($scale-values, $modular-scale)
114
- // and down until the value is lower than the lowest $base-size
115
- // and add the result to $scale-values
116
- $i: -1
117
- $modular-scale: nth($base-size, $k)
118
- @while $modular-scale >= nth($base-size, 1)
119
- $modular-scale: power($ratio, $i) * nth($base-size, $k)
120
- $scale-values: append($scale-values, $modular-scale)
121
- $i: $i - 1
122
- @if $multiple < 0
123
- // do the scale down for each set to below 1px
124
- $i: 0
125
- $modular-scale: nth($base-size, $k)
126
- @while $i >= $multiple
127
- $modular-scale: power($ratio, $i) * nth($base-size, $k)
128
- $scale-values: append($scale-values, $modular-scale)
129
- $i: $i - 1
130
- $k: $k + 1
131
- // return trimmed and sorted final list
132
- @return trim-sort($multiple, $scale-values, $base-size)
133
-
134
-
135
- // calculate values in using each ratio
136
- @function ms-multiratio($multiple, $base-size: $base-size, $ratio: $ratio)
137
- // start with an empty list to place all values in
138
- $scale-values: ()
139
- // If $multiple is a positive integer (up the scale)
140
- @if $multiple > 0
141
- // take each ratio in turn
142
- $j: 1
143
- @while $j <= length($ratio)
144
- // reset $modular-scale for each set
145
- $modular-scale: $base-size
146
- // do the scale using this ratio thru the multiple, and add the result to $scale-values
147
- @for $i from 1 through $multiple
148
- $modular-scale: power(nth($ratio, $j), $i) * $base-size
149
- $scale-values: append($scale-values, $modular-scale)
150
- $j: $j + 1
151
- // sort acsending
152
- $scale-values: sort_list($scale-values)
153
- // return the final value using the laced list
154
- @return nth($scale-values, $multiple)
155
- // If $multiple is a negative integer (down the scale)
156
- @if $multiple < 0
157
- // take each ratio in turn
158
- $j: 1
159
- @while $j <= length($ratio)
160
- // reset $modular-scale for each set
161
- $modular-scale: $base-size
162
- // do the scale using this ratio thru the multiple, and add the result to $scale-values
163
- @for $i from 1 through ($multiple * -1)
164
- $modular-scale: power(nth($ratio, $j), -$i) * $base-size
165
- $scale-values: append($scale-values, $modular-scale)
166
- $j: $j + 1
167
- // sort decending
168
- $scale-values: reverse_list(sort_list($scale-values))
169
- // return the final value using the laced list
170
- @return nth($scale-values, $multiple * -1)
171
-
172
-
173
- // trim and sort the final list
174
- @function trim-sort($multiple, $scale-values: $scale-values, $base-size: $base-size)
175
- @if $multiple > 0
176
- // trim list so we can count from the lowest $base-size
177
- $scale-values: trim_list($scale-values, nth($base-size, 1), true)
178
- // sort acsending
179
- $scale-values: sort_list($scale-values)
180
- // return the final value using the laced list
181
- @return nth($scale-values, $multiple)
182
- @else
183
- // trim list so we can count from the lowest $base-size
184
- $scale-values: trim_list($scale-values, nth($base-size, 1), false)
185
- // sort acsending
186
- $scale-values: reverse_list(sort_list($scale-values))
187
- // return the final value using the laced list
188
- @return nth($scale-values, -$multiple)
189
-
190
-
191
- /////////////////////////////////////////////////////////////////////////
192
-
193
- // alias for golden_ratio()
194
- @function golden()
195
- @return golden_ratio()
196
-
197
- // Shortcut
198
- @function ms($multiple, $base-size: $base-size, $ratio: $ratio, $round-pixels: $round-pixels)
199
- // Return the value from the Modular Scale function
200
- @return modular-scale($multiple, $base-size, $ratio, $round-pixels)
201
-
202
- // Write Modular Scale List
203
- @function modular-scale-list($start: 0, $finish: 20, $base-size: $base-size, $ratio: $ratio, $round-pixels: $round-pixels)
204
- $ms-list: unquote("MS-LIST:")
205
- @for $i from $start through $finish
206
- $ms-list: append($ms-list, ms($i, $base-size, $ratio, $round-pixels))
207
- @return $ms-list
208
-
209
- @function ms-list($start: 0, $finish: 20, $base-size: $base-size, $ratio: $ratio, $round-pixels: $round-pixels)
210
- @return modular-scale-list($start, $finish, $base-size, $ratio, $round-pixels)
211
-
212
- =modular-scale-list($start: 0, $finish: 20, $base-size: $base-size, $ratio: $ratio, $round-pixels: $round-pixels)
213
- @debug modular-scale-list($start, $finish, $base-size, $ratio, $round-pixels)
214
-
215
- =ms-list($start: 0, $finish: 20, $base-size: $base-size, $ratio: $ratio, $round-pixels: $round-pixels)
216
- @debug modular-scale-list($start, $finish, $base-size, $ratio, $round-pixels)
217
-
218
- =modular-scale-list-output($start: 0, $finish: 20, $base-size: $base-size, $ratio: $ratio, $round-pixels: $round-pixels)
219
- MODULAR-SCALE-LIST
220
- ms-list: modular-scale-list($start, $finish, $base-size, $ratio, $round-pixels)
221
-
222
- =ms-list-output($start: 0, $finish: 20, $base-size: $base-size, $ratio: $ratio, $round-pixels: $round-pixels)
223
- +modular-scale-list-output($start, $finish, $base-size, $ratio, $round-pixels)
224
-
225
- // Other libraries can easily query if this function is avalible
226
- $modular-scale-loaded: true