modular-scale 2.0.0.alpha3 → 2.0.0.alpha4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6a777d36ccbd68153d19bf54d896e50889f671e9
4
- data.tar.gz: 6c75b152c6a6fe8c770e280c7209084ba0718316
3
+ metadata.gz: 04987e47c5704452df1374e46931ca1c58930915
4
+ data.tar.gz: 35fdeb87e81ed54c5e5a479d5f91440e5c8aa639
5
5
  SHA512:
6
- metadata.gz: b448db85d605b2182d0318cd30b420f7e7513018c610389952d772f307421190b99df346822e16af90dd87b619340e998b2d7206c6691b81cd1b4491019ebce0
7
- data.tar.gz: f8b9aa2177c557a13715be8554c152b0bd8efb5acb45c183722267485626f49bd4de0edac7db48acaf5296ec55a77d2523c52f6ca0b574dfeb64a8560ae5d379
6
+ metadata.gz: 9eb5e247d681d58eae471c5ef8e7acafd6c6ff00f24eba7ea0e13e841f7a34eb0e1ec4fecc050b1cde87276d930af41d9c64046de1e519e47cdcbea631f92369
7
+ data.tar.gz: 147c7dcb79a02546103c5411ccb60c9d6e6f1bad6d6ba19dfff51716fc2e634842cd94d082e41f735906dc0792f09bac490c8a97da4e5e901a6ca821d24d09fd
@@ -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.alpha3"
19
+ VERSION = "2.0.0.alpha4"
20
20
  DATE = "2013-12-20"
21
21
  end
22
22
 
@@ -24,6 +24,98 @@ end
24
24
  # available on require of your extension without the need for users to import
25
25
  # any partials. Uncomment below.
26
26
 
27
- # module Sass::Script::Functions
28
- #
29
- # end
27
+ module Sass::Script::Functions
28
+
29
+ # Let MS know that extra functionality is avalible
30
+ def ms_gem_installed()
31
+ Sass::Script::Bool.new(true)
32
+ end
33
+
34
+ def ms_gem_func(value, bases, ratios)
35
+
36
+ # Convert to native ruby things
37
+ rvalue = value.value.to_i
38
+
39
+ if bases.class == Sass::Script::Number
40
+ bases = [] << bases
41
+ else
42
+ bases = bases.value.to_a
43
+ end
44
+ if ratios.class == Sass::Script::Number
45
+ ratios = [] << ratios
46
+ else
47
+ ratios = ratios.value.to_a
48
+ end
49
+
50
+ # Convert items in arrays to floating point numbers
51
+ rbases = []
52
+ rratios = []
53
+ bases.each do |num|
54
+ rbases << num.value.to_f
55
+ end
56
+ ratios.each do |num|
57
+ rratios << num.value.to_f
58
+ end
59
+
60
+
61
+ # Blank array for return
62
+ r = [rbases[0]]
63
+
64
+ # loop through all possibilities
65
+ # NOTE THIS IS NOT FULLY FUNCTIONAL YET
66
+ # ONLY LOOPS THROUGH SOME/MOST OF THE POSSIBILITES
67
+
68
+ rbases.each do |base|
69
+ rratios.each do |ratio|
70
+
71
+ # Find values on a positive scale
72
+ if rvalue > 0
73
+ # Find lower values on the scale
74
+ i = -1;
75
+ while ((ratio ** i) * base) >= (rbases[0])
76
+ r << (ratio ** i) * base
77
+ i = i - 1;
78
+ end
79
+
80
+ # Find higher possible values on the scale
81
+ i = 1;
82
+ while ((ratio ** i) * base) <= ((ratio ** rvalue) * base)
83
+ r << (ratio ** i) * base
84
+ i = i + 1;
85
+ end
86
+
87
+ else
88
+
89
+ # Find lower values on the scale
90
+ i = 1;
91
+ while ((ratio ** i) * base) <= (rbases[0])
92
+ r << (ratio ** i) * base
93
+ i = i + 1;
94
+ end
95
+
96
+ # Find higher possible values on the scale
97
+ i = -1;
98
+ while ((ratio ** i) * base) >= ((ratio ** rvalue) * base)
99
+ r << (ratio ** i) * base
100
+ i = i - 1;
101
+ end
102
+ end
103
+
104
+ end
105
+ end
106
+
107
+ # Sort and trim
108
+ r.sort!
109
+ r.uniq!
110
+
111
+ if rvalue < 0
112
+ r = r.keep_if { |a| a <= rbases[0] }
113
+ r.reverse!
114
+ end
115
+
116
+ # Final value
117
+ r = r[rvalue]
118
+
119
+ Sass::Script::Number.new(r)
120
+ end
121
+ end
@@ -7,6 +7,21 @@
7
7
  @return ms-calc($Value, $Bases, $Ratios);
8
8
  }
9
9
 
10
+ // Do calculations directly in Ruby when avalible
11
+ @if $MS-gem-exists {
12
+
13
+ // Remove units from bases
14
+ $Unit: nth($Bases, 1) * 0 + 1;
15
+ $Unitless-Bases: ();
16
+ @each $Base in $Bases {
17
+ $Base: $Base/$Unit;
18
+ $Unitless-Bases: join($Unitless-Bases, $Base);
19
+ }
20
+
21
+ // Calculate natively in Ruby
22
+ @return ms-gem-func($Value, $Unitless-Bases, $Ratios) * $Unit;
23
+ }
24
+
10
25
  // Generate a list of all possible values
11
26
  $Return: ms-generate-list($Value, $Bases, $Ratios);
12
27
 
@@ -2,7 +2,6 @@
2
2
 
3
3
 
4
4
  // Test if the pow() function exists
5
-
6
5
  @function ms-pow-exists() {
7
6
  @if pow(4, 2) == 16 {
8
7
  @return true;
@@ -10,4 +9,14 @@
10
9
  @return false;
11
10
  }
12
11
 
13
- $MS-pow-exists: ms-pow-exists();
12
+ $MS-pow-exists: ms-pow-exists();
13
+
14
+ // Test if MS was installed via the gem
15
+ @function ms-gem-exists() {
16
+ @if ms-gem-installed() == true {
17
+ @return true;
18
+ }
19
+ @return false;
20
+ }
21
+
22
+ $MS-gem-exists: ms-gem-exists();
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.alpha3
4
+ version: 2.0.0.alpha4
5
5
  platform: ruby
6
6
  authors:
7
7
  - First Last
@@ -42,6 +42,7 @@ files:
42
42
  - stylesheets/modular-scale/_ratios.scss
43
43
  - stylesheets/modular-scale/_sort-list.scss
44
44
  - stylesheets/modular-scale/_tests.scss
45
+ - stylesheets/modular-scale.zip
45
46
  homepage: http://extension.com
46
47
  licenses:
47
48
  - MIT