# at-import/Sassy-math

merge into compass plugin

1 parent 97185f4 commit 0cf6b295167844b6b56b6955f3261bb00045674c scottkellum committed Jan 13, 2013
Showing with 15 additions and 31 deletions.
1. +2 −2 compass/lib/sassy-math.rb
2. +5 −23 config.rb
3. +1 −1 css/math.css
4. +5 −5 css/math2.css
5. +2 −0 sass/math.scss
4 compass/lib/sassy-math.rb
 @@ -48,8 +48,8 @@ def factorial(number) end Sass::Script::Number.new(result) end - def rand - Sass::Script::Number.new(4) + def random(max = Sass::Script::Number.new(100)) ## shamelessly taken from here: https://gist.github.com/1561650 + Sass::Script::Number.new(rand(max.value), max.numerator_units, max.denominator_units) end def hypot(a, b) a = a.value.to_f
28 config.rb
 @@ -26,23 +26,8 @@ # Sass Script Proving Grounds +# Sassy math Functions module Sass::Script::Functions - # Fractions - def numerator(number) - Sass::Script::Number.new(number.value.fraction.first) - end - def denominator(number) - num, den = number.value.fraction - Sass::Script::Number.new(den) - end - def to_fraction(number) - result = numerator(number).to_s + '/' + denominator(number).to_s - Sass::Script::String.new(result) - end - def to_decimal(fraction) - fraction = fraction.value.to_f - Sass::Script::Number.new(fraction) - end # Exponents def exponent(base, powerNum, powerDen) base = base.value.to_f @@ -88,8 +73,8 @@ def factorial(number) end Sass::Script::Number.new(result) end - def rand - Sass::Script::Number.new(4) + def random(max = Sass::Script::Number.new(100)) ## shamelessly taken from here: https://gist.github.com/1561650 + Sass::Script::Number.new(rand(max.value), max.numerator_units, max.denominator_units) end def hypot(a, b) a = a.value.to_f @@ -106,9 +91,6 @@ def e e = Math::E Sass::Script::Number.new(e) end - def random(max = Sass::Script::Number.new(100)) ## shamelessly taken from here: https://gist.github.com/1561650 - Sass::Script::Number.new(rand(max.value), max.numerator_units, max.denominator_units) - end def golden_ratio() result = (1.0 / 2.0) + (Math.sqrt(5) / 2.0) Sass::Script::Number.new(result) @@ -154,7 +136,7 @@ def acos(rad) def acosh(rad) rad = rad.value.to_f result = Math.acosh(rad) - Sass::Script::Number.new(reult) + Sass::Script::Number.new(result) end def sinh(rad) rad = rad.value.to_f @@ -192,4 +174,4 @@ def atanh(rad) result = Math.atanh(rad) Sass::Script::Number.new(result) end -end +end
2 css/math.css
 @@ -1,5 +1,5 @@ @charset "UTF-8"; -/* line 330, ../sass/math.scss */ +/* line 332, ../sass/math.scss */ .foo { width: 1.61803; }
10 css/math2.css
 @@ -1,11 +1,11 @@ /* line 36, ../sass/math2.scss */ #tester { - numerator: 5; - denominator: 2; - to-fraction: 5/2; - to-decimal: 1.5; + numerator: numerator(2.5); + denominator: denominator(2.5); + to-fraction: to-fraction(2.5); + to-decimal: to-decimal(3/2); exponent: 4.0; - power: 12226.616; + power: 12226.61611; sqrt: 127; nth-root: 3; factorial: 362880;
2 sass/math.scss
 @@ -11,6 +11,8 @@ \$e: 2.71828182845904523536028747135266249775724709369995; \$iter: 50; +@debug random(); + ////////////////////////////// // Random Number // Working from http://xkcd.com/221/