A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
add func for getting dark/light shades of a color
ammarahm-ed9792a24a666f
diff --git a/apps/mobile/src/utils/utils.js b/apps/mobile/src/utils/utils.jsindex 7768eb1d4..3595eaddd 100755--- a/apps/mobile/src/utils/utils.js+++ b/apps/mobile/src/utils/utils.js@@ -202,7 +202,15 @@ const getAlphafloat = (a, alpha) => {return 1;};++ const rgbRes = {+ color:'',+ result:''+ }+export const hexToRGBA = (hex, alpha) => {+ if (rgbRes.color === hex)+ return rgbRes.resultif (!isValidHex(hex)) {throw new Error('Invalid HEX');}@@ -211,3 +219,38 @@ export const hexToRGBA = (hex, alpha) => {const [r, g, b, a] = hexArr.map(convertHexUnitTo256);return `rgba(${r}, ${g}, ${b}, ${getAlphafloat(a, alpha)})`;};++++export const shadeBlendConvert = function (p, from, to) {++ if(typeof(p)!="number"||p<-1||p>1||typeof(from)!="string"||(from[0]!='r'&&from[0]!='#')||(to&&typeof(to)!="string"))return null; //ErrorCheck+ if(!this.sbcRip)this.sbcRip=(d)=>{+ let l=d.length,RGB={};+ if(l>9){+ d=d.split(",");+ if(d.length<3||d.length>4)return null;//ErrorCheck+ RGB[0]=i(d[0].split("(")[1]),RGB[1]=i(d[1]),RGB[2]=i(d[2]),RGB[3]=d[3]?parseFloat(d[3]):-1;+ }else{+ if(l==8||l==6||l<4)return null; //ErrorCheck+ if(l<6)d="#"+d[1]+d[1]+d[2]+d[2]+d[3]+d[3]+(l>4?d[4]+""+d[4]:""); //3 or 4 digit+ d=i(d.slice(1),16),RGB[0]=d>>16&255,RGB[1]=d>>8&255,RGB[2]=d&255,RGB[3]=-1;+ if(l==9||l==5)RGB[3]=r((RGB[2]/255)*10000)/10000,RGB[2]=RGB[1],RGB[1]=RGB[0],RGB[0]=d>>24&255;+ }return RGB;}+ var i=parseInt,r=Math.round,h=from.length>9,h=typeof(to)=="string"?to.length>9?true:to=="c"?!h:false:h,b=p<0,p=b?p*-1:p,to=to&&to!="c"?to:b?"#000000":"#FFFFFF",f=this.sbcRip(from),t=this.sbcRip(to);+ if(!f||!t)return null; //ErrorCheck+ if(h)return "rgb"+(f[3]>-1||t[3]>-1?"a(":"(")+r((t[0]-f[0])*p+f[0])+","+r((t[1]-f[1])*p+f[1])+","+r((t[2]-f[2])*p+f[2])+(f[3]<0&&t[3]<0?")":","+(f[3]>-1&&t[3]>-1?r(((t[3]-f[3])*p+f[3])*10000)/10000:t[3]<0?f[3]:t[3])+")");+ else return "#"+(0x100000000+r((t[0]-f[0])*p+f[0])*0x1000000+r((t[1]-f[1])*p+f[1])*0x10000+r((t[2]-f[2])*p+f[2])*0x100+(f[3]>-1&&t[3]>-1?r(((t[3]-f[3])*p+f[3])*255):t[3]>-1?r(t[3]*255):f[3]>-1?r(f[3]*255):255)).toString(16).slice(1,f[3]>-1||t[3]>-1?undefined:-2);+}++const shadeRes = {+ color:'',+ alpha:0,+ result:''+}+export const RGB_Linear_Shade=(p,c)=>{+ if (shadeRes.color === c && shadeRes.alpha === p)+ return shadeRes.result;+ var i=parseInt,r=Math.round,[a,b,c,d]=c.split(","),P=p<0,t=P?0:255*p,P=P?1+p:1-p;+ return"rgb"+(d?"a(":"(")+r(i(a[3]=="a"?a.slice(5):a.slice(4))*P+t)+","+r(i(b)*P+t)+","+r(i(c)*P+t)+(d?","+d:")");+}