UNPKG

@progress/kendo-vue-inputs

Version:
9 lines (8 loc) 2.19 kB
/** * @license *------------------------------------------------------------------------------------------- * Copyright © 2025 Progress Software Corporation. All rights reserved. * Licensed under commercial license. See LICENSE.md in the package root for more information *------------------------------------------------------------------------------------------- */ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@progress/kendo-drawing"),r=require("./misc.js"),p=(t,o,n=!1,s=!0)=>{if(["hex","rgba"].indexOf(o)===-1)throw new Error(`Unsupported color output format '${o}'. The available options are 'hex' or 'rgba'.`);if(!r.isPresent(t))return;const e=a.parseColor(t.trim(),s);if(r.isPresent(e))return o==="hex"?g(e,n):e.toCssRgba()},g=(t,o)=>o&&t.a<1?t.toCss({alpha:!0}):t.toCss(),C=(t,o=!0)=>{const n=a.parseColor(t,o);return r.isPresent(n)?n.toHSV():{}},h=(t,o=!0)=>{const n=a.parseColor(t,o);return r.isPresent(n)?n.toBytes():{}},B=t=>{const o=r.fitIntoBounds(t.h,0,359.9),n=r.fitIntoBounds(t.s,0,1),s=r.fitIntoBounds(t.v,0,1),u=r.fitIntoBounds(t.a,0,1);return a.Color.fromHSV(o,n,s,u).toCssRgba()},I=t=>B({h:t,s:1,v:1,a:1}),R=t=>{const o=r.fitIntoBounds(t.r,0,255),n=r.fitIntoBounds(t.g,0,255),s=r.fitIntoBounds(t.b,0,255),u=r.fitIntoBounds(t.a,0,1);return a.Color.fromBytes(o,n,s,u).toCssRgba()},i=(t,o)=>{const n=r.fitIntoBounds(t.r,0,255),s=r.fitIntoBounds(t.g,0,255),u=r.fitIntoBounds(t.b,0,255),e=r.fitIntoBounds(t.a,0,1),l=r.fitIntoBounds(o.r,0,255),f=r.fitIntoBounds(o.g,0,255),m=r.fitIntoBounds(o.b,0,255);return{r:Math.round((1-e)*l+e*n),g:Math.round((1-e)*f+e*s),b:Math.round((1-e)*m+e*u)}},c=t=>{let o=[t.r,t.g,t.b].map(function(n){return n/=255,n<=.03928?n/12.92:Math.pow((n+.055)/1.055,2.4)});return o[0]*.2126+o[1]*.7152+o[2]*.0722},d=(t,o)=>{const n=Math.max(t,o),s=Math.min(t,o);return(n+.05)/(s+.05)},F=(t,o)=>d(c(i(t,o)),c(i(o,{r:0,g:0,b:0,a:1})));exports.getColorFromHSV=B;exports.getColorFromHue=I;exports.getColorFromRGBA=R;exports.getContrast=d;exports.getContrastFromTwoRGBAs=F;exports.getHSV=C;exports.getHexValue=g;exports.getLuminance=c;exports.getRGBA=h;exports.getRGBFromRGBA=i;exports.parseColor=p;