Module: Compass::Core::SassExtensions::Functions::Math

### Home Classes Methods

### In Files

- lib/compass/core/sass_extensions/functions/math.rb

### Methods

- ::included
- #acos
- #asin
- #atan
- #cos
- #deprecated_random
- #e
- #logarithm
- #pi
- #pow
- #sin
- #sqrt
- #square_root
- #tan

### Class/Module Index

Quicksearch

- Compass
- Compass::BrowserSupport
- Compass::Configuration
- Compass::Configuration::Adapters
- Compass::Configuration::Data
- Compass::Configuration::Defaults
- Compass::Configuration::Inheritance
- Compass::Configuration::Inheritance::ClassMethods
- Compass::Configuration::Inheritance::ClassMethods::ArrayProxy
- Compass::Configuration::Inheritance::InstanceMethods
- Compass::Configuration::Paths
- Compass::Configuration::Watch
- Compass::Core
- Compass::Core::CanIUse
- Compass::Core::SassExtensions
- Compass::Core::SassExtensions::Functions
- Compass::Core::SassExtensions::Functions::Colors
- Compass::Core::SassExtensions::Functions::Configuration
- Compass::Core::SassExtensions::Functions::Constants
- Compass::Core::SassExtensions::Functions::CrossBrowserSupport
- Compass::Core::SassExtensions::Functions::CrossBrowserSupport::CSS2FallbackValue
- Compass::Core::SassExtensions::Functions::Display
- Compass::Core::SassExtensions::Functions::Enumerate
- Compass::Core::SassExtensions::Functions::Env
- Compass::Core::SassExtensions::Functions::Files
- Compass::Core::SassExtensions::Functions::FontFiles
- Compass::Core::SassExtensions::Functions::GradientSupport
- Compass::Core::SassExtensions::Functions::GradientSupport::Assertions
- Compass::Core::SassExtensions::Functions::GradientSupport::CSS3AngleToSVGConverter
- Compass::Core::SassExtensions::Functions::GradientSupport::ColorStop
- Compass::Core::SassExtensions::Functions::GradientSupport::Functions
- Compass::Core::SassExtensions::Functions::GradientSupport::Gradient
- Compass::Core::SassExtensions::Functions::GradientSupport::Gradient::ClassMethods
- Compass::Core::SassExtensions::Functions::GradientSupport::LinearGradient
- Compass::Core::SassExtensions::Functions::GradientSupport::RadialGradient
- Compass::Core::SassExtensions::Functions::ImageSize
- Compass::Core::SassExtensions::Functions::ImageSize::ImageProperties
- Compass::Core::SassExtensions::Functions::ImageSize::JPEG
- Compass::Core::SassExtensions::Functions::InlineImage
- Compass::Core::SassExtensions::Functions::Lists
- Compass::Core::SassExtensions::Functions::Math
- Compass::Core::SassExtensions::Functions::SassDeclarationHelper
- Compass::Core::SassExtensions::Functions::Selectors
- Compass::Core::SassExtensions::Functions::Urls
- Compass::Core::SassExtensions::Functions::Urls::FontUrl
- Compass::Core::SassExtensions::Functions::Urls::GeneratedImageUrl
- Compass::Core::SassExtensions::Functions::Urls::ImageUrl
- Compass::Core::SassExtensions::Functions::Urls::StylesheetUrl
- Compass::Error
- Compass::Frameworks
- Compass::Frameworks::Framework
- Compass::HasDeprecatedConstantsFromCore
- Compass::SassExtensions
- Compass::SassExtensions::Functions
- Compass::Util
- Sass
- Sass::Script
- Sass::Script::CrossBrowserFunctionCall
- Sass::Script::Funcall
- Sass::Script::Functions
- Sass::Script::Functions::EvaluationContext
- Sass::Script::HasSimpleCrossBrowserFunctionSupport
- Sass::Script::List
- Sass::Script::Value
- Sass::Script::Value::ArgList
- Sass::Script::Value::Base
- Sass::Script::Value::List
- Sass::Script::Value::Map
- Sass::Tree
- Sass::Tree::Node

No matching classes.

# Compass::Core::SassExtensions::Functions::Math

### Constants

E
PI

### Public Class Methods

included(base) click to toggle source

    # File lib/compass/core/sass_extensions/functions/math.rb, line 5
    def self.included(base)
      if base == Sass::Script::Functions
        base.send :alias_method, :sass_random, :random
        base.send :alias_method, :random, :deprecated_random
      end
    end

### Public Instance Methods

acos(number) click to toggle source

    # File lib/compass/core/sass_extensions/functions/math.rb, line 50
    def acos(number)
      trig(:acos, number)
    end

asin(number) click to toggle source

    # File lib/compass/core/sass_extensions/functions/math.rb, line 40
    def asin(number)
      trig(:asin, number)
    end

atan(number) click to toggle source

    # File lib/compass/core/sass_extensions/functions/math.rb, line 60
    def atan(number)
      trig(:atan, number)
    end

cos(number) click to toggle source

    # File lib/compass/core/sass_extensions/functions/math.rb, line 45
    def cos(number)
      trig(:cos, number)
    end

deprecated_random(*args) click to toggle source

    # File lib/compass/core/sass_extensions/functions/math.rb, line 20
    def deprecated_random(*args)
      if args.length == 2
        Compass::Util.compass_warn WARNING: The $start value for random(#{args.first}, #{args.last}) is not supported by Sass and is now  deprecated in Compass and will be removed in a future release.  Use `#{args.first} + random(#{args.last.minus(args.first)})` instead.
        range = (args.first.value..args.last.value).to_a
        number(range[rand(range.length)])
      else
        sass_random(*args)
      end
    end

e() click to toggle source

    # File lib/compass/core/sass_extensions/functions/math.rb, line 65
    def e
      E
    end

logarithm(number, base = e ) click to toggle source

    # File lib/compass/core/sass_extensions/functions/math.rb, line 70
    def logarithm(number, base = e )
      assert_type number, :Number
      assert_type base, :Number
      raise Sass::SyntaxError, "base to logarithm must be unitless." unless base.unitless?

      result = Math.log(number.value, base.value) rescue Math.log(number.value) / Math.log(base.value)
      number(result, number.unit_str)
    end

pi() click to toggle source

    # File lib/compass/core/sass_extensions/functions/math.rb, line 15
    def pi()
      PI
    end

pow(number, exponent) click to toggle source

    # File lib/compass/core/sass_extensions/functions/math.rb, line 89
    def pow(number, exponent)
      assert_type number, :Number
      assert_type exponent, :Number
      raise Sass::SyntaxError, "exponent to pow must be unitless." unless exponent.unitless?
      number(number.value**exponent.value, number.unit_str)
    end

sin(number) click to toggle source

    # File lib/compass/core/sass_extensions/functions/math.rb, line 35
    def sin(number)
      trig(:sin, number)
    end

sqrt(number) click to toggle source

    # File lib/compass/core/sass_extensions/functions/math.rb, line 81
    def sqrt(number)
      numeric_transformation(number) { |n| Math.sqrt(n) }
    end

Also aliased as: square_root
square_root(number) click to toggle source
Alias for: sqrt
tan(number) click to toggle source

    # File lib/compass/core/sass_extensions/functions/math.rb, line 55
    def tan(number)
      trig(:tan, number)
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.