sassy-math 1.0 → 1.1
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.
- data/lib/sassy-math.rb +80 -15
- data/sassy-math.gemspec +3 -3
- metadata +4 -4
data/lib/sassy-math.rb
CHANGED
@@ -4,8 +4,7 @@ Compass::Frameworks.register("sassy-math", :path => "#{File.dirname(__FILE__)}/.
|
|
4
4
|
|
5
5
|
# Sassy math Functions
|
6
6
|
module Sass::Script::Functions
|
7
|
-
#
|
8
|
-
# Fraction Functions
|
7
|
+
# Fractions
|
9
8
|
def numerator(number)
|
10
9
|
Sass::Script::Number.new(number.value.fraction.first)
|
11
10
|
end
|
@@ -21,7 +20,7 @@ module Sass::Script::Functions
|
|
21
20
|
fraction = fraction.value.to_f
|
22
21
|
Sass::Script::Number.new(fraction)
|
23
22
|
end
|
24
|
-
#
|
23
|
+
# Exponents
|
25
24
|
def exponent(base, powerNum, powerDen)
|
26
25
|
base = base.value.to_f
|
27
26
|
powerNum = powerNum.value.to_f
|
@@ -46,7 +45,16 @@ module Sass::Script::Functions
|
|
46
45
|
result = number ** (1.0 / root)
|
47
46
|
Sass::Script::Number.new(result)
|
48
47
|
end
|
49
|
-
#
|
48
|
+
# Logarithms
|
49
|
+
def ln(num)
|
50
|
+
result = Math.log(num.value)
|
51
|
+
Sass::Script::Number.new(result)
|
52
|
+
end
|
53
|
+
def log10(num)
|
54
|
+
result = Math.log10(num.value)
|
55
|
+
Sass::Script::Number.new(result)
|
56
|
+
end
|
57
|
+
# Miscellaneous
|
50
58
|
def factorial(number)
|
51
59
|
result = 1
|
52
60
|
number = number.value
|
@@ -57,13 +65,13 @@ module Sass::Script::Functions
|
|
57
65
|
end
|
58
66
|
Sass::Script::Number.new(result)
|
59
67
|
end
|
60
|
-
|
61
|
-
|
62
|
-
result = Math.log(num.value)
|
63
|
-
Sass::Script::Number.new(result)
|
68
|
+
def rand
|
69
|
+
Sass::Script::Number.new(4)
|
64
70
|
end
|
65
|
-
def
|
66
|
-
|
71
|
+
def hypot(a, b)
|
72
|
+
a = a.value.to_f
|
73
|
+
b = b.value.to_f
|
74
|
+
result = Math.hypot(a, b)
|
67
75
|
Sass::Script::Number.new(result)
|
68
76
|
end
|
69
77
|
# Constants
|
@@ -75,9 +83,6 @@ module Sass::Script::Functions
|
|
75
83
|
e = Math::E
|
76
84
|
Sass::Script::Number.new(e)
|
77
85
|
end
|
78
|
-
def rand
|
79
|
-
Sass::Script::Number.new(4)
|
80
|
-
end
|
81
86
|
def golden_ratio()
|
82
87
|
result = (1.0 / 2.0) + (Math.sqrt(5) / 2.0)
|
83
88
|
Sass::Script::Number.new(result)
|
@@ -101,11 +106,71 @@ module Sass::Script::Functions
|
|
101
106
|
end
|
102
107
|
Sass::Script::Bool.new(result)
|
103
108
|
end
|
109
|
+
# Trigonometric Functions
|
110
|
+
def deg_to_rad(degree)
|
111
|
+
result = degree.value.to_f * Math::PI / 180
|
112
|
+
Sass::Script::Number.new(result)
|
113
|
+
end
|
114
|
+
def rad_to_deg(rad)
|
115
|
+
result = rad.value.to_f * 180 / Math::PI
|
116
|
+
Sass::Script::Number.new(result)
|
117
|
+
end
|
118
|
+
def cosh(rad)
|
119
|
+
rad = rad.value.to_f
|
120
|
+
result = Math.cosh(rad)
|
121
|
+
Sass::Script::Number.new(result)
|
122
|
+
end
|
123
|
+
def acos(rad)
|
124
|
+
rad = rad.value.to_f
|
125
|
+
result = Math.acos(rad)
|
126
|
+
Sass::Script::Number.new(result)
|
127
|
+
end
|
128
|
+
def acosh(rad)
|
129
|
+
rad = rad.value.to_f
|
130
|
+
result = Math.acosh(rad)
|
131
|
+
Sass::Script::Number.new(result)
|
132
|
+
end
|
133
|
+
def sinh(rad)
|
134
|
+
rad = rad.value.to_f
|
135
|
+
result = Math.sinh(rad)
|
136
|
+
Sass::Script::Number.new(result)
|
137
|
+
end
|
138
|
+
def asin(rad)
|
139
|
+
rad = rad.value.to_f
|
140
|
+
result = Math.asin(rad)
|
141
|
+
Sass::Script::Number.new(result)
|
142
|
+
end
|
143
|
+
def asinh(rad)
|
144
|
+
rad = rad.value.to_f
|
145
|
+
result = Math.asinh(rad)
|
146
|
+
Sass::Script::Number.new(result)
|
147
|
+
end
|
148
|
+
def tanh(rad)
|
149
|
+
rad = rad.value.to_f
|
150
|
+
result = Math.tanh(rad)
|
151
|
+
Sass::Script::Number.new(result)
|
152
|
+
end
|
153
|
+
def atan(rad)
|
154
|
+
rad = rad.value.to_f
|
155
|
+
result = Math.atan(rad)
|
156
|
+
Sass::Script::Number.new(result)
|
157
|
+
end
|
158
|
+
def atan2(y, x)
|
159
|
+
y = y.value.to_f
|
160
|
+
x = x.value.to_f
|
161
|
+
result = Math.atan2(y, x)
|
162
|
+
Sass::Script::Number.new(result)
|
163
|
+
end
|
164
|
+
def atanh(rad)
|
165
|
+
rad = rad.value.to_f
|
166
|
+
result = Math.atanh(rad)
|
167
|
+
Sass::Script::Number.new(result)
|
168
|
+
end
|
104
169
|
end
|
105
170
|
|
106
171
|
module SassyMath
|
107
172
|
|
108
|
-
VERSION = "1.
|
109
|
-
DATE = "2012-06-
|
173
|
+
VERSION = "1.1"
|
174
|
+
DATE = "2012-06-17"
|
110
175
|
|
111
176
|
end
|
data/sassy-math.gemspec
CHANGED
@@ -2,13 +2,13 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{sassy-math}
|
5
|
-
s.version = "1.
|
5
|
+
s.version = "1.1"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.3.5")
|
8
8
|
s.authors = ["Sam Richard", "Mario Valencia", "Scott Kellum"]
|
9
|
-
s.date = %q{2012-06-
|
9
|
+
s.date = %q{2012-06-17}
|
10
10
|
s.description = %q{Use advanced mathematical functions in Compass.}
|
11
|
-
s.email = %w{
|
11
|
+
s.email = %w{snugug@gmail.com}
|
12
12
|
s.has_rdoc = false
|
13
13
|
s.files = [
|
14
14
|
"sassy-math.gemspec",
|
metadata
CHANGED
@@ -4,8 +4,8 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 1
|
7
|
-
-
|
8
|
-
version: "1.
|
7
|
+
- 1
|
8
|
+
version: "1.1"
|
9
9
|
platform: ruby
|
10
10
|
authors:
|
11
11
|
- Sam Richard
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-06-
|
18
|
+
date: 2012-06-17 00:00:00 -04:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -47,7 +47,7 @@ dependencies:
|
|
47
47
|
version_requirements: *id002
|
48
48
|
description: Use advanced mathematical functions in Compass.
|
49
49
|
email:
|
50
|
-
-
|
50
|
+
- snugug@gmail.com
|
51
51
|
executables: []
|
52
52
|
|
53
53
|
extensions: []
|