michaelforrest-tidy 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) hide show
  1. data/Manifest +87 -0
  2. data/README +5 -0
  3. data/Rakefile +14 -0
  4. data/bin/tidyproject +33 -0
  5. data/lib/aslibs/as3/lbi/com/lbi/animation/animator/Animator.as +86 -0
  6. data/lib/aslibs/as3/lbi/com/lbi/animation/animator/Transition.as +142 -0
  7. data/lib/aslibs/as3/lbi/com/lbi/animation/group/Parallel.as +28 -0
  8. data/lib/aslibs/as3/lbi/com/lbi/animation/group/Queue.as +93 -0
  9. data/lib/aslibs/as3/lbi/com/lbi/animation/group/Sequence.as +28 -0
  10. data/lib/aslibs/as3/lbi/com/lbi/animation/group/Set.as +82 -0
  11. data/lib/aslibs/as3/lbi/com/lbi/animation/group/Stack.as +30 -0
  12. data/lib/aslibs/as3/lbi/com/lbi/animation/single/Animation.as +173 -0
  13. data/lib/aslibs/as3/lbi/com/lbi/animation/single/Message.as +36 -0
  14. data/lib/aslibs/as3/lbi/com/lbi/animation/single/MethodWithCompleteEvent.as +75 -0
  15. data/lib/aslibs/as3/lbi/com/lbi/animation/single/OrphanEvent.as +78 -0
  16. data/lib/aslibs/as3/lbi/com/lbi/animation/single/Pause.as +35 -0
  17. data/lib/aslibs/as3/lbi/com/lbi/animation/single/Tween.as +73 -0
  18. data/lib/aslibs/as3/lbi/com/lbi/animation/util/Easing.as +158 -0
  19. data/lib/aslibs/as3/lbi/com/lbi/animation/util/Engine.as +35 -0
  20. data/lib/aslibs/as3/lbi/com/lbi/animation/util/GroupCommon.as +62 -0
  21. data/lib/aslibs/as3/lbi/com/lbi/animation/util/IAnimation.as +30 -0
  22. data/lib/aslibs/as3/lbi/com/lbi/debug/DraggyClip.as +96 -0
  23. data/lib/aslibs/as3/lbi/com/lbi/debug/FPSView.as +48 -0
  24. data/lib/aslibs/as3/lbi/com/lbi/debug/KeySequenceTrigger.as +60 -0
  25. data/lib/aslibs/as3/lbi/com/lbi/debug/Log.as +168 -0
  26. data/lib/aslibs/as3/lbi/com/lbi/debug/LogItemType.as +23 -0
  27. data/lib/aslibs/as3/lbi/com/lbi/debug/LogType.as +31 -0
  28. data/lib/aslibs/as3/lbi/com/lbi/debug/ViewAnalysis.as +24 -0
  29. data/lib/aslibs/as3/lbi/com/lbi/media/IBufferable.as +16 -0
  30. data/lib/aslibs/as3/lbi/com/lbi/media/ITransportControllable.as +11 -0
  31. data/lib/aslibs/as3/lbi/com/lbi/mvc/collection/Collection.as +296 -0
  32. data/lib/aslibs/as3/lbi/com/lbi/mvc/collection/ISearchable.as +10 -0
  33. data/lib/aslibs/as3/lbi/com/lbi/mvc/collection/ISelectable.as +10 -0
  34. data/lib/aslibs/as3/lbi/com/lbi/mvc/collection/Matchable.as +9 -0
  35. data/lib/aslibs/as3/lbi/com/lbi/mvc/collection/Searchable.as +56 -0
  36. data/lib/aslibs/as3/lbi/com/lbi/mvc/collection/Selectable.as +49 -0
  37. data/lib/aslibs/as3/lbi/com/lbi/mvc/helper/Cloner.as +15 -0
  38. data/lib/aslibs/as3/lbi/com/lbi/mvc/helper/TypographyBase.as +194 -0
  39. data/lib/aslibs/as3/lbi/com/lbi/mvc/helper/preloading/LoadProgressEvent.as +18 -0
  40. data/lib/aslibs/as3/lbi/com/lbi/mvc/model/Application.as +45 -0
  41. data/lib/aslibs/as3/lbi/com/lbi/mvc/model/ConcurrentDependencyLoader.as +27 -0
  42. data/lib/aslibs/as3/lbi/com/lbi/mvc/model/EventMapper.as +85 -0
  43. data/lib/aslibs/as3/lbi/com/lbi/mvc/model/Hyperlink.as +36 -0
  44. data/lib/aslibs/as3/lbi/com/lbi/mvc/model/IEventMapper.as +10 -0
  45. data/lib/aslibs/as3/lbi/com/lbi/mvc/model/Merge.as +14 -0
  46. data/lib/aslibs/as3/lbi/com/lbi/mvc/model/SequentialDependencyLoader.as +43 -0
  47. data/lib/aslibs/as3/lbi/com/lbi/mvc/model/StringFormatting.as +142 -0
  48. data/lib/aslibs/as3/lbi/com/lbi/mvc/model/XMLListLoader.as +98 -0
  49. data/lib/aslibs/as3/lbi/com/lbi/mvc/model/XMLListLoaderDispatcher.as +52 -0
  50. data/lib/aslibs/as3/lbi/com/lbi/mvc/view/ViewBase.as +323 -0
  51. data/lib/aslibs/as3/lbi/com/quasimondo/geom/ColorMatrix.as +682 -0
  52. data/lib/script/as2/lib/as2_class.rb +37 -0
  53. data/lib/script/as2/lib/test/SampleClass.as +34 -0
  54. data/lib/script/as2/lib/test/as2_class_test.rb +15 -0
  55. data/lib/script/as2/navigation/bin/xml/__model.xml +7 -0
  56. data/lib/script/as2/navigation/navigation.rb +44 -0
  57. data/lib/script/as2/navigation/src/app/models/App.as +14 -0
  58. data/lib/script/as2/navigation/src/app/models/__Model.as +42 -0
  59. data/lib/script/as2/navigation/src/app/views/__model/__ModelView.as +61 -0
  60. data/lib/script/as2/navigation/src/app/views/__model/__ModelsView.as +33 -0
  61. data/lib/script/as2/project/project.rb +7 -0
  62. data/lib/script/as2/project/src/app/helpers/Colours.as +1 -0
  63. data/lib/script/as2/project/src/app/helpers/Typography.as +1 -0
  64. data/lib/script/as2/project/src/app/models/App.as +22 -0
  65. data/lib/script/as2/project/src/app/models/FlashVars.as +1 -0
  66. data/lib/script/as2/project/src/app/models/Linkages.as +8 -0
  67. data/lib/script/as2/project/src/app/views/AppView.as +21 -0
  68. data/lib/script/as3/project/project.rb +10 -0
  69. data/lib/script/as3/project/src/app/helpers/Colours.as +1 -0
  70. data/lib/script/as3/project/src/app/helpers/Typography.as +1 -0
  71. data/lib/script/as3/project/src/app/models/App.as +21 -0
  72. data/lib/script/as3/project/src/app/models/FlashVars.as +1 -0
  73. data/lib/script/as3/project/src/app/views/AppView.as +27 -0
  74. data/lib/script/as3/scaffold/bin/xml/__model.xml +0 -0
  75. data/lib/script/as3/scaffold/scaffold.rb +41 -0
  76. data/lib/script/as3/scaffold/src/models/__Model.as +11 -0
  77. data/lib/script/as3/scaffold/src/views/__model/__ModelDetailView.as +0 -0
  78. data/lib/script/as3/scaffold/src/views/__model/__ModelListItemView.as +0 -0
  79. data/lib/script/as3/scaffold/src/views/__model/__ModelListView.as +0 -0
  80. data/lib/script/bwlimit.rb +305 -0
  81. data/lib/script/generate +117 -0
  82. data/lib/script/server +4 -0
  83. data/lib/script/server.rb +20 -0
  84. data/lib/tidy_project.rb +19 -0
  85. data/tasks/build.rake +4 -0
  86. data/tasks/release.rake +8 -0
  87. data/test/test_tidy_project.rb +22 -0
  88. data/tidy.gemspec +33 -0
  89. metadata +229 -0
@@ -0,0 +1,682 @@
1
+ // ColorMatrix Class v2.1
2
+ //
3
+ // released under MIT License (X11)
4
+ // http://www.opensource.org/licenses/mit-license.php
5
+ //
6
+ // Author: Mario Klingemann
7
+ // http://www.quasimondo.com
8
+
9
+ /*
10
+ Copyright (c) 2008 Mario Klingemann
11
+
12
+ Permission is hereby granted, free of charge, to any person obtaining a copy
13
+ of this software and associated documentation files (the "Software"), to deal
14
+ in the Software without restriction, including without limitation the rights
15
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16
+ copies of the Software, and to permit persons to whom the Software is
17
+ furnished to do so, subject to the following conditions:
18
+
19
+ The above copyright notice and this permission notice shall be included in
20
+ all copies or substantial portions of the Software.
21
+
22
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
28
+ THE SOFTWARE.
29
+ */
30
+
31
+ // Changes in v1.1:
32
+ // Changed the RGB to luminance constants
33
+ // Added colorize() method
34
+
35
+ // Changes in v1.2:
36
+ // Added clone()
37
+ // Added randomize()
38
+ // Added blend()
39
+ // Added "filter" property
40
+
41
+ // Changes in v1.3:
42
+ // Added invertAlpha()
43
+ // Added thresholdAlpha()
44
+
45
+ // Changes in v1.4:
46
+ // Added luminance2Alpha()
47
+
48
+ //Changes in v1.5
49
+ // Added rotateX();
50
+ // Added rotateY();
51
+ // Added rotateZ();
52
+ // Added shearZ();
53
+
54
+ //changes in v2.0
55
+ // AS3 optimizations
56
+ // Added setMultiplicators()
57
+ // Added clearChannels()
58
+ // Added rotateHue()
59
+ // Added transformVector()
60
+ // Added applyMatrix()
61
+ // Added rotateRed()
62
+ // Added rotateGreen()
63
+ // Added rotateBlue()
64
+ // Added shearRed()
65
+ // Added shearGreen()
66
+ // Added shearBlue()
67
+
68
+ //changes in v2.1
69
+ // Added applyColorDeficiency()
70
+
71
+ package com.quasimondo.geom {
72
+
73
+ import flash.filters.ColorMatrixFilter;
74
+
75
+ public class ColorMatrix {
76
+
77
+ public static const COLOR_DEFICIENCY_TYPES:Array = [
78
+ 'Protanopia',
79
+ 'Protanomaly',
80
+ 'Deuteranopia',
81
+ 'Deuteranomaly',
82
+ 'Tritanopia',
83
+ 'Tritanomaly',
84
+ 'Achromatopsia',
85
+ 'Achromatomaly' ];
86
+
87
+ // RGB to Luminance conversion constants as found on
88
+ // Charles A. Poynton's colorspace-faq:
89
+ // http://www.faqs.org/faqs/graphics/colorspace-faq/
90
+
91
+ private static const LUMA_R:Number = 0.212671;
92
+ private static const LUMA_G:Number = 0.71516;
93
+ private static const LUMA_B:Number = 0.072169;
94
+
95
+
96
+ // There seem different standards for converting RGB
97
+ // values to Luminance. This is the one by Paul Haeberli:
98
+
99
+ private static const LUMA_R2:Number = 0.3086;
100
+ private static const LUMA_G2:Number = 0.6094;
101
+ private static const LUMA_B2:Number = 0.0820;
102
+
103
+
104
+
105
+ private static const ONETHIRD:Number = 1 / 3;
106
+
107
+ private static const IDENTITY:Array = [1,0,0,0,0,
108
+ 0,1,0,0,0,
109
+ 0,0,1,0,0,
110
+ 0,0,0,1,0];
111
+
112
+
113
+ private static const RAD:Number = Math.PI / 180;
114
+
115
+ public var matrix:Array;
116
+
117
+ private var preHue:ColorMatrix;
118
+ private var postHue:ColorMatrix;
119
+ private var hueInitialized:Boolean;
120
+
121
+ /*
122
+ Function: ColorMatrix
123
+
124
+ Constructor
125
+
126
+ Parameters:
127
+
128
+ mat - if omitted matrix gets initialized with an
129
+ identity matrix. Alternatively it can be
130
+ initialized with another ColorMatrix or
131
+ an array (there is currently no check
132
+ if the array is valid. A correct array
133
+ contains 20 elements.)
134
+
135
+
136
+ */
137
+
138
+ public function ColorMatrix ( mat:Object = null )
139
+ {
140
+
141
+ if (mat is ColorMatrix )
142
+ {
143
+ matrix = mat.matrix.concat();
144
+ } else if (mat is Array )
145
+ {
146
+ matrix = mat.concat();
147
+ } else
148
+ {
149
+ reset();
150
+ }
151
+
152
+ }
153
+
154
+ /*
155
+ Function: reset
156
+
157
+ resets the matrix to the neutral identity matrix. Applying this
158
+ matrix to an image will not make any changes to it.
159
+
160
+ Parameters:
161
+
162
+ none
163
+
164
+ Returns:
165
+
166
+ nothing
167
+ */
168
+
169
+ public function reset():void
170
+ {
171
+ matrix = IDENTITY.concat();
172
+ }
173
+
174
+
175
+ public function clone():ColorMatrix
176
+ {
177
+ return new ColorMatrix( matrix );
178
+ }
179
+
180
+ public function invert():void
181
+ {
182
+ concat([ -1 , 0, 0, 0, 255,
183
+ 0 , -1, 0, 0, 255,
184
+ 0 , 0, -1, 0, 255,
185
+ 0, 0, 0, 1, 0]);
186
+ }
187
+
188
+ /*
189
+ Function: adjustSaturation
190
+
191
+ changes the saturation
192
+
193
+ Parameters:
194
+
195
+ s - typical values come in the range 0.0 ... 2.0 where
196
+ 0.0 means 0% Saturation
197
+ 0.5 means 50% Saturation
198
+ 1.0 is 100% Saturation (aka no change)
199
+ 2.0 is 200% Saturation
200
+
201
+ Other values outside of this range are possible
202
+ -1.0 will invert the hue but keep the luminance
203
+
204
+
205
+ Returns:
206
+
207
+ nothing
208
+
209
+
210
+ */
211
+
212
+ public function adjustSaturation( s:Number ):void{
213
+
214
+ var sInv:Number;
215
+ var irlum:Number;
216
+ var iglum:Number;
217
+ var iblum:Number;
218
+
219
+ sInv = (1 - s);
220
+ irlum = (sInv * LUMA_R);
221
+ iglum = (sInv * LUMA_G);
222
+ iblum = (sInv * LUMA_B);
223
+
224
+ concat([(irlum + s), iglum, iblum, 0, 0,
225
+ irlum, (iglum + s), iblum, 0, 0,
226
+ irlum, iglum, (iblum + s), 0, 0,
227
+ 0, 0, 0, 1, 0]);
228
+
229
+ }
230
+
231
+
232
+ /*
233
+ Function: adjustContrast
234
+
235
+ changes the contrast
236
+
237
+ Parameters:
238
+
239
+ s - typical values come in the range -1.0 ... 1.0 where
240
+ -1.0 means no contrast (grey)
241
+ 0 means no change
242
+ 1.0 is high contrast
243
+
244
+
245
+
246
+ Returns:
247
+
248
+ nothing
249
+
250
+
251
+ */
252
+
253
+ public function adjustContrast( r:Number, g:Number = NaN, b:Number = NaN ):void
254
+ {
255
+ if (isNaN(g)) g = r;
256
+ if (isNaN(b)) b = r;
257
+ r += 1;
258
+ g += 1;
259
+ b += 1;
260
+
261
+ concat([r, 0, 0, 0, (128 * (1 - r)),
262
+ 0, g, 0, 0, (128 * (1 - g)),
263
+ 0, 0, b, 0, (128 * (1 - b)),
264
+ 0, 0, 0, 1, 0]);
265
+ }
266
+
267
+
268
+ public function adjustBrightness(r:Number, g:Number=NaN, b:Number=NaN):void
269
+ {
270
+ if (isNaN(g)) g = r;
271
+ if (isNaN(b)) b = r;
272
+ concat([1, 0, 0, 0, r,
273
+ 0, 1, 0, 0, g,
274
+ 0, 0, 1, 0, b,
275
+ 0, 0, 0, 1, 0]);
276
+ }
277
+
278
+
279
+ public function adjustHue( degrees:Number ):void
280
+ {
281
+ degrees *= RAD;
282
+ var cos:Number = Math.cos(degrees);
283
+ var sin:Number = Math.sin(degrees);
284
+ concat([((LUMA_R + (cos * (1 - LUMA_R))) + (sin * -(LUMA_R))), ((LUMA_G + (cos * -(LUMA_G))) + (sin * -(LUMA_G))), ((LUMA_B + (cos * -(LUMA_B))) + (sin * (1 - LUMA_B))), 0, 0,
285
+ ((LUMA_R + (cos * -(LUMA_R))) + (sin * 0.143)), ((LUMA_G + (cos * (1 - LUMA_G))) + (sin * 0.14)), ((LUMA_B + (cos * -(LUMA_B))) + (sin * -0.283)), 0, 0,
286
+ ((LUMA_R + (cos * -(LUMA_R))) + (sin * -((1 - LUMA_R)))), ((LUMA_G + (cos * -(LUMA_G))) + (sin * LUMA_G)), ((LUMA_B + (cos * (1 - LUMA_B))) + (sin * LUMA_B)), 0, 0,
287
+ 0, 0, 0, 1, 0]);
288
+ }
289
+
290
+
291
+ public function rotateHue( degrees:Number ):void
292
+ {
293
+ initHue();
294
+
295
+ concat( preHue.matrix );
296
+ rotateBlue( degrees );
297
+ concat( postHue.matrix );
298
+
299
+ }
300
+
301
+
302
+
303
+
304
+ public function luminance2Alpha():void
305
+ {
306
+ concat([0, 0, 0, 0, 255,
307
+ 0, 0, 0, 0, 255,
308
+ 0, 0, 0, 0, 255,
309
+ LUMA_R, LUMA_G, LUMA_B, 0, 0]);
310
+ }
311
+
312
+ public function adjustAlphaContrast(amount:Number):void
313
+ {
314
+ amount += 1;
315
+ concat([1, 0, 0, 0, 0,
316
+ 0, 1, 0, 0, 0,
317
+ 0, 0, 1, 0, 0,
318
+ 0, 0, 0, amount, (128 * (1 - amount))]);
319
+ }
320
+
321
+ public function colorize(rgb:int, amount:Number=1):void
322
+ {
323
+ var r:Number;
324
+ var g:Number;
325
+ var b:Number;
326
+ var inv_amount:Number;
327
+
328
+ r = (((rgb >> 16) & 0xFF) / 0xFF);
329
+ g = (((rgb >> 8) & 0xFF) / 0xFF);
330
+ b = ((rgb & 0xFF) / 0xFF);
331
+ inv_amount = (1 - amount);
332
+
333
+ concat([(inv_amount + ((amount * r) * LUMA_R)), ((amount * r) * LUMA_G), ((amount * r) * LUMA_B), 0, 0,
334
+ ((amount * g) * LUMA_R), (inv_amount + ((amount * g) * LUMA_G)), ((amount * g) * LUMA_B), 0, 0,
335
+ ((amount * b) * LUMA_R), ((amount * b) * LUMA_G), (inv_amount + ((amount * b) * LUMA_B)), 0, 0,
336
+ 0, 0, 0, 1, 0]);
337
+ }
338
+
339
+
340
+ public function setChannels( r:int = 1, g:int = 2, b:int = 4, a:int = 8):void
341
+ {
342
+ var rf:Number = ((((((r & 1) == 1)) ? 1 : 0 + (((r & 2) == 2)) ? 1 : 0) + (((r & 4) == 4)) ? 1 : 0) + (((r & 8) == 8)) ? 1 : 0);
343
+ if (rf > 0){
344
+ rf = (1 / rf);
345
+ };
346
+ var gf:Number = ((((((g & 1) == 1)) ? 1 : 0 + (((g & 2) == 2)) ? 1 : 0) + (((g & 4) == 4)) ? 1 : 0) + (((g & 8) == 8)) ? 1 : 0);
347
+ if (gf > 0){
348
+ gf = (1 / gf);
349
+ };
350
+ var bf:Number = ((((((b & 1) == 1)) ? 1 : 0 + (((b & 2) == 2)) ? 1 : 0) + (((b & 4) == 4)) ? 1 : 0) + (((b & 8) == 8)) ? 1 : 0);
351
+ if (bf > 0){
352
+ bf = (1 / bf);
353
+ };
354
+ var af:Number = ((((((a & 1) == 1)) ? 1 : 0 + (((a & 2) == 2)) ? 1 : 0) + (((a & 4) == 4)) ? 1 : 0) + (((a & 8) == 8)) ? 1 : 0);
355
+ if (af > 0){
356
+ af = (1 / af);
357
+ };
358
+ concat([(((r & 1) == 1)) ? rf : 0, (((r & 2) == 2)) ? rf : 0, (((r & 4) == 4)) ? rf : 0, (((r & 8) == 8)) ? rf : 0, 0, (((g & 1) == 1)) ? gf : 0, (((g & 2) == 2)) ? gf : 0, (((g & 4) == 4)) ? gf : 0, (((g & 8) == 8)) ? gf : 0, 0, (((b & 1) == 1)) ? bf : 0, (((b & 2) == 2)) ? bf : 0, (((b & 4) == 4)) ? bf : 0, (((b & 8) == 8)) ? bf : 0, 0, (((a & 1) == 1)) ? af : 0, (((a & 2) == 2)) ? af : 0, (((a & 4) == 4)) ? af : 0, (((a & 8) == 8)) ? af : 0, 0]);
359
+ }
360
+
361
+
362
+ public function blend(mat:ColorMatrix, amount:Number):void
363
+ {
364
+ var inv_amount:Number = (1 - amount);
365
+ var i:int = 0;
366
+ while (i < 20)
367
+ {
368
+ matrix[i] = ((inv_amount * Number(matrix[i])) + (amount * Number(mat.matrix[i])));
369
+ i++;
370
+ };
371
+ }
372
+
373
+ public function average( r:Number=ONETHIRD, g:Number=ONETHIRD, b:Number=ONETHIRD):void
374
+ {
375
+ concat([r, g, b, 0, 0,
376
+ r, g, b, 0, 0,
377
+ r, g, b, 0, 0,
378
+ 0, 0, 0, 1, 0]);
379
+ }
380
+
381
+ public function threshold(threshold:Number, factor:Number=256):void
382
+ {
383
+ concat([(LUMA_R * factor), (LUMA_G * factor), (LUMA_B * factor), 0, (-(factor) * threshold),
384
+ (LUMA_R * factor), (LUMA_G * factor), (LUMA_B * factor), 0, (-(factor) * threshold),
385
+ (LUMA_R * factor), (LUMA_G * factor), (LUMA_B * factor), 0, (-(factor) * threshold),
386
+ 0, 0, 0, 1, 0]);
387
+ }
388
+
389
+ public function desaturate():void
390
+ {
391
+ concat([LUMA_R, LUMA_G, LUMA_B, 0, 0,
392
+ LUMA_R, LUMA_G, LUMA_B, 0, 0,
393
+ LUMA_R, LUMA_G, LUMA_B, 0, 0,
394
+ 0, 0, 0, 1, 0]);
395
+ }
396
+
397
+
398
+ public function randomize(amount:Number=1):void
399
+ {
400
+ var inv_amount:Number = (1 - amount);
401
+ var r1:Number = (inv_amount + (amount * (Math.random() - Math.random())));
402
+ var g1:Number = (amount * (Math.random() - Math.random()));
403
+ var b1:Number = (amount * (Math.random() - Math.random()));
404
+ var o1:Number = ((amount * 0xFF) * (Math.random() - Math.random()));
405
+ var r2:Number = (amount * (Math.random() - Math.random()));
406
+ var g2:Number = (inv_amount + (amount * (Math.random() - Math.random())));
407
+ var b2:Number = (amount * (Math.random() - Math.random()));
408
+ var o2:Number = ((amount * 0xFF) * (Math.random() - Math.random()));
409
+ var r3:Number = (amount * (Math.random() - Math.random()));
410
+ var g3:Number = (amount * (Math.random() - Math.random()));
411
+ var b3:Number = (inv_amount + (amount * (Math.random() - Math.random())));
412
+ var o3:Number = ((amount * 0xFF) * (Math.random() - Math.random()));
413
+
414
+ concat([r1, g1, b1, 0, o1,
415
+ r2, g2, b2, 0, o2,
416
+ r3, g3, b3, 0, o3,
417
+ 0, 0, 0, 1, 0]);
418
+ }
419
+
420
+
421
+
422
+
423
+ public function setMultiplicators( red:Number = 1, green:Number = 1, blue:Number = 1, alpha:Number = 1 ):void
424
+ {
425
+ var mat:Array = new Array ( red, 0, 0, 0, 0,
426
+ 0, green, 0, 0, 0,
427
+ 0, 0, blue, 0, 0,
428
+ 0, 0, 0, alpha, 0 );
429
+
430
+ concat(mat);
431
+ }
432
+
433
+ public function clearChannels( red:Boolean = false, green:Boolean = false, blue:Boolean = false, alpha:Boolean = false ):void
434
+ {
435
+ if ( red )
436
+ {
437
+ matrix[0] = matrix[1] = matrix[2] = matrix[3] = matrix[4] = 0;
438
+ }
439
+ if ( green )
440
+ {
441
+ matrix[5] = matrix[6] = matrix[7] = matrix[8] = matrix[9] = 0;
442
+ }
443
+ if ( blue )
444
+ {
445
+ matrix[10] = matrix[11] = matrix[12] = matrix[13] = matrix[14] = 0;
446
+ }
447
+ if ( alpha )
448
+ {
449
+ matrix[15] = matrix[16] = matrix[17] = matrix[18] = matrix[19] = 0;
450
+ }
451
+ }
452
+
453
+ public function thresholdAlpha( threshold:Number, factor:Number = 256):void
454
+ {
455
+ concat([1, 0, 0, 0, 0,
456
+ 0, 1, 0, 0, 0,
457
+ 0, 0, 1, 0, 0,
458
+ 0, 0, 0, factor, (-factor * threshold)]);
459
+ }
460
+
461
+ public function averageRGB2Alpha():void
462
+ {
463
+ concat([0, 0, 0, 0, 255,
464
+ 0, 0, 0, 0, 255,
465
+ 0, 0, 0, 0, 255,
466
+ ONETHIRD, ONETHIRD, ONETHIRD, 0, 0]);
467
+ }
468
+
469
+ public function invertAlpha():void
470
+ {
471
+ concat([1, 0, 0, 0, 0,
472
+ 0, 1, 0, 0, 0,
473
+ 0, 0, 1, 0, 0,
474
+ 0, 0, 0, -1, 255]);
475
+ }
476
+
477
+ public function rgb2Alpha( r:Number, g:Number, b:Number ):void
478
+ {
479
+ concat([0, 0, 0, 0, 255,
480
+ 0, 0, 0, 0, 255,
481
+ 0, 0, 0, 0, 255,
482
+ r, g, b, 0, 0]);
483
+ }
484
+
485
+ public function setAlpha(alpha:Number):void
486
+ {
487
+ concat([1, 0, 0, 0, 0,
488
+ 0, 1, 0, 0, 0,
489
+ 0, 0, 1, 0, 0,
490
+ 0, 0, 0, alpha, 0]);
491
+ }
492
+
493
+
494
+
495
+
496
+ public function get filter():ColorMatrixFilter
497
+ {
498
+ return new ColorMatrixFilter( matrix );
499
+ }
500
+
501
+ public function concat( mat:Array ):void
502
+ {
503
+
504
+ var temp:Array = [];
505
+ var i:int = 0;
506
+ var x:int, y:int;
507
+ for (y = 0; y < 4; y++ )
508
+ {
509
+
510
+ for (x = 0; x < 5; x++ )
511
+ {
512
+ temp[ int( i + x) ] = Number(mat[i ]) * Number(matrix[x]) +
513
+ Number(mat[int(i+1)]) * Number(matrix[int(x + 5)]) +
514
+ Number(mat[int(i+2)]) * Number(matrix[int(x + 10)]) +
515
+ Number(mat[int(i+3)]) * Number(matrix[int(x + 15)]) +
516
+ (x == 4 ? Number(mat[int(i+4)]) : 0);
517
+ }
518
+ i+=5;
519
+ }
520
+
521
+ matrix = temp;
522
+
523
+ }
524
+
525
+ public function rotateRed( degrees:Number ):void
526
+ {
527
+ rotateColor( degrees, 2, 1 );
528
+ }
529
+
530
+ public function rotateGreen( degrees:Number ):void
531
+ {
532
+ rotateColor( degrees, 0, 2 );
533
+ }
534
+
535
+ public function rotateBlue( degrees:Number ):void
536
+ {
537
+ rotateColor( degrees, 1, 0 );
538
+ }
539
+
540
+ private function rotateColor( degrees:Number, x:int, y:int ):void
541
+ {
542
+ degrees *= RAD;
543
+ var mat:Array = IDENTITY.concat();
544
+ mat[ x + x * 5 ] = mat[ y + y * 5 ] = Math.cos( degrees );
545
+ mat[ y + x * 5 ] = Math.sin( degrees );
546
+ mat[ x + y * 5 ] = -Math.sin( degrees );
547
+ concat( mat );
548
+ }
549
+
550
+ public function shearRed( green:Number, blue:Number ):void
551
+ {
552
+ shearColor( 0, 1, green, 2, blue );
553
+ }
554
+
555
+ public function shearGreen( red:Number, blue:Number ):void
556
+ {
557
+ shearColor( 1, 0, red, 2, blue );
558
+ }
559
+
560
+ public function shearBlue( red:Number, green:Number ):void
561
+ {
562
+ shearColor( 2, 0, red, 1, green );
563
+ }
564
+
565
+ private function shearColor( x:int, y1:int, d1:Number, y2:int, d2:Number ):void
566
+ {
567
+ var mat:Array = IDENTITY.concat();
568
+ mat[ y1 + x * 5 ] = d1;
569
+ mat[ y2 + x * 5 ] = d2;
570
+ concat( mat );
571
+ }
572
+
573
+ public function applyColorDeficiency( type:String ):void
574
+ {
575
+ // the values of this method are copied from http://www.nofunc.com/Color_Matrix_Library/
576
+
577
+ switch ( type )
578
+ {
579
+ case 'Protanopia':
580
+ concat([0.567,0.433,0,0,0, 0.558,0.442,0,0,0, 0,0.242,0.758,0,0, 0,0,0,1,0]);
581
+ break;
582
+ case 'Protanomaly':
583
+ concat([0.817,0.183,0,0,0, 0.333,0.667,0,0,0, 0,0.125,0.875,0,0, 0,0,0,1,0]);
584
+ break;
585
+ case 'Deuteranopia':
586
+ concat([0.625,0.375,0,0,0, 0.7,0.3,0,0,0, 0,0.3,0.7,0,0, 0,0,0,1,0]);
587
+ break;
588
+ case 'Deuteranomaly':
589
+ concat([0.8,0.2,0,0,0, 0.258,0.742,0,0,0, 0,0.142,0.858,0,0, 0,0,0,1,0]);
590
+ break;
591
+ case 'Tritanopia':
592
+ concat([0.95,0.05,0,0,0, 0,0.433,0.567,0,0, 0,0.475,0.525,0,0, 0,0,0,1,0]);
593
+ break;
594
+ case 'Tritanomaly':
595
+ concat([0.967,0.033,0,0,0, 0,0.733,0.267,0,0, 0,0.183,0.817,0,0, 0,0,0,1,0]);
596
+ break;
597
+ case 'Achromatopsia':
598
+ concat([0.299,0.587,0.114,0,0, 0.299,0.587,0.114,0,0, 0.299,0.587,0.114,0,0, 0,0,0,1,0]);
599
+ break;
600
+ case 'Achromatomaly':
601
+ concat([0.618,0.320,0.062,0,0, 0.163,0.775,0.062,0,0, 0.163,0.320,0.516,0,0, 0,0,0,1,0]);
602
+ break;
603
+
604
+ }
605
+
606
+ }
607
+
608
+ public function applyMatrix( rgba:uint ):uint
609
+ {
610
+ var a:Number = ( rgba >>> 24 ) & 0xff;
611
+ var r:Number = ( rgba >>> 16 ) & 0xff;
612
+ var g:Number = ( rgba >>> 8 ) & 0xff;
613
+ var b:Number = rgba & 0xff;
614
+
615
+ var r2:int = 0.5 + r * matrix[0] + g * matrix[1] + b * matrix[2] + a * matrix[3] + matrix[4];
616
+ var g2:int = 0.5 + r * matrix[5] + g * matrix[6] + b * matrix[7] + a * matrix[8] + matrix[9];
617
+ var b2:int = 0.5 + r * matrix[10] + g * matrix[11] + b * matrix[12] + a * matrix[13] + matrix[14];
618
+ var a2:int = 0.5 + r * matrix[15] + g * matrix[16] + b * matrix[17] + a * matrix[18] + matrix[19];
619
+
620
+ if ( a2 < 0 ) a2 = 0;
621
+ if ( a2 > 255 ) a2 = 255;
622
+ if ( r2 < 0 ) r2 = 0;
623
+ if ( r2 > 255 ) r2 = 255;
624
+ if ( g2 < 0 ) g2 = 0;
625
+ if ( g2 > 255 ) g2 = 255;
626
+ if ( b2 < 0 ) b2 = 0;
627
+ if ( b2 > 255 ) b2 = 255;
628
+
629
+ return a2<<24 | r2<<16 | g2<<8 | b2;
630
+ }
631
+
632
+
633
+ public function transformVector( values:Array ):void
634
+ {
635
+ if ( values.length != 4) return;
636
+
637
+ var r:Number = values[0] * matrix[0] + values[1] * matrix[1] + values[2] * matrix[2] + values[3] * matrix[3] + matrix[4];
638
+ var g:Number = values[0] * matrix[5] + values[1] * matrix[6] + values[2] * matrix[7] + values[3] * matrix[8] + matrix[9];
639
+ var b:Number = values[0] * matrix[10] + values[1] * matrix[11] + values[2] * matrix[12] + values[3] * matrix[13] + matrix[14];
640
+ var a:Number = values[0] * matrix[15] + values[1] * matrix[16] + values[2] * matrix[17] + values[3] * matrix[18] + matrix[19];
641
+
642
+ values[0] = r;
643
+ values[1] = g;
644
+ values[2] = b;
645
+ values[3] = a;
646
+ }
647
+
648
+
649
+ private function initHue():void
650
+ {
651
+
652
+ //var greenRotation:Number = 35.0;
653
+ var greenRotation:Number = 39.182655;
654
+
655
+ if (!hueInitialized)
656
+ {
657
+ hueInitialized = true;
658
+ preHue = new ColorMatrix();
659
+ preHue.rotateRed( 45 );
660
+ preHue.rotateGreen(- greenRotation );
661
+
662
+ var lum:Array = [ LUMA_R2, LUMA_G2, LUMA_B2, 1.0 ];
663
+
664
+ preHue.transformVector(lum);
665
+
666
+ var red:Number = lum[0] / lum[2];
667
+ var green:Number = lum[1] / lum[2];
668
+
669
+ preHue.shearBlue(red, green);
670
+
671
+ postHue = new ColorMatrix();
672
+ postHue.shearBlue( -red, -green);
673
+ postHue.rotateGreen(greenRotation);
674
+ postHue.rotateRed(- 45.0 );
675
+ }
676
+
677
+ }
678
+
679
+
680
+
681
+ }
682
+ }
@@ -0,0 +1,37 @@
1
+ module LBi
2
+ class AS2ClassLexer
3
+ COMPONENTS = [
4
+ [:imports , // ],
5
+ [:fields , // ],
6
+ [:methods , /^.*function.*;$/ ]
7
+ ]
8
+ def initialize filename
9
+ @filename = filename
10
+ @components = {}
11
+ parse
12
+ end
13
+ def parse
14
+ @raw = IO.read(@filename)
15
+ COMPONENTS.each do |d|
16
+ add_components ClassComponent.new(d[0], d[1])
17
+ end
18
+ end
19
+ def add_components definition
20
+ match, *result = *@raw.match(definition.regexp)
21
+ @components[definition.id] = result
22
+ end
23
+ def get_methods
24
+ @components[:methods]
25
+ end
26
+ end
27
+ class ClassComponent
28
+ attr_reader :id, :regexp
29
+ def initialize id, regexp
30
+ @id = id
31
+ @regexp = regexp
32
+ end
33
+ end
34
+ class AS2Method
35
+
36
+ end
37
+ end