UNPKG

@progress/kendo-vue-inputs

Version:
9 lines (8 loc) 1.7 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 h=require("vue"),f=require("./utils/svg-calc.js"),g=require("./utils/color-parser.js"),p=4.5,b=7,C=16,m=h.defineComponent({name:"KendoColorContrastSvg",props:{metrics:Object,backgroundColor:String,hsva:Object},render(){const u=function(r,n){if(r.length===0)return"";const o=r.reduce((e,t,s,c)=>s===0?`M ${t[0]},${t[1]}`:`${e} ${n(t,s,c)}`,"");return h.createVNode("path",{d:o,fill:"none",stroke:"white","stroke-width":"1"},null)},i=this.$props.metrics,v=(r,n,o,e,t)=>{const s=(o+e)/2,c=Object.assign({},this.$props.hsva,{s:n/i.width,v:1-s/i.height}),l=g.getContrastFromTwoRGBAs(g.getRGBA(g.getColorFromHSV(c)),g.getRGBA(this.$props.backgroundColor||""));return o+.5>e?l<r+1&&l>r-1?s:null:t(l,r)?v(r,n,o,e-(e-o)/2,t):v(r,n,o+(e-o)/2,e,t)},a=(r,n,o=!1)=>{const e=[];for(let t=0;t<=i.width;t+=i.width/n){const s=v(r,t,0,i.height,o?(c,l)=>c<l:(c,l)=>c>l);s!==null&&e.push([t,s])}return e},d=f.bezierCommand(f.controlPoint(f.line));return h.createVNode("svg",{xmlns:"http://www.w3.org/2000/svg",class:"k-color-contrast-svg",style:{position:"absolute",overflow:"visible",pointerEvents:"none",left:0,top:0,zIndex:3}},[u.call(this,a(p,C),d),u.call(this,a(p,C,!0),d),u.call(this,a(b,C),d),u.call(this,a(b,C,!0),d)])}});exports.ColorContrastSvg=m;