q5 2.9.22 → 2.9.23

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 (69) hide show
  1. package/.vscode/launch.json +26 -0
  2. package/bun.lockb +0 -0
  3. package/p5-tests/js/chai_helpers.js +20 -0
  4. package/p5-tests/js/mocha_setup.js +2 -0
  5. package/p5-tests/js/modernizr.js +5 -0
  6. package/p5-tests/js/p5_helpers.js +135 -0
  7. package/p5-tests/js/sinon.js +5949 -0
  8. package/p5-tests/mocha.css +289 -0
  9. package/p5-tests/test.html +71 -0
  10. package/p5-tests/unit/color/color_conversion.js +68 -0
  11. package/p5-tests/unit/color/creating_reading.js +217 -0
  12. package/p5-tests/unit/color/p5.Color.js +1000 -0
  13. package/p5-tests/unit/color/setting.js +289 -0
  14. package/p5-tests/unit/core/2d_primitives.js +490 -0
  15. package/p5-tests/unit/core/attributes.js +115 -0
  16. package/p5-tests/unit/core/curves.js +139 -0
  17. package/p5-tests/unit/core/environment.js +248 -0
  18. package/p5-tests/unit/core/error_helpers.js +1158 -0
  19. package/p5-tests/unit/core/main.js +340 -0
  20. package/p5-tests/unit/core/p5.Element.js +773 -0
  21. package/p5-tests/unit/core/p5.Graphics.js +179 -0
  22. package/p5-tests/unit/core/preload.js +285 -0
  23. package/p5-tests/unit/core/rendering.js +116 -0
  24. package/p5-tests/unit/core/structure.js +293 -0
  25. package/p5-tests/unit/core/transform.js +144 -0
  26. package/p5-tests/unit/core/version.js +28 -0
  27. package/p5-tests/unit/core/vertex.js +137 -0
  28. package/p5-tests/unit/dom/dom.js +2146 -0
  29. package/p5-tests/unit/events/acceleration.js +213 -0
  30. package/p5-tests/unit/events/keyboard.js +179 -0
  31. package/p5-tests/unit/events/mouse.js +487 -0
  32. package/p5-tests/unit/events/touch.js +180 -0
  33. package/p5-tests/unit/image/downloading.js +379 -0
  34. package/p5-tests/unit/image/filters.js +92 -0
  35. package/p5-tests/unit/image/loading.js +413 -0
  36. package/p5-tests/unit/image/p5.Image.js +201 -0
  37. package/p5-tests/unit/image/pixels.js +234 -0
  38. package/p5-tests/unit/io/files.js +378 -0
  39. package/p5-tests/unit/io/loadBytes.js +149 -0
  40. package/p5-tests/unit/io/loadImage.js +123 -0
  41. package/p5-tests/unit/io/loadJSON.js +185 -0
  42. package/p5-tests/unit/io/loadModel.js +215 -0
  43. package/p5-tests/unit/io/loadShader.js +176 -0
  44. package/p5-tests/unit/io/loadStrings.js +140 -0
  45. package/p5-tests/unit/io/loadTable.js +183 -0
  46. package/p5-tests/unit/io/loadXML.js +127 -0
  47. package/p5-tests/unit/io/saveModel.js +113 -0
  48. package/p5-tests/unit/io/saveTable.js +142 -0
  49. package/p5-tests/unit/math/calculation.js +452 -0
  50. package/p5-tests/unit/math/noise.js +66 -0
  51. package/p5-tests/unit/math/p5.Vector.js +1886 -0
  52. package/p5-tests/unit/math/random.js +177 -0
  53. package/p5-tests/unit/math/trigonometry.js +144 -0
  54. package/p5-tests/unit/spec.js +50 -0
  55. package/p5-tests/unit/typography/attributes.js +120 -0
  56. package/p5-tests/unit/typography/loadFont.js +162 -0
  57. package/p5-tests/unit/typography/p5.Font.js +63 -0
  58. package/p5-tests/unit/utilities/conversion.js +329 -0
  59. package/p5-tests/unit/utilities/time_date.js +133 -0
  60. package/package.json +1 -1
  61. package/q5.js +48 -37
  62. package/q5.min.js +1 -1
  63. package/src/q5-2d-image.js +3 -1
  64. package/src/q5-core.js +3 -1
  65. package/src/q5-math.js +1 -0
  66. package/src/q5-webgpu-canvas.js +8 -7
  67. package/src/q5-webgpu-drawing.js +15 -12
  68. package/src/q5-webgpu-image.js +1 -1
  69. package/src/q5-webgpu-text.js +17 -15
@@ -0,0 +1,289 @@
1
+ @charset "utf-8";
2
+
3
+ body {
4
+ margin: 0;
5
+ background-color: #111;
6
+ color: #fff;
7
+ }
8
+
9
+ #mocha {
10
+ font: 20px/1.5 "Helvetica Neue", Helvetica, Arial, sans-serif;
11
+ margin: 60px 50px;
12
+ }
13
+
14
+ #mocha ul,
15
+ #mocha li {
16
+ margin: 0;
17
+ padding: 0;
18
+ }
19
+
20
+ #mocha ul {
21
+ list-style: none;
22
+ }
23
+
24
+ #mocha h1,
25
+ #mocha h2 {
26
+ margin: 0;
27
+ }
28
+
29
+ #mocha h1 {
30
+ margin-top: 15px;
31
+ font-size: 1em;
32
+ font-weight: 200;
33
+ }
34
+
35
+ #mocha h1 a {
36
+ text-decoration: none;
37
+ color: inherit;
38
+ }
39
+
40
+ #mocha h1 a:hover {
41
+ text-decoration: underline;
42
+ }
43
+
44
+ #mocha .suite .suite h1 {
45
+ margin-top: 0;
46
+ font-size: .8em;
47
+ }
48
+
49
+ #mocha .hidden {
50
+ display: none;
51
+ }
52
+
53
+ #mocha h2 {
54
+ font-size: 12px;
55
+ font-weight: normal;
56
+ cursor: pointer;
57
+ }
58
+
59
+ #mocha .suite {
60
+ margin-left: 15px;
61
+ }
62
+
63
+ #mocha .test {
64
+ margin-left: 15px;
65
+ overflow: hidden;
66
+ }
67
+
68
+ #mocha .test.pending:hover h2::after {
69
+ content: '(pending)';
70
+ font-family: arial, sans-serif;
71
+ }
72
+
73
+ #mocha .test.pass.medium .duration {
74
+ background: #c09853;
75
+ }
76
+
77
+ #mocha .test.pass.slow .duration {
78
+ background: #b94a48;
79
+ }
80
+
81
+ #mocha .test.pass::before {
82
+ content: '✓';
83
+ font-size: 12px;
84
+ display: block;
85
+ float: left;
86
+ margin-right: 5px;
87
+ color: #00d6b2;
88
+ }
89
+
90
+ #mocha .test.pass .duration {
91
+ font-size: 9px;
92
+ margin-left: 5px;
93
+ padding: 2px 5px;
94
+ color: #fff;
95
+ -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, .2);
96
+ -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, .2);
97
+ box-shadow: inset 0 1px 1px rgba(0, 0, 0, .2);
98
+ -webkit-border-radius: 5px;
99
+ -moz-border-radius: 5px;
100
+ -ms-border-radius: 5px;
101
+ -o-border-radius: 5px;
102
+ border-radius: 5px;
103
+ }
104
+
105
+ #mocha .test.pass.fast .duration {
106
+ display: none;
107
+ }
108
+
109
+ #mocha .test.pending {
110
+ color: #0b97c4;
111
+ }
112
+
113
+ #mocha .test.pending::before {
114
+ content: '◦';
115
+ color: #0b97c4;
116
+ }
117
+
118
+ #mocha .test.fail {
119
+ color: #c00;
120
+ }
121
+
122
+ #mocha .test.fail pre {
123
+ color: black;
124
+ }
125
+
126
+ #mocha .test.fail::before {
127
+ content: '✖';
128
+ font-size: 12px;
129
+ display: block;
130
+ float: left;
131
+ margin-right: 5px;
132
+ color: #c00;
133
+ }
134
+
135
+ #mocha .test pre.error {
136
+ color: #c00;
137
+ max-height: 300px;
138
+ overflow: auto;
139
+ }
140
+
141
+ /**
142
+ * (1): approximate for browsers not supporting calc
143
+ * (2): 42 = 2*15 + 2*10 + 2*1 (padding + margin + border)
144
+ * ^^ seriously
145
+ */
146
+ #mocha .test pre {
147
+ display: block;
148
+ float: left;
149
+ clear: left;
150
+ font: 12px/1.5 monaco, monospace;
151
+ margin: 5px;
152
+ padding: 15px;
153
+ border: 1px solid #eee;
154
+ max-width: 85%;
155
+ /*(1)*/
156
+ max-width: calc(100% - 42px);
157
+ /*(2)*/
158
+ word-wrap: break-word;
159
+ border-bottom-color: #ddd;
160
+ -webkit-border-radius: 3px;
161
+ -webkit-box-shadow: 0 1px 3px #eee;
162
+ -moz-border-radius: 3px;
163
+ -moz-box-shadow: 0 1px 3px #eee;
164
+ border-radius: 3px;
165
+ }
166
+
167
+ #mocha .test h2 {
168
+ position: relative;
169
+ }
170
+
171
+ #mocha .test a.replay {
172
+ position: absolute;
173
+ top: 3px;
174
+ right: 0;
175
+ text-decoration: none;
176
+ vertical-align: middle;
177
+ display: block;
178
+ width: 15px;
179
+ height: 15px;
180
+ line-height: 15px;
181
+ text-align: center;
182
+ background: #eee;
183
+ font-size: 15px;
184
+ -moz-border-radius: 15px;
185
+ border-radius: 15px;
186
+ -webkit-transition: opacity 200ms;
187
+ -moz-transition: opacity 200ms;
188
+ transition: opacity 200ms;
189
+ opacity: 0.3;
190
+ color: #888;
191
+ }
192
+
193
+ #mocha .test:hover a.replay {
194
+ opacity: 1;
195
+ }
196
+
197
+ #mocha-report.pass .test.fail {
198
+ display: none;
199
+ }
200
+
201
+ #mocha-report.fail .test.pass {
202
+ display: none;
203
+ }
204
+
205
+ #mocha-report.pending .test.pass,
206
+ #mocha-report.pending .test.fail {
207
+ display: none;
208
+ }
209
+
210
+ #mocha-report.pending .test.pass.pending {
211
+ display: block;
212
+ }
213
+
214
+ #mocha-error {
215
+ color: #c00;
216
+ font-size: 1.5em;
217
+ font-weight: 100;
218
+ letter-spacing: 1px;
219
+ }
220
+
221
+ #mocha-stats {
222
+ position: fixed;
223
+ top: 15px;
224
+ right: 10px;
225
+ font-size: 12px;
226
+ margin: 0;
227
+ color: #888;
228
+ z-index: 1;
229
+ }
230
+
231
+ #mocha-stats .progress {
232
+ float: right;
233
+ padding-top: 0;
234
+ }
235
+
236
+ #mocha-stats em {
237
+ color: black;
238
+ }
239
+
240
+ #mocha-stats a {
241
+ text-decoration: none;
242
+ color: inherit;
243
+ }
244
+
245
+ #mocha-stats a:hover {
246
+ border-bottom: 1px solid #eee;
247
+ }
248
+
249
+ #mocha-stats li {
250
+ display: inline-block;
251
+ margin: 0 5px;
252
+ list-style: none;
253
+ padding-top: 11px;
254
+ }
255
+
256
+ #mocha-stats canvas {
257
+ width: 40px;
258
+ height: 40px;
259
+ }
260
+
261
+ #mocha code .comment {
262
+ color: #ddd;
263
+ }
264
+
265
+ #mocha code .init {
266
+ color: #2f6fad;
267
+ }
268
+
269
+ #mocha code .string {
270
+ color: #5890ad;
271
+ }
272
+
273
+ #mocha code .keyword {
274
+ color: #8a6343;
275
+ }
276
+
277
+ #mocha code .number {
278
+ color: #2f6fad;
279
+ }
280
+
281
+ @media screen and (max-device-width: 480px) {
282
+ #mocha {
283
+ margin: 60px 0px;
284
+ }
285
+
286
+ #mocha #stats {
287
+ position: absolute;
288
+ }
289
+ }
@@ -0,0 +1,71 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+
4
+ <head>
5
+ <meta http-equiv="Content-type" content="text/html; charset=utf-8">
6
+ <link rel="stylesheet" href="mocha.css" />
7
+ </head>
8
+
9
+ <body>
10
+ <!-- Required for browser reporter -->
11
+ <div id="mocha"></div>
12
+
13
+ <!-- mocha -->
14
+ <script src="../node_modules/mocha/mocha.js"></script>
15
+ <script src="js/mocha_setup.js"></script>
16
+
17
+ <!-- Include your assertion lib of choice -->
18
+ <script src="../node_modules/chai/chai.js"></script>
19
+ <script src="js/sinon.js"></script>
20
+ <script src="js/modernizr.js"></script>
21
+ <script src="js/chai_helpers.js"></script>
22
+ <script src="js/p5_helpers.js"></script>
23
+
24
+ <!-- Include anything you want to test -->
25
+ <script src="../q5.js"></script>
26
+
27
+ <!-- Spec files (Now centralized in unit/spec.js) -->
28
+ <script src="unit/spec.js"></script>
29
+
30
+ <!-- run mocha -->
31
+ <script>
32
+ p5._throwValidationErrors = true;
33
+
34
+ window.addEventListener('load', function () {
35
+ var runner = mocha.run();
36
+
37
+ // NOTE: Sauce Labs removed, keeping these for now
38
+ // This exposes our test results to Sauce Labs. For more
39
+ // details, see: https://github.com/axemclion/grunt-saucelabs.
40
+
41
+ var failedTests = [];
42
+ runner.on('end', function () {
43
+ window.mochaResults = runner.stats;
44
+ window.mochaResults.reports = failedTests;
45
+ });
46
+
47
+ runner.on('fail', logFailure);
48
+
49
+ function logFailure(test, err) {
50
+ var flattenTitles = function (test) {
51
+ var titles = [];
52
+ while (test.parent.title) {
53
+ titles.push(test.parent.title);
54
+ test = test.parent;
55
+ }
56
+ return titles.reverse();
57
+ };
58
+
59
+ failedTests.push({
60
+ name: test.title,
61
+ result: false,
62
+ message: err.message,
63
+ stack: err.stack,
64
+ titles: flattenTitles(test)
65
+ });
66
+ }
67
+ }, false);
68
+ </script>
69
+ </body>
70
+
71
+ </html>
@@ -0,0 +1,68 @@
1
+ suite('color/p5.ColorConversion', function() {
2
+ var rgba = [1, 0, 0.4, 0.8];
3
+ var rgbaWithMaxHue = [1, 0, 0, 0.6];
4
+ var rgbaWithHighLightness = [0.969, 0.753, 0.122, 0.8];
5
+ var hsla = [336 / 360, 1, 0.5, 0.8];
6
+ var hslaWithMaxHue = [1, 1, 0.5, 0.6];
7
+ var hsba = [336 / 360, 1, 1, 0.8];
8
+ var hsbaWithMaxHue = [1, 1, 1, 0.6];
9
+ var accuracy = 0.01;
10
+ var result;
11
+
12
+ suite('rgbaToHSBA', function() {
13
+ test('rgba converts to hsba', function() {
14
+ result = p5.ColorConversion._rgbaToHSBA(rgba);
15
+ assert.arrayApproximately(result, hsba, accuracy);
16
+ });
17
+ });
18
+
19
+ suite('hsbaToRGBA', function() {
20
+ test('hsba converts to rgba', function() {
21
+ result = p5.ColorConversion._hsbaToRGBA(hsba);
22
+ assert.arrayApproximately(result, rgba, accuracy);
23
+ });
24
+
25
+ test('handles maximum hue value', function() {
26
+ result = p5.ColorConversion._hsbaToRGBA(hsbaWithMaxHue);
27
+ assert.arrayApproximately(result, rgbaWithMaxHue, accuracy);
28
+ });
29
+ });
30
+
31
+ suite('hslaToRGBA', function() {
32
+ test('hsla converts to rgba', function() {
33
+ result = p5.ColorConversion._hslaToRGBA(hsla);
34
+ assert.arrayApproximately(result, rgba, accuracy);
35
+ });
36
+
37
+ test('handles maximum hue value', function() {
38
+ result = p5.ColorConversion._hslaToRGBA(hslaWithMaxHue);
39
+ assert.arrayApproximately(result, rgbaWithMaxHue, accuracy);
40
+ });
41
+ });
42
+
43
+ suite('rgbaToHSLA', function() {
44
+ test('rgba converts to hsla (low lightness)', function() {
45
+ result = p5.ColorConversion._rgbaToHSLA(rgba);
46
+ assert.arrayApproximately(result, hsla, accuracy);
47
+ });
48
+
49
+ test('rgba converts to hsla (high lightness)', function() {
50
+ result = p5.ColorConversion._rgbaToHSLA(rgbaWithHighLightness);
51
+ assert.arrayApproximately(result, [0.12, 0.93, 0.55, 0.8], accuracy);
52
+ });
53
+ });
54
+
55
+ suite('hslaToHSBA', function() {
56
+ test('hsla converts to hsba', function() {
57
+ result = p5.ColorConversion._hslaToHSBA(hsla);
58
+ assert.arrayApproximately(result, hsba, accuracy);
59
+ });
60
+ });
61
+
62
+ suite('hsbaToHSLA', function() {
63
+ test('hsba converts to hsla', function() {
64
+ result = p5.ColorConversion._hsbaToHSLA(hsba);
65
+ assert.arrayApproximately(result, hsla, accuracy);
66
+ });
67
+ });
68
+ });
@@ -0,0 +1,217 @@
1
+ suite('color/CreatingReading', function() {
2
+ var myp5;
3
+
4
+ setup(function(done) {
5
+ new p5(function(p) {
6
+ p.setup = function() {
7
+ myp5 = p;
8
+ done();
9
+ };
10
+ });
11
+ });
12
+
13
+ teardown(function() {
14
+ myp5.remove();
15
+ });
16
+
17
+ var fromColor;
18
+ var toColor;
19
+ var c;
20
+ var val;
21
+
22
+ suite('p5.prototype.alpha', function() {
23
+ setup(function() {
24
+ myp5.colorMode(myp5.RGB);
25
+ });
26
+ test('no friendly-err-msg I', function() {
27
+ assert.doesNotThrow(
28
+ function() {
29
+ var string = 'magenta';
30
+ c = myp5.color(string);
31
+ val = myp5.alpha(c);
32
+ assert.approximately(val, 255, 0.01);
33
+ },
34
+ Error,
35
+ 'got unwanted exception'
36
+ );
37
+ });
38
+ test('no friendly-err-msg II', function() {
39
+ assert.doesNotThrow(
40
+ function() {
41
+ c = myp5.color('hsba(160, 100%, 50%, 0.5)');
42
+ val = myp5.alpha(c);
43
+ assert.approximately(val, 127.5, 0.01);
44
+ },
45
+ Error,
46
+ 'got unwanted exception'
47
+ );
48
+ });
49
+ test('wrong param type at #0', function() {
50
+ assert.validationError(function() {
51
+ c = 20;
52
+ val = myp5.alpha(c);
53
+ });
54
+ });
55
+ });
56
+
57
+ suite('p5.prototype.red, green, blue', function() {
58
+ setup(function() {
59
+ myp5.colorMode(myp5.RGB);
60
+ });
61
+ test('red(): no friendly-err-msg', function() {
62
+ assert.doesNotThrow(
63
+ function() {
64
+ c = myp5.color('hsl(126, 100%, 60%)');
65
+ val = myp5.red(c);
66
+ assert.approximately(val, 51, 0.5);
67
+ },
68
+ Error,
69
+ 'got unwanted exception'
70
+ );
71
+ });
72
+ test('green(): no friendly-err-msg', function() {
73
+ assert.doesNotThrow(
74
+ function() {
75
+ c = myp5.color('hsl(126, 100%, 60%)');
76
+ val = myp5.green(c);
77
+ assert.approximately(val, 255, 0.5);
78
+ },
79
+ Error,
80
+ 'got unwanted exception'
81
+ );
82
+ });
83
+ test('blue(): no friendly-err-msg', function() {
84
+ assert.doesNotThrow(
85
+ function() {
86
+ c = myp5.color('hsl(126, 100%, 60%)');
87
+ val = myp5.blue(c);
88
+ assert.approximately(val, 71, 0.5);
89
+ },
90
+ Error,
91
+ 'got unwanted exception'
92
+ );
93
+ });
94
+ });
95
+
96
+ suite('p5.prototype.hue, brightness, lightness, saturation', function() {
97
+ setup(function() {
98
+ myp5.colorMode(myp5.HSL);
99
+ });
100
+ test('hue(): no friendly-err-msg', function() {
101
+ assert.doesNotThrow(
102
+ function() {
103
+ c = myp5.color('#7fffd4');
104
+ val = myp5.hue(c);
105
+ assert.approximately(val, 160, 0.5);
106
+ },
107
+ Error,
108
+ 'got unwanted exception'
109
+ );
110
+ });
111
+ test('brightness(): no friendly-err-msg', function() {
112
+ assert.doesNotThrow(
113
+ function() {
114
+ c = myp5.color('#7fffd4');
115
+ val = myp5.brightness(c);
116
+ assert.approximately(val, 100, 0.5);
117
+ },
118
+ Error,
119
+ 'got unwanted exception'
120
+ );
121
+ });
122
+ test('lightness(): no friendly-err-msg', function() {
123
+ assert.doesNotThrow(
124
+ function() {
125
+ c = myp5.color('#7fffd4');
126
+ val = myp5.lightness(c);
127
+ assert.approximately(val, 75, 0.5);
128
+ },
129
+ Error,
130
+ 'got unwanted exception'
131
+ );
132
+ });
133
+ test('saturation(): no friendly-err-msg', function() {
134
+ assert.doesNotThrow(
135
+ function() {
136
+ c = myp5.color('#7fffd4');
137
+ val = myp5.saturation(c);
138
+ assert.approximately(val, 100, 0.5);
139
+ },
140
+ Error,
141
+ 'got unwanted exception'
142
+ );
143
+ });
144
+ });
145
+
146
+ suite('p5.prototype.lerpColor', function() {
147
+ setup(function() {
148
+ myp5.colorMode(myp5.RGB);
149
+ fromColor = myp5.color(218, 165, 32);
150
+ toColor = myp5.color(72, 61, 139);
151
+ });
152
+ test('should correctly get lerp colors in RGB', function() {
153
+ var interA = myp5.lerpColor(fromColor, toColor, 0.33);
154
+ var interB = myp5.lerpColor(fromColor, toColor, 0.66);
155
+ assert.deepEqual(interA.levels, [170, 131, 67, 255]);
156
+ assert.deepEqual(interB.levels, [122, 96, 103, 255]);
157
+ });
158
+ test('should correctly get lerp colors in HSL', function() {
159
+ myp5.colorMode(myp5.HSL);
160
+ var interA = myp5.lerpColor(fromColor, toColor, 0.33);
161
+ var interB = myp5.lerpColor(fromColor, toColor, 0.66);
162
+ assert.deepEqual(interA.levels, [190, 44, 63, 255]);
163
+ assert.deepEqual(interB.levels, [164, 53, 162, 255]);
164
+ });
165
+ test('should correctly get lerp colors in HSB', function() {
166
+ myp5.colorMode(myp5.HSB);
167
+ var interA = myp5.lerpColor(fromColor, toColor, 0.33);
168
+ var interB = myp5.lerpColor(fromColor, toColor, 0.66);
169
+ assert.deepEqual(interA.levels, [192, 47, 66, 255]);
170
+ assert.deepEqual(interB.levels, [166, 56, 164, 255]);
171
+ });
172
+ test('should not extrapolate', function() {
173
+ var interA = myp5.lerpColor(fromColor, toColor, -0.5);
174
+ var interB = myp5.lerpColor(fromColor, toColor, 1.5);
175
+ assert.deepEqual(interA.levels, [218, 165, 32, 255]);
176
+ assert.deepEqual(interB.levels, [72, 61, 139, 255]);
177
+ });
178
+ test('missing param #2', function() {
179
+ assert.validationError(function() {
180
+ myp5.lerpColor(fromColor, toColor);
181
+ });
182
+ });
183
+ });
184
+ suite('p5.prototype.lerpColor with alpha', function() {
185
+ setup(function() {
186
+ myp5.colorMode(myp5.RGB);
187
+ fromColor = myp5.color(218, 165, 32, 49);
188
+ toColor = myp5.color(72, 61, 139, 200);
189
+ });
190
+ test('should correctly get lerp colors in RGB with alpha', function() {
191
+ var interA = myp5.lerpColor(fromColor, toColor, 0.33);
192
+ var interB = myp5.lerpColor(fromColor, toColor, 0.66);
193
+ assert.deepEqual(interA.levels, [170, 131, 67, 99]);
194
+ assert.deepEqual(interB.levels, [122, 96, 103, 149]);
195
+ });
196
+ test('should correctly get lerp colors in HSL with alpha', function() {
197
+ myp5.colorMode(myp5.HSL);
198
+ var interA = myp5.lerpColor(fromColor, toColor, 0.33);
199
+ var interB = myp5.lerpColor(fromColor, toColor, 0.66);
200
+ assert.deepEqual(interA.levels, [190, 44, 63, 99]);
201
+ assert.deepEqual(interB.levels, [164, 53, 162, 149]);
202
+ });
203
+ test('should correctly get lerp colors in HSB with alpha', function() {
204
+ myp5.colorMode(myp5.HSB);
205
+ var interA = myp5.lerpColor(fromColor, toColor, 0.33);
206
+ var interB = myp5.lerpColor(fromColor, toColor, 0.66);
207
+ assert.deepEqual(interA.levels, [192, 47, 66, 99]);
208
+ assert.deepEqual(interB.levels, [166, 56, 164, 149]);
209
+ });
210
+ test('should not extrapolate', function() {
211
+ var interA = myp5.lerpColor(fromColor, toColor, -0.5);
212
+ var interB = myp5.lerpColor(fromColor, toColor, 1.5);
213
+ assert.deepEqual(interA.levels, [218, 165, 32, 49]);
214
+ assert.deepEqual(interB.levels, [72, 61, 139, 200]);
215
+ });
216
+ });
217
+ });