blowfish/node_modules/khroma/dist/methods/rgba.js

20 lines
552 B
JavaScript
Raw Permalink Normal View History

2023-01-29 22:30:24 +00:00
/* IMPORT */
import _ from '../utils/index.js';
import ChannelsReusable from '../channels/reusable.js';
import Color from '../color/index.js';
import change from './change.js';
/* MAIN */
const rgba = (r, g, b = 0, a = 1) => {
if (typeof r !== 'number')
return change(r, { a: g });
const channels = ChannelsReusable.set({
r: _.channel.clamp.r(r),
g: _.channel.clamp.g(g),
b: _.channel.clamp.b(b),
a: _.channel.clamp.a(a)
});
return Color.stringify(channels);
};
/* EXPORT */
export default rgba;