bm-core-ui 2.7.0

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.
Files changed (99) hide show
  1. package/CHANGELOG.md +1624 -0
  2. package/LICENSE +21 -0
  3. package/README.md +145 -0
  4. package/build/@types/index.d.ts +14078 -0
  5. package/build/BMCodeEditor/BMCodeEditor.js +707 -0
  6. package/build/BMCollectionView/BMCollectionView.js +5861 -0
  7. package/build/BMCollectionView/BMCollectionViewCell.js +688 -0
  8. package/build/BMCollectionView/BMCollectionViewFlowLayout.js +4467 -0
  9. package/build/BMCollectionView/BMCollectionViewLayout.js +830 -0
  10. package/build/BMCollectionView/BMCollectionViewLayoutAttributes.js +673 -0
  11. package/build/BMCollectionView/BMCollectionViewMasonryLayout.js +491 -0
  12. package/build/BMCollectionView/BMCollectionViewStackLayout.js +634 -0
  13. package/build/BMCollectionView/BMCollectionViewTileLayout.js +1121 -0
  14. package/build/BMCoreUI.css +2833 -0
  15. package/build/BMView/BMAttributedLabelView.js +310 -0
  16. package/build/BMView/BMLayoutConstraint_v2.5.js +1813 -0
  17. package/build/BMView/BMLayoutGuide.js +192 -0
  18. package/build/BMView/BMLayoutSizeClass.js +466 -0
  19. package/build/BMView/BMMenu.js +574 -0
  20. package/build/BMView/BMScrollView.js +247 -0
  21. package/build/BMView/BMTextField.js +512 -0
  22. package/build/BMView/BMTextFieldDelegate.js +71 -0
  23. package/build/BMView/BMView_v2.5.js +3572 -0
  24. package/build/BMView/BMViewport.js +221 -0
  25. package/build/BMViewLayoutEditor/BMLayoutEditor.js +6117 -0
  26. package/build/BMViewLayoutEditor/BMLayoutEditorConstraintSettings.js +417 -0
  27. package/build/BMViewLayoutEditor/BMLayoutEditorDelegate.js +59 -0
  28. package/build/BMViewLayoutEditor/BMLayoutEditorSettingCells.js +1653 -0
  29. package/build/BMViewLayoutEditor/BMLayoutEditorSettings.js +1480 -0
  30. package/build/BMViewLayoutEditor/BMLayoutEditorSettingsComplexCells.js +431 -0
  31. package/build/BMViewLayoutEditor/BMLayoutEditorSettingsDelegate.js +46 -0
  32. package/build/BMViewLayoutEditor/BMLayoutEditorVariablesController.js +460 -0
  33. package/build/BMViewLayoutEditor/BMLayoutEditorViewGroupSettings.js +293 -0
  34. package/build/BMViewLayoutEditor/BMLayoutEditorViewSettings.js +382 -0
  35. package/build/BMViewLayoutEditor/BMLayoutVariableProvider.js +202 -0
  36. package/build/BMWindow/BMConfirmationPopup.js +477 -0
  37. package/build/BMWindow/BMKeyboardShortcut.js +151 -0
  38. package/build/BMWindow/BMPopover/BMPopover.js +492 -0
  39. package/build/BMWindow/BMToolWindow.js +71 -0
  40. package/build/BMWindow/BMWindow.js +2000 -0
  41. package/build/Core/BMAnimationContext.js +1181 -0
  42. package/build/Core/BMColor.js +991 -0
  43. package/build/Core/BMCoreUI.js +470 -0
  44. package/build/Core/BMFunctionCollection.js +110 -0
  45. package/build/Core/BMIndexPath.js +165 -0
  46. package/build/Core/BMInset.js +138 -0
  47. package/build/Core/BMKeyPath.js +100 -0
  48. package/build/Core/BMPoint.js +291 -0
  49. package/build/Core/BMRect.js +556 -0
  50. package/build/Core/BMSize.js +137 -0
  51. package/build/iScroll/LICENSE +22 -0
  52. package/build/iScroll/iscroll-probe.js +2154 -0
  53. package/build/images/AlignBottom.png +0 -0
  54. package/build/images/AlignCenterX.png +0 -0
  55. package/build/images/AlignCenterY.png +0 -0
  56. package/build/images/AlignLeading.png +0 -0
  57. package/build/images/AlignTop.png +0 -0
  58. package/build/images/AlignTrailing.png +0 -0
  59. package/build/images/AllConstraints.png +0 -0
  60. package/build/images/BottomConstraint.png +0 -0
  61. package/build/images/CenterXConstraint.png +0 -0
  62. package/build/images/CenterYConstraint.png +0 -0
  63. package/build/images/CoreUI2.png +0 -0
  64. package/build/images/CoreUI2@2x.png +0 -0
  65. package/build/images/Desktop.png +0 -0
  66. package/build/images/DesktopMini.png +0 -0
  67. package/build/images/EqualHeight.png +0 -0
  68. package/build/images/EqualHorizontalSpacing.png +0 -0
  69. package/build/images/EqualHorizontalSpacingInSuperview.png +0 -0
  70. package/build/images/EqualVerticalSpacing.png +0 -0
  71. package/build/images/EqualVerticalSpacingInSuperview.png +0 -0
  72. package/build/images/EqualWidth.png +0 -0
  73. package/build/images/HeightConstraint.png +0 -0
  74. package/build/images/InactiveConstraints.png +0 -0
  75. package/build/images/Layout.png +0 -0
  76. package/build/images/LayoutVariables.png +0 -0
  77. package/build/images/LeftConstraint.png +0 -0
  78. package/build/images/OwnConstraints.png +0 -0
  79. package/build/images/Phone.png +0 -0
  80. package/build/images/PhoneLandscape.png +0 -0
  81. package/build/images/PhoneLandscapeMini.png +0 -0
  82. package/build/images/PhoneMini.png +0 -0
  83. package/build/images/PhonePortrait.png +0 -0
  84. package/build/images/PhonePortraitMini.png +0 -0
  85. package/build/images/Properties.png +0 -0
  86. package/build/images/RightConstraint.png +0 -0
  87. package/build/images/SubviewConstraints.png +0 -0
  88. package/build/images/Tablet.png +0 -0
  89. package/build/images/TabletLandscape.png +0 -0
  90. package/build/images/TabletLandscapeMini.png +0 -0
  91. package/build/images/TabletMini.png +0 -0
  92. package/build/images/TabletPortrait.png +0 -0
  93. package/build/images/TabletPortraitMini.png +0 -0
  94. package/build/images/TopConstraint.png +0 -0
  95. package/build/images/WidthConstraint.png +0 -0
  96. package/build/index.js +40 -0
  97. package/lib/@types/BMCoreUI.min.d.ts +14078 -0
  98. package/lib/BMCoreUI.min.js +1 -0
  99. package/package.json +58 -0
@@ -0,0 +1,991 @@
1
+ // @ts-check
2
+
3
+ import {BMNumberByConstrainingNumberToBounds, BMNumberByInterpolatingNumbersWithFraction} from './BMCoreUI'
4
+
5
+ // @type _BMColorStorage
6
+
7
+ /**
8
+ * Used internally by CoreUI.
9
+ */
10
+ // function _BMColorStorage() {} // <constructor>
11
+
12
+ // @endtype
13
+
14
+ // @type BMColor implements BMAnimating
15
+
16
+ /*
17
+ ****************************************************************************************************************************************************************
18
+ BMColor
19
+ ****************************************************************************************************************************************************************
20
+ */
21
+
22
+ /**
23
+ * A BMColor object is an opaque representation of a CSS color.
24
+ * It handles the conversion between the different CSS color representations such as hex strings and rgba strings.
25
+ * The BMColor is an abstract object - a different implementation of BMColor may be used depending on how it was constructed.
26
+ * Additionally, changing certain properties of this object might cause its underlying implementation to change at runtime;
27
+ * when this happens, the color might change slightly if the target implementation cannot accurately represent the source one.
28
+ */
29
+ export function BMColor() {} // <constructor>
30
+
31
+ BMColor.prototype = {
32
+
33
+ /**
34
+ * The underlying storage object to which this color object delegates its functionality.
35
+ */
36
+ _storage: undefined, // <_BMColorStorage>
37
+
38
+ /**
39
+ * The color's red component in a RGBA representation.
40
+ * Changing this value will cause this color's underlying representation to switch to RGBA.
41
+ */
42
+ get red() { // <Short>
43
+ return this._storage.red;
44
+ },
45
+ set red(red) {
46
+ this._storage.red = red;
47
+ },
48
+
49
+ /**
50
+ * The color's green component in a RGBA representation.
51
+ * Changing this value will cause this color's underlying representation to switch to RGBA.
52
+ */
53
+ get green() { // <Short>
54
+ return this._storage.green;
55
+ },
56
+ set green(green) {
57
+ this._storage.green = green;
58
+ },
59
+
60
+ /**
61
+ * The color's blue component in a RGBA representation.
62
+ * Changing this value will cause this color's underlying representation to switch to RGBA.
63
+ */
64
+ get blue() { // <Short>
65
+ return this._storage.blue;
66
+ },
67
+ set blue(blue) {
68
+ this._storage.blue = blue;
69
+ },
70
+
71
+
72
+ /**
73
+ * The color's alpha component.
74
+ */
75
+ get alpha() { // <Short>
76
+ return this._storage.alpha;
77
+ },
78
+ set alpha(alpha) {
79
+ this._storage.alpha = alpha;
80
+ },
81
+
82
+
83
+ /**
84
+ * The color's hue component in a HSLA representation.
85
+ * Changing this value will cause this color's underlying representation to switch to HSLA.
86
+ */
87
+ get hue() { // <Short>
88
+ return this._storage.hue;
89
+ },
90
+ set hue(hue) {
91
+ this._storage.hue = hue;
92
+ },
93
+
94
+ /**
95
+ * The color's saturation component in a HSLA representation.
96
+ * Changing this value will cause this color's underlying representation to switch to HSLA.
97
+ */
98
+ get saturation() { // <Short>
99
+ return this._storage.saturation;
100
+ },
101
+ set saturation(saturation) {
102
+ this._storage.saturation = saturation;
103
+ },
104
+
105
+ /**
106
+ * The color's luminosity component in a HSLA representation.
107
+ * Changing this value will cause this color's underlying representation to switch to HSLA.
108
+ */
109
+ get luminosity() { // <Short>
110
+ return this._storage.luminosity;
111
+ },
112
+ set luminosity(luminosity) {
113
+ this._storage.luminosity = luminosity;
114
+ },
115
+
116
+ /**
117
+ * The RGBA representation of this color.
118
+ */
119
+ get RGBAString() { // <String>
120
+ return this._storage.RGBAString;
121
+ },
122
+
123
+ /**
124
+ * The RGB representation of this color. The alpha component of this color is ignored in this representation.
125
+ */
126
+ get RGBString() { // <String>
127
+ return this._storage.RGBString;
128
+ },
129
+
130
+ /**
131
+ * The hex representation of this color. The alpha component of this color is ignored in this representation.
132
+ */
133
+ get hexString() { // <String>
134
+ return this._storage.hexString;
135
+ },
136
+
137
+ /**
138
+ * The HSLA representation of this color.
139
+ */
140
+ get HSLAString() { // <String>
141
+ return this._storage.HSLAString;
142
+ },
143
+
144
+ /**
145
+ * The HSL representation of this color. The alpha component of this color is ignored in this representation.
146
+ */
147
+ get HSLString() { // <String>
148
+ return this._storage.HSLString;
149
+ },
150
+
151
+ /**
152
+ * Creates and returns a copy of this color.
153
+ * @return <BMColor> A color.
154
+ */
155
+ copy: function () {
156
+ var color = new BMColor();
157
+
158
+ color._storage = this._storage.copy();
159
+
160
+ return color;
161
+ },
162
+
163
+ /**
164
+ * Invoked by the CoreUI animation engine to obtain an interpolated
165
+ * value between this object and the target object.
166
+ * The resulting color will always be in the RGBA space when created
167
+ * by this method.
168
+ * @param fraction <Number> The animation fraction.
169
+ * {
170
+ * @param toValue <BMColor> The object to which to interpolate.
171
+ * }
172
+ * @return <BMColor> A color.
173
+ */
174
+ interpolatedValueWithFraction(fraction, args) {
175
+ var target = args.toValue;
176
+ return BMColorByInterpolatingRGBAColor(this, {toColor: target, withFraction: fraction});
177
+ }
178
+ };
179
+
180
+ /**
181
+ * Constructs and returns a fully transparent black color.
182
+ * @return <BMColor> A color.
183
+ */
184
+ export function BMColorMake() {
185
+ return BMColorMakeWithRed(0, {green: 0, blue: 0, alpha: 0});
186
+ }
187
+
188
+
189
+ /**
190
+ * Constructs and returns a BMColor object by parsing the given CSS color string.
191
+ * The string can be a hex, rgba, rgb, hsla or hsl color or any of the CSS 3 color keywords.
192
+ * If the string is not a valid color string, the resulting BMColor object is not defined.
193
+ * @param string <String, nullable> Defaults to 'rgba(0, 0, 0, 0)'. The color string.
194
+ * @return <BMColor, nullable> The new BMColor object or undefined if the color string cannot be parsed.
195
+ */
196
+ export function BMColorMakeWithString(string) {
197
+
198
+ if (!string) return BMColorMakeWithRed(0, {green: 0, blue: 0, alpha: 0});
199
+
200
+ if (_BMColorKeywords[string]) return BMColorMakeWithHexString(_BMColorKeywords[string]);
201
+
202
+ if (string.indexOf('#') == 0) return BMColorMakeWithHexString(string);
203
+
204
+ if (string.indexOf('rgba') == 0) return BMColorMakeWithRGBAString(string);
205
+
206
+ if (string.indexOf('rgb') == 0) return BMColorMakeWithRGBString(string);
207
+
208
+ if (string.indexOf('hsla') == 0) return BMColorMakeWithHSLAString(string);
209
+
210
+ if (string.indexOf('hsl') == 0) return BMColorMakeWithHSLString(string);
211
+
212
+ }
213
+
214
+ /**
215
+ * Constructs and returns a BMColor by specifying its RGBA components.
216
+ * @param red <Short> The red component.
217
+ * {
218
+ * @param green <Short> The green component.
219
+ * @param blue <Short> The blue component.
220
+ * @param alpha <Short, nullable> Defaults to 1. The alpha component.
221
+ * }
222
+ */
223
+ export function BMColorMakeWithRed(red, options) {
224
+ var color = new BMColor();
225
+
226
+ color._storage = new _BMRGBAColor();
227
+ color._storage._color = color;
228
+
229
+ color._storage._red = BMNumberByConstrainingNumberToBounds(red | 0, 0, 255);
230
+ color._storage._green = BMNumberByConstrainingNumberToBounds(options.green | 0, 0, 255);
231
+ color._storage._blue = BMNumberByConstrainingNumberToBounds(options.blue | 0, 0, 255);
232
+
233
+ color._storage._alpha = BMNumberByConstrainingNumberToBounds('alpha' in options ? options.alpha : 1, 0, 1);
234
+
235
+ return color;
236
+ }
237
+
238
+ /**
239
+ * Constructs and returns a BMColor by specifying its HSLA components.
240
+ * @param hue <Int> The hue component.
241
+ * {
242
+ * @param saturation <Short> The saturation component.
243
+ * @param luminosity <Short> The luminosity component.
244
+ * @param alpha <Short, nullable> Defaults to 1. The alpha component.
245
+ * }
246
+ */
247
+ export function BMColorMakeWithHue(hue, options) {
248
+ var color = new BMColor();
249
+
250
+ color._storage = new _BMHSLAColor();
251
+ color._storage._color = color;
252
+
253
+ color._storage._hue = BMNumberByConstrainingNumberToBounds(hue | 0, 0, 360);
254
+ color._storage._saturation = BMNumberByConstrainingNumberToBounds(options.saturation | 0, 0, 100);
255
+ color._storage._lightness = BMNumberByConstrainingNumberToBounds(options.lightness | 0, 0, 100);
256
+
257
+ color._storage._alpha = BMNumberByConstrainingNumberToBounds('alpha' in options ? options.alpha : 1, 0, 1);
258
+
259
+ return color;
260
+ }
261
+
262
+
263
+ /**
264
+ * Constructs and returns a new BMColor by parsing the specified hex string.
265
+ * @param string <String> The hex string.
266
+ * @return <BMColor> A color.
267
+ */
268
+ export function BMColorMakeWithHexString(string) {
269
+ var color = new BMColor();
270
+
271
+ color._storage = new _BMRGBAColor();
272
+ color._storage._color = color;
273
+
274
+ if (string.charAt(0) == '#') {
275
+ color._storage._red = parseInt(string.substring(1, 3), 16);
276
+ color._storage._green = parseInt(string.substring(3, 5), 16);
277
+ color._storage._blue = parseInt(string.substring(5, 7), 16);
278
+ }
279
+ else {
280
+ color._storage._red = parseInt(string.substring(0, 2), 16);
281
+ color._storage._green = parseInt(string.substring(2, 4), 16);
282
+ color._storage._blue = parseInt(string.substring(4, 6), 16);
283
+ }
284
+
285
+ return color;
286
+ }
287
+
288
+
289
+ /**
290
+ * Constructs and returns a new BMColor by parsing the specified RGBA string.
291
+ * @param string <String> The RGBA string.
292
+ * @return <BMColor> A color.
293
+ */
294
+ export function BMColorMakeWithRGBAString(string) {
295
+ var color = new BMColor();
296
+
297
+ color._storage = new _BMRGBAColor();
298
+ color._storage._color = color;
299
+
300
+ var components = string.split(',');
301
+
302
+ color._storage.red = parseInt(components[0].substring(5), 10);
303
+ color._storage.green = parseInt(components[1], 10);
304
+ color._storage.blue = parseInt(components[2], 10);
305
+ color._storage.alpha = parseFloat(components[3]);
306
+
307
+ return color;
308
+ }
309
+
310
+
311
+ /**
312
+ * Constructs and returns a new BMColor by parsing the specified RGB string.
313
+ * @param string <String> The RGB string.
314
+ * @return <BMColor> A color.
315
+ */
316
+ export function BMColorMakeWithRGBString(string) {
317
+ var color = new BMColor();
318
+
319
+ color._storage = new _BMRGBAColor();
320
+ color._storage._color = color;
321
+
322
+ var components = string.split(',');
323
+
324
+ color._storage.red = parseInt(components[0].substring(4), 10);
325
+ color._storage.green = parseInt(components[1], 10);
326
+ color._storage.blue = parseInt(components[2], 10);
327
+
328
+ return color;
329
+ }
330
+
331
+
332
+ /**
333
+ * Constructs and returns a new BMColor by parsing the specified RGBA string.
334
+ * @param string <String> The RGBA string.
335
+ * @return <BMColor> A color.
336
+ */
337
+ export function BMColorMakeWithHSLAString(string) {
338
+ var color = new BMColor();
339
+
340
+ color._storage = new _BMHSLAColor();
341
+ color._storage._color = color;
342
+
343
+ var components = string.split(',');
344
+
345
+ color._storage.hue = parseInt(components[0].substring(5), 10);
346
+ color._storage.saturation = parseInt(components[1], 10);
347
+ color._storage.luminosity = parseInt(components[2], 10);
348
+ color._storage.alpha = parseFloat(components[3]);
349
+
350
+ return color;
351
+ }
352
+
353
+
354
+ /**
355
+ * Constructs and returns a new BMColor by parsing the specified RGB string.
356
+ * @param string <String> The RGB string.
357
+ * @return <BMColor> A color.
358
+ */
359
+ export function BMColorMakeWithHSLString(string) {
360
+ var color = new BMColor();
361
+
362
+ color._storage = new _BMHSLAColor();
363
+ color._storage._color = color;
364
+
365
+ var components = string.split(',');
366
+
367
+ color._storage.hue = parseInt(components[0].substring(4), 10);
368
+ color._storage.saturation = parseInt(components[1], 10);
369
+ color._storage.luminosity = parseInt(components[2], 10);
370
+
371
+ return color;
372
+ }
373
+
374
+
375
+ /**
376
+ * Creates and returns a color that represents the interpolation between two colors with a given fraction.
377
+ * The resulting color will always be a RGBA color.
378
+ * @param sourceColor <BMColor> The source color.
379
+ * {
380
+ * @param toColor <BMColor> The target color.
381
+ * @param withFraction <Number> The amount by which to interpolate. The fraction should be a number between 0 and 1, but going past these values is supported.
382
+ * Negative values will overshoot the source color and values greater than 1 will overshoot the target color, however each color
383
+ * component will be clamped between each component's minimum and maximum values.
384
+ * }
385
+ * @return <BMColor> A color.
386
+ */
387
+ export function BMColorByInterpolatingRGBAColor(sourceColor, options) {
388
+ var targetColor = options.toColor;
389
+ var fraction = options.withFraction;
390
+
391
+ return BMColorMakeWithRed(BMNumberByInterpolatingNumbersWithFraction(sourceColor.red, targetColor.red, fraction), {
392
+ green: BMNumberByInterpolatingNumbersWithFraction(sourceColor.green, targetColor.green, fraction),
393
+ blue: BMNumberByInterpolatingNumbersWithFraction(sourceColor.blue, targetColor.blue, fraction),
394
+ alpha: BMNumberByInterpolatingNumbersWithFraction(sourceColor.alpha, targetColor.alpha, fraction)
395
+ });
396
+ }
397
+
398
+
399
+ /**
400
+ * Creates and returns a color that represents the interpolation between two colors with a given fraction.
401
+ * The resulting color will always be a HSLA color.
402
+ * @param sourceColor <BMColor> The source color.
403
+ * {
404
+ * @param toColor <BMColor> The target color.
405
+ * @param withFraction <Number> The amount by which to interpolate. The fraction should be a number between 0 and 1, but going past these values is supported.
406
+ * Negative values will overshoot the source color and values greater than 1 will overshoot the target color, however each color
407
+ * component will be clamped between each component's minimum and maximum values.
408
+ * }
409
+ * @return <BMColor> A color.
410
+ */
411
+ export function BMColorByInterpolatingHSLAColor(sourceColor, options) {
412
+ var targetColor = options.toColor;
413
+ var fraction = options.withFraction;
414
+
415
+ return BMColorMakeWithHue(BMNumberByInterpolatingNumbersWithFraction(sourceColor.hue, targetColor.hue, fraction), {
416
+ saturation: BMNumberByInterpolatingNumbersWithFraction(sourceColor.saturation, targetColor.saturation, fraction),
417
+ luminosity: BMNumberByInterpolatingNumbersWithFraction(sourceColor.luminosity, targetColor.luminosity, fraction),
418
+ alpha: BMNumberByInterpolatingNumbersWithFraction(sourceColor.alpha, targetColor.alpha, fraction)
419
+ });
420
+ }
421
+
422
+
423
+ /**
424
+ * Converts the given number to a hex string that is guaranteed to have at least the specified number of digits.
425
+ * @param number <Int> The number to convert.
426
+ * {
427
+ * @param minDigits <Int, nullable> Defaults to 0. When set to a positive number, the resulting hex string will be padded with 0 if
428
+ * its length is lower than this parameter.
429
+ * }
430
+ * @return <String> A hex string.
431
+ */
432
+ export function BMHexStringWithNumber(number, options) {
433
+ var result = number.toString(16);
434
+ var minDigits = (options && options.minDigits) || 0;
435
+
436
+ // If the resulting string has fewer digits than the minDigits paramter, 0 will be added to the beginning of the string until
437
+ // it matches the required digit count.
438
+ while (result.length < minDigits) {
439
+ result = '0' + result;
440
+ }
441
+
442
+ return result;
443
+ }
444
+
445
+ // @endtype
446
+
447
+ // @type _BMRGBAColor implements _BMColorStorage
448
+
449
+ /**
450
+ * A _BMRGBAColor object is a color storage model where colors are represented by four 8 bit values representing the
451
+ * red, green, blue and alpha components.
452
+ */
453
+ function _BMRGBAColor() {}; // <constructor>
454
+
455
+ _BMRGBAColor.prototype = {
456
+
457
+ /**
458
+ * The color object that manages this RGBAColor
459
+ */
460
+ _color: undefined, // <BMColor>
461
+
462
+ /**
463
+ * The color's red component.
464
+ */
465
+ _red: 0, // <Short>
466
+ get red() { return this._red; },
467
+ set red(red) {
468
+ this._red = BMNumberByConstrainingNumberToBounds(red | 0, 0, 255);
469
+ },
470
+
471
+ /**
472
+ * The color's green component.
473
+ */
474
+ _green: 0, // <Short>
475
+ get green() { return this._green; },
476
+ set green(green) {
477
+ this._green = BMNumberByConstrainingNumberToBounds(green | 0, 0, 255);
478
+ },
479
+
480
+ /**
481
+ * The color's blue component.
482
+ */
483
+ _blue: 0, // <Short>
484
+
485
+ get blue() { return this._blue; },
486
+ set blue(blue) {
487
+ this._blue = BMNumberByConstrainingNumberToBounds(blue | 0, 0, 255);
488
+ },
489
+
490
+ /**
491
+ * The color's alpha component.
492
+ */
493
+ _alpha: 1, // <Short>
494
+ get alpha() { return this._alpha; },
495
+ set alpha(alpha) {
496
+ this._alpha = BMNumberByConstrainingNumberToBounds(alpha, 0, 1);
497
+ },
498
+
499
+
500
+ /**
501
+ * The color's hue component in a HSLA representation.
502
+ * Changing this value will cause this color's underlying representation to switch to HSLA.
503
+ */
504
+ get hue() { // <Short>
505
+ return this.BMHSLAColor.hue;
506
+ },
507
+ set hue(hue) {
508
+ var storage = this.BMHSLAColor;
509
+ this._color._storage = storage;
510
+ storage.hue = hue;
511
+ },
512
+
513
+ /**
514
+ * The color's saturation component in a HSLA representation.
515
+ * Changing this value will cause this color's underlying representation to switch to HSLA.
516
+ */
517
+ get saturation() { // <Short>
518
+ return this.BMHSLAColor.saturation;
519
+ },
520
+ set saturation(saturation) {
521
+ var storage = this.BMHSLAColor;
522
+ this._color._storage = storage;
523
+ storage.saturation = saturation;
524
+ },
525
+
526
+ /**
527
+ * The color's luminosity component in a HSLA representation.
528
+ * Changing this value will cause this color's underlying representation to switch to HSLA.
529
+ */
530
+ get luminosity() { // <Short>
531
+ return this.BMHSLAColor.luminosity;
532
+ },
533
+ set luminosity(luminosity) {
534
+ var storage = this.BMHSLAColor;
535
+ this._color._storage = storage;
536
+ storage.luminosity = luminosity;
537
+ },
538
+
539
+ /**
540
+ * Returns the equivalent HSLA color.
541
+ */
542
+ get BMHSLAColor() { // <_BMHSLAColor>
543
+ var HSLAColor = new _BMHSLAColor();
544
+
545
+ // NOTE: code from http://en.wikipedia.org/wiki/HSL_color_space
546
+
547
+ var r = this._red / 255;
548
+ var g = this._green / 255;
549
+ var b = this._blue / 255;
550
+
551
+ var max = Math.max(r, g, b);
552
+ var min = Math.min(r, g, b);
553
+
554
+ var l = (max + min) / 2;
555
+ HSLAColor._luminosity = (l * 100) | 0;
556
+
557
+ if (max == min) {
558
+ HSLAColor._saturation = 0;
559
+ HSLAColor._hue = 0;
560
+ }
561
+ else {
562
+ var d = max - min;
563
+ var s = l > .5 ? (d / (2 - max - min)) : d / (max + min);
564
+ var h;
565
+ switch (max) {
566
+ case r: h = (g - b) / d + (g < b ? 6 : 0); break;
567
+ case g: h = (b - r) / d + 2; break;
568
+ case b: h = (r - g) / d + 4; break;
569
+ }
570
+ h = h / 6;
571
+
572
+ HSLAColor._saturation = (s * 100) | 0;
573
+ HSLAColor._hue = (h * 360) | 0;
574
+ }
575
+
576
+ HSLAColor._alpha = this._alpha;
577
+
578
+ return HSLAColor;
579
+ },
580
+
581
+ /**
582
+ * The RGBA representation of this color.
583
+ */
584
+ get RGBAString() { // <String>
585
+ return 'rgba(' + this._red + ',' + this._green + ',' + this._blue + ',' + this._alpha + ')';
586
+ },
587
+
588
+ /**
589
+ * The RGB representation of this color. The alpha component of this color is ignored in this representation.
590
+ */
591
+ get RGBString() { // <String>
592
+ return 'rgb(' + this._red + ',' + this._green + ',' + this._blue + ')';
593
+ },
594
+
595
+ /**
596
+ * The hex representation of this color. The alpha component of this color is ignored in this representation.
597
+ */
598
+ get hexString() { // <String>
599
+ return '#' + BMHexStringWithNumber(this._red, {minDigits: 2}) + BMHexStringWithNumber(this._green, {minDigits: 2}) + BMHexStringWithNumber(this._blue, {minDigits: 2});
600
+ },
601
+
602
+ /**
603
+ * The HSLA representation of this color.
604
+ */
605
+ get HSLAString() { // <String>
606
+ return this.BMHSLAColor.HSLAString;
607
+ },
608
+
609
+ /**
610
+ * The HSL representation of this color. The alpha component of this color is ignored in this representation.
611
+ */
612
+ get HSLString() { // <String>
613
+ return this.BMHSLAColor.HSLString;
614
+ },
615
+
616
+ /**
617
+ * Creates and returns a copy of this RGBA color.
618
+ * @return <BMColor> A color.
619
+ */
620
+ copy: function () {
621
+ var color = new _BMRGBAColor();
622
+
623
+ color._red = this._red;
624
+ color._green = this._green;
625
+ color._blue = this._blue;
626
+ color._alpha = this._alpha;
627
+
628
+ return color;
629
+
630
+ }
631
+
632
+ };
633
+
634
+ // @endtype
635
+
636
+ // @type _BMHSLAColor implements _BMColorStorage
637
+
638
+ /**
639
+ * A _BMHSLAColor object is a color storage model where colors are represented by four 8 bit values representing the
640
+ * hue, saturation, luminosity and alpha components.
641
+ */
642
+ function _BMHSLAColor() {}; // <constructor>
643
+
644
+ _BMHSLAColor.prototype = {
645
+
646
+ /**
647
+ * The color object that manages this HSLAColor
648
+ */
649
+ _color: undefined, // <BMColor>
650
+
651
+ /**
652
+ * The color's red component.
653
+ * Changing this value will cause this color's underlying representation to switch to RGBA.
654
+ */
655
+ get red() {
656
+ return this.BMRGBAColor.red;
657
+ },
658
+ set red(red) {
659
+ var storage = this.BMRGBAColor;
660
+ this._color._storage = storage;
661
+ storage.red = red;
662
+ },
663
+
664
+ /**
665
+ * The color's green component.
666
+ * Changing this value will cause this color's underlying representation to switch to RGBA.
667
+ */
668
+ get green() {
669
+ return this.BMRGBAColor.green;
670
+ },
671
+ set green(green) {
672
+ var storage = this.BMRGBAColor;
673
+ this._color._storage = storage;
674
+ storage.green = green;
675
+ },
676
+
677
+ /**
678
+ * The color's blue component.
679
+ * Changing this value will cause this color's underlying representation to switch to RGBA.
680
+ */
681
+ get blue() {
682
+ return this.BMRGBAColor.blue;
683
+ },
684
+ set blue(blue) {
685
+ var storage = this.BMRGBAColor;
686
+ this._color._storage = storage;
687
+ storage.blue = blue;
688
+ },
689
+
690
+ /**
691
+ * The color's alpha component.
692
+ */
693
+ _alpha: 1, // <Short>
694
+ get alpha() { return this._alpha; },
695
+ set alpha(alpha) {
696
+ this._alpha = BMNumberByConstrainingNumberToBounds(alpha, 0, 1);
697
+ },
698
+
699
+
700
+ /**
701
+ * The color's hue component in a HSLA representation.
702
+ */
703
+ _hue: 0, // <Int>
704
+
705
+ get hue() {
706
+ return this._hue;
707
+ },
708
+ set hue(hue) {
709
+ this._hue = BMNumberByConstrainingNumberToBounds(hue | 0, 0, 360);
710
+ },
711
+
712
+ /**
713
+ * The color's saturation component in a HSLA representation.
714
+ */
715
+ _saturation: 0, // <Short>
716
+
717
+ get saturation() {
718
+ return this._saturation;
719
+ },
720
+ set saturation(saturation) {
721
+ this._saturation = BMNumberByConstrainingNumberToBounds(saturation | 0, 0, 100);
722
+ },
723
+
724
+ /**
725
+ * The color's luminosity component in a HSLA representation.
726
+ */
727
+ _luminosity: 0, // <Short>
728
+
729
+ get luminosity() {
730
+ return this._luminosity;
731
+ },
732
+ set luminosity(luminosity) {
733
+ this._luminosity = BMNumberByConstrainingNumberToBounds(luminosity | 0, 0, 100);
734
+ },
735
+
736
+ /**
737
+ * Returns the equivalent HSLA color.
738
+ */
739
+ get BMRGBAColor() { // <_BMRGBAColor>
740
+ var RGBAColor = new _BMRGBAColor();
741
+
742
+ // NOTE: code from http://en.wikipedia.org/wiki/HSL_color_space
743
+ if (this._saturation == 0) {
744
+ RGBAColor._red = RGBAColor._green = RGBAColor._blue = (((this._luminosity / 100) * 255) | 0);
745
+ }
746
+ else {
747
+ var h = this._hue / 360;
748
+ var l = this._luminosity / 100;
749
+ var s = this._saturation / 100;
750
+
751
+ var q = l < .5 ? l * (1 + s) : l + s - l * s;
752
+ var p = 2 * l - q;
753
+
754
+ RGBAColor._red = (_BMHueToRGB(p, q, h + 1 / 3) * 255) | 0;
755
+ RGBAColor._green = (_BMHueToRGB(p, q, h) * 255) | 0;
756
+ RGBAColor._blue = (_BMHueToRGB(p, q, h - 1 / 3) * 255) | 0;
757
+ }
758
+
759
+ RGBAColor._alpha = this._alpha;
760
+
761
+ return RGBAColor;
762
+ },
763
+
764
+ /**
765
+ * The RGBA representation of this color.
766
+ */
767
+ get RGBAString() { // <String>
768
+ return this.BMRGBAColor.RGBAString;
769
+ },
770
+
771
+ /**
772
+ * The RGB representation of this color. The alpha component of this color is ignored in this representation.
773
+ */
774
+ get RGBString() { // <String>
775
+ return this.BMRGBAColor.RGBString;
776
+ },
777
+
778
+ /**
779
+ * The hex representation of this color. The alpha component of this color is ignored in this representation.
780
+ */
781
+ get hexString() { // <String>
782
+ return this.BMRGBAColor.hexString;
783
+ },
784
+
785
+ /**
786
+ * The HSLA representation of this color.
787
+ */
788
+ get HSLAString() { // <String>
789
+ return 'hsl(' + this._hue + ',' + this._saturation + '%,' + this._luminosity + '%,' + this._alpha + ')';
790
+ },
791
+
792
+ /**
793
+ * The HSL representation of this color. The alpha component of this color is ignored in this representation.
794
+ */
795
+ get HSLString() { // <String>
796
+ return 'hsl(' + this._hue + ',' + this._saturation + '%,' + this._luminosity + '%)';
797
+ },
798
+
799
+ /**
800
+ * Creates and returns a copy of this RGBA color.
801
+ * @return <BMColor> A color.
802
+ */
803
+ copy: function () {
804
+ var color = new _BMRGBAColor();
805
+
806
+ color._hue = this._hue;
807
+ color._saturation = this._saturation;
808
+ color._luminosity = this._luminosity;
809
+ color._alpha = this._alpha;
810
+
811
+ return color;
812
+
813
+ }
814
+
815
+ };
816
+
817
+ function _BMHueToRGB(p, q, t) {
818
+ if (t < 0) {
819
+ t += 1;
820
+ }
821
+ if (t > 1) {
822
+ t -= 1;
823
+ }
824
+ if (t < 1/6) {
825
+ return p + (q - p) * 6 * t;
826
+ }
827
+ if (t < 1/2) {
828
+ return q;
829
+ }
830
+ if (t < 2/3) {
831
+ return p + (q - p) * (2/3 - t) * 6;
832
+ }
833
+
834
+ return p;
835
+ }
836
+
837
+
838
+
839
+ // A JSON object containing all the color keywords with their hex values.
840
+ var _BMColorKeywords = { // <Object<String, String>>
841
+ "aliceblue": "#f0f8ff",
842
+ "antiquewhite": "#faebd7",
843
+ "aqua": "#00ffff",
844
+ "aquamarine": "#7fffd4",
845
+ "azure": "#f0ffff",
846
+ "beige": "#f5f5dc",
847
+ "bisque": "#ffe4c4",
848
+ "black": "#000000",
849
+ "blanchedalmond": "#ffebcd",
850
+ "blue": "#0000ff",
851
+ "blueviolet": "#8a2be2",
852
+ "brown": "#a52a2a",
853
+ "burlywood": "#deb887",
854
+ "cadetblue": "#5f9ea0",
855
+ "chartreuse": "#7fff00",
856
+ "chocolate": "#d2691e",
857
+ "coral": "#ff7f50",
858
+ "cornflowerblue": "#6495ed",
859
+ "cornsilk": "#fff8dc",
860
+ "crimson": "#dc143c",
861
+ "cyan": "#00ffff",
862
+ "darkblue": "#00008b",
863
+ "darkcyan": "#008b8b",
864
+ "darkgoldenrod": "#b8860b",
865
+ "darkgray": "#a9a9a9",
866
+ "darkgreen": "#006400",
867
+ "darkgrey": "#a9a9a9",
868
+ "darkkhaki": "#bdb76b",
869
+ "darkmagenta": "#8b008b",
870
+ "darkolivegreen": "#556b2f",
871
+ "darkorange": "#ff8c00",
872
+ "darkorchid": "#9932cc",
873
+ "darkred": "#8b0000",
874
+ "darksalmon": "#e9967a",
875
+ "darkseagreen": "#8fbc8f",
876
+ "darkslateblue": "#483d8b",
877
+ "darkslategray": "#2f4f4f",
878
+ "darkslategrey": "#2f4f4f",
879
+ "darkturquoise": "#00ced1",
880
+ "darkviolet": "#9400d3",
881
+ "deeppink": "#ff1493",
882
+ "deepskyblue": "#00bfff",
883
+ "dimgray": "#696969",
884
+ "dimgrey": "#696969",
885
+ "dodgerblue": "#1e90ff",
886
+ "firebrick": "#b22222",
887
+ "floralwhite": "#fffaf0",
888
+ "forestgreen": "#228b22",
889
+ "fuchsia": "#ff00ff",
890
+ "gainsboro": "#dcdcdc",
891
+ "ghostwhite": "#f8f8ff",
892
+ "gold": "#ffd700",
893
+ "goldenrod": "#daa520",
894
+ "gray": "#808080",
895
+ "green": "#008000",
896
+ "greenyellow": "#adff2f",
897
+ "grey": "#808080",
898
+ "honeydew": "#f0fff0",
899
+ "hotpink": "#ff69b4",
900
+ "indianred": "#cd5c5c",
901
+ "indigo": "#4b0082",
902
+ "ivory": "#fffff0",
903
+ "khaki": "#f0e68c",
904
+ "lavender": "#e6e6fa",
905
+ "lavenderblush": "#fff0f5",
906
+ "lawngreen": "#7cfc00",
907
+ "lemonchiffon": "#fffacd",
908
+ "lightblue": "#add8e6",
909
+ "lightcoral": "#f08080",
910
+ "lightcyan": "#e0ffff",
911
+ "lightgoldenrodyellow": "#fafad2",
912
+ "lightgray": "#d3d3d3",
913
+ "lightgreen": "#90ee90",
914
+ "lightgrey": "#d3d3d3",
915
+ "lightpink": "#ffb6c1",
916
+ "lightsalmon": "#ffa07a",
917
+ "lightseagreen": "#20b2aa",
918
+ "lightskyblue": "#87cefa",
919
+ "lightslategray": "#778899",
920
+ "lightslategrey": "#778899",
921
+ "lightsteelblue": "#b0c4de",
922
+ "lightyellow": "#ffffe0",
923
+ "lime": "#00ff00",
924
+ "limegreen": "#32cd32",
925
+ "linen": "#faf0e6",
926
+ "magenta": "#ff00ff",
927
+ "maroon": "#800000",
928
+ "mediumaquamarine": "#66cdaa",
929
+ "mediumblue": "#0000cd",
930
+ "mediumorchid": "#ba55d3",
931
+ "mediumpurple": "#9370db",
932
+ "mediumseagreen": "#3cb371",
933
+ "mediumslateblue": "#7b68ee",
934
+ "mediumspringgreen": "#00fa9a",
935
+ "mediumturquoise": "#48d1cc",
936
+ "mediumvioletred": "#c71585",
937
+ "midnightblue": "#191970",
938
+ "mintcream": "#f5fffa",
939
+ "mistyrose": "#ffe4e1",
940
+ "moccasin": "#ffe4b5",
941
+ "navajowhite": "#ffdead",
942
+ "navy": "#000080",
943
+ "oldlace": "#fdf5e6",
944
+ "olive": "#808000",
945
+ "olivedrab": "#6b8e23",
946
+ "orange": "#ffa500",
947
+ "orangered": "#ff4500",
948
+ "orchid": "#da70d6",
949
+ "palegoldenrod": "#eee8aa",
950
+ "palegreen": "#98fb98",
951
+ "paleturquoise": "#afeeee",
952
+ "palevioletred": "#db7093",
953
+ "papayawhip": "#ffefd5",
954
+ "peachpuff": "#ffdab9",
955
+ "peru": "#cd853f",
956
+ "pink": "#ffc0cb",
957
+ "plum": "#dda0dd",
958
+ "powderblue": "#b0e0e6",
959
+ "purple": "#800080",
960
+ "rebeccapurple": "#663399",
961
+ "red": "#ff0000",
962
+ "rosybrown": "#bc8f8f",
963
+ "royalblue": "#4169e1",
964
+ "saddlebrown": "#8b4513",
965
+ "salmon": "#fa8072",
966
+ "sandybrown": "#f4a460",
967
+ "seagreen": "#2e8b57",
968
+ "seashell": "#fff5ee",
969
+ "sienna": "#a0522d",
970
+ "silver": "#c0c0c0",
971
+ "skyblue": "#87ceeb",
972
+ "slateblue": "#6a5acd",
973
+ "slategray": "#708090",
974
+ "slategrey": "#708090",
975
+ "snow": "#fffafa",
976
+ "springgreen": "#00ff7f",
977
+ "steelblue": "#4682b4",
978
+ "tan": "#d2b48c",
979
+ "teal": "#008080",
980
+ "thistle": "#d8bfd8",
981
+ "tomato": "#ff6347",
982
+ "turquoise": "#40e0d0",
983
+ "violet": "#ee82ee",
984
+ "wheat": "#f5deb3",
985
+ "white": "#ffffff",
986
+ "whitesmoke": "#f5f5f5",
987
+ "yellow": "#ffff00",
988
+ "yellowgreen": "#9acd32"
989
+ };
990
+
991
+ // @endtype