We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 0492e9e + 5e9d185 commit eb17bd0Copy full SHA for eb17bd0
test/unit/color/p5.Color.js
@@ -780,4 +780,28 @@ suite('p5.Color', function() {
780
assert.deepEqual(c.levels, [100, 100, 100, 70]);
781
});
782
783
+
784
+ suite.only('p5.Color.prototype.toString', function() {
785
+ var colorStr;
786
787
+ setup(function() {
788
+ myp5.colorMode(myp5.RGB, 255, 255, 255, 255);
789
+ c = myp5.color(128, 0, 128, 128);
790
+ colorStr = c.toString();
791
+ });
792
793
+ test('should generate (r,g,b,a) color string with 0-1 normalized alpha', function() {
794
+ // Will not exactly equal 0.5 due to math: test "0.5" substr of
795
+ // 'rgba(128,0,128,0.5...' instead of checking the entire string
796
+ assert.equal(colorStr.substr(15, 3), '0.5');
797
798
799
+ test('should consistently generate the same output', function() {
800
+ assert.equal(colorStr, '' + c);
801
802
803
+ test('should not mutate color levels', function() {
804
+ assert.equal(c.levels, [128, 0, 128, 128]);
805
806
807
0 commit comments