red 4.1.3 → 4.1.4
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/Manifest.txt +2 -0
- data/lib/red.rb +1 -1
- data/lib/red/nodes/call_nodes.rb +7 -3
- data/lib/source/redshift.rb +1 -0
- data/lib/source/redshift/transform.rb +43 -8
- data/lib/source/redshift/tween.rb +0 -1
- data/lib/source/redspec.rb +1 -0
- metadata +3 -1
data/Manifest.txt
CHANGED
@@ -19,6 +19,8 @@ lib/red/nodes/illegal_nodes.rb
|
|
19
19
|
lib/red/nodes/literal_nodes.rb
|
20
20
|
lib/red/nodes/logic_nodes.rb
|
21
21
|
lib/red/nodes/variable_nodes.rb
|
22
|
+
lib/source/redshift.rb
|
23
|
+
lib/source/redspec.rb
|
22
24
|
lib/source/ruby.rb
|
23
25
|
lib/source/redshift/accessors.rb
|
24
26
|
lib/source/redshift/browser.rb
|
data/lib/red.rb
CHANGED
data/lib/red/nodes/call_nodes.rb
CHANGED
@@ -81,11 +81,15 @@ module Red
|
|
81
81
|
when :require
|
82
82
|
basename = File.basename((arguments_array_sexp.assoc(:array).assoc(:str).last rescue ''))
|
83
83
|
dirname = File.dirname((arguments_array_sexp.assoc(:array).assoc(:str).last rescue ''))
|
84
|
-
|
85
|
-
long_filename = File.join(@@red_filepath, dirname, basename)
|
84
|
+
filename = File.join(@@red_filepath, dirname, basename)
|
86
85
|
unless @@red_required.include?(basename)
|
87
86
|
@@red_required |= [basename]
|
88
|
-
file = Dir.glob(
|
87
|
+
file = Dir.glob('%s.red' % filename)[0] ||
|
88
|
+
Dir.glob('%s.rb' % filename)[0] ||
|
89
|
+
Dir.glob(filename)[0] ||
|
90
|
+
Dir.glob('%s/../../source/%s.red' % [File.dirname(__FILE__),basename])[0] ||
|
91
|
+
Dir.glob('%s/../../source/%s.rb' % [File.dirname(__FILE__),basename])[0]
|
92
|
+
Dir.glob('%s/../../source/%s' % [File.dirname(__FILE__),basename])[0] ||
|
89
93
|
stored_filepath = @@red_filepath
|
90
94
|
@@red_filepath = File.dirname(file)
|
91
95
|
self << hush_warnings { File.read(file).translate_to_sexp_array }.red!
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'redshift/redshift'
|
@@ -14,8 +14,19 @@ class Transform
|
|
14
14
|
:normal => 500,
|
15
15
|
:long => 1000
|
16
16
|
}
|
17
|
+
|
18
|
+
ALGORITHMS = {'linear' => `function(p){return -(Math.cos(Math.PI * p) - 1) / 2;}`}
|
17
19
|
|
18
|
-
|
20
|
+
def self.add_transition(name, func)
|
21
|
+
Transform::ALGORITHMS[name] = func
|
22
|
+
Transform::ALGORITHMS["#{name}:in"] = `function(pos){return func(pos, params);}`
|
23
|
+
Transform::ALGORITHMS["#{name}:out"] = `function(pos){return 1 - func(1 - pos, params);}`
|
24
|
+
Transform::ALGORITHMS["#{name}:in:out"] = `function(pos){return (pos <= 0.5) ? func(2 * pos, params) / 2 : (2 - func(2 * (1 - pos), params)) / 2;}`
|
25
|
+
end
|
26
|
+
|
27
|
+
def transition(transition, *args)
|
28
|
+
`#{ALGORITHMS[transition]}(args)`
|
29
|
+
end
|
19
30
|
# at the end of an interval based transformation clears the Timeout and Intervals
|
20
31
|
# in the browser and returns nil.
|
21
32
|
`$clear = function(timer){clearTimeout(timer);clearInterval(timer);return nil;};`
|
@@ -40,6 +51,7 @@ class Transform
|
|
40
51
|
return this.create({bind: bind, arguments: args, periodical: periodical})();
|
41
52
|
};`
|
42
53
|
|
54
|
+
|
43
55
|
def self.compute(from, to, delta)
|
44
56
|
`(to - from) * delta + from`
|
45
57
|
end
|
@@ -66,6 +78,10 @@ class Transform
|
|
66
78
|
return nil
|
67
79
|
end
|
68
80
|
|
81
|
+
def set_transition
|
82
|
+
`this.__transition__ = #{Transform::ALGORITHMS[(@options[:transition] || 'sine:in:out')]}`
|
83
|
+
end
|
84
|
+
|
69
85
|
def set(now)
|
70
86
|
return now
|
71
87
|
end
|
@@ -89,9 +105,11 @@ class Transform
|
|
89
105
|
`this.__from__ = from`
|
90
106
|
`this.__to__ = to`
|
91
107
|
`this.__time__ = 0`
|
92
|
-
|
93
|
-
|
94
|
-
|
108
|
+
# `this.m$set_transition`
|
109
|
+
`this.__transition__ = function(p){
|
110
|
+
return -(Math.cos(Math.PI * p) - 1) / 2;
|
111
|
+
}`
|
112
|
+
|
95
113
|
self.start_timer
|
96
114
|
self.fire(:start)
|
97
115
|
return self
|
@@ -134,8 +152,25 @@ class Transform
|
|
134
152
|
end
|
135
153
|
|
136
154
|
|
137
|
-
#
|
138
|
-
|
155
|
+
# Built-in algorithms
|
156
|
+
`x = {'pow' : function(p, x){return Math.pow(p, x[0] || 6);},
|
157
|
+
'expo' : function(p){return Math.pow(2, 8 * (p - 1));},
|
158
|
+
'circ' : function(p){return 1 - Math.sin(Math.acos(p));},
|
159
|
+
'sine' : function(p){return 1 - Math.sin((1 - p) * Math.PI / 2);},
|
160
|
+
'back' : function(p, x){x = x[0] || 1.618;return Math.pow(p, 2) * ((x + 1) * p - x);},
|
161
|
+
'bounce' : function(p){ var value; for (var a = 0, b = 1; 1; a += b, b /= 2){ if (p >= (7 - 4 * a) / 11){value = b * b - Math.pow((11 - 6 * a - 11 * p) / 4, 2);break;}}return value;},
|
162
|
+
'elastic' : function(p, x){return Math.pow(2, 10 * --p) * Math.cos(20 * p * Math.PI * (x[0] || 1) / 3);}
|
163
|
+
};
|
164
|
+
for (prop in x) {
|
165
|
+
c$Transform.m$add_transition($q(prop), x.prop)
|
166
|
+
};
|
167
|
+
x = ['quad', 'cubic', 'quart', 'quint'];
|
168
|
+
for (var i = 0, l = x.length; i < l; i ++) {
|
169
|
+
c$Transform.m$add_transition($q(x[i]), function(p){return Math.pow(p, [i + 2]);})
|
170
|
+
};`
|
171
|
+
|
172
|
+
# Module +Parser+ is responsible for turning a css value into a computable value (integer or array of integers),
|
173
|
+
# computing this value to the correct new value in a computation and serving the final value in the correct format
|
139
174
|
module Parser
|
140
175
|
|
141
176
|
# Class Color is responsible for handling css color values in either hex (#fff) or rgb triplet (rgb(0,0,0))
|
@@ -237,8 +272,8 @@ class Transform
|
|
237
272
|
end
|
238
273
|
end
|
239
274
|
|
240
|
-
# Class String is responsible for handling css string values which cannot be parsed.
|
241
|
-
# from a start value to end value with no transform.
|
275
|
+
# Class String is responsible for handling css string values which cannot be parsed. String transforms
|
276
|
+
# from a start value to end value with no transform. This class exists mostly for polymorphic reasons.
|
242
277
|
class String
|
243
278
|
def self.parse(value)
|
244
279
|
false
|
@@ -34,7 +34,6 @@ class Tween < Transform
|
|
34
34
|
value.each do |val|
|
35
35
|
::Transform::Parsers.each do |parser|
|
36
36
|
parsed = parser.parse(val)
|
37
|
-
`console.log(parsed)`
|
38
37
|
found = {:value => parsed, :parser => parser} if (parsed)
|
39
38
|
end
|
40
39
|
found = found || {:value => val, :parser => ::Transform::Parser::String}
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'redspec/lib/red_spec/red_spec'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: red
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.1.
|
4
|
+
version: 4.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jesse Sielaff
|
@@ -87,6 +87,8 @@ files:
|
|
87
87
|
- lib/red/nodes/literal_nodes.rb
|
88
88
|
- lib/red/nodes/logic_nodes.rb
|
89
89
|
- lib/red/nodes/variable_nodes.rb
|
90
|
+
- lib/source/redshift.rb
|
91
|
+
- lib/source/redspec.rb
|
90
92
|
- lib/source/ruby.rb
|
91
93
|
- lib/source/redshift/accessors.rb
|
92
94
|
- lib/source/redshift/browser.rb
|