Merge pull request #1249 from derekjan1240/master

fix: rgbaColorToRGBA function output NaN when input with percentage
This commit is contained in:
Anton Lavrenov
2021-12-15 13:47:57 -05:00
committed by GitHub
2 changed files with 36 additions and 1 deletions

View File

@@ -46,6 +46,36 @@ describe('Util', function () {
});
});
it('colorToRGBA() - from color string with percentage to RGBA conversion!', function () {
assert.deepEqual(Konva.Util.colorToRGBA('rgba(50, 100, 150, 0.5)'), {
r: 50,
g: 100,
b: 150,
a: 0.5,
});
assert.deepEqual(Konva.Util.colorToRGBA('rgba(50, 100, 150, 50%)'), {
r: 50,
g: 100,
b: 150,
a: 0.5,
});
assert.deepEqual(Konva.Util.colorToRGBA('rgba(25%, 50%, 100%, 0.5)'), {
r: 63.75,
g: 127.5,
b: 255,
a: 0.5,
});
assert.deepEqual(Konva.Util.colorToRGBA('rgba(0%, 50%, 100%, 100%)'), {
r: 0,
g: 127.5,
b: 255,
a: 1,
});
});
it('make sure Transform is exported', () => {
assert.equal(!!Konva.Transform, true);
});