You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi there,
I have been working on an extension that analyses eight samples along the edge of the canvas and extracts the most frequently used color, excluding white. I am trying to extend uploaded brand logos in case they have a colored background and cannot be scaled.
Maybe this concept could spark a new feature idea for the vue-croppa plugin?
Cheers, Jonas
methods: {onDraw: function(ctx){//https://bit.ly/2Zf1lth//get canvas dimensionslet{ width, height }=ctx.canvas;//define sample spotsletsampleSpots=[[0,0],[width*0.5,0],[width-1,0],[width-1,height*0.5],[width-1,height-1],[width*0.5,height-1],[0,height-1],[0,height*0.5]];//get samplesletsamples=[];letsamplesHex=[];for(leti=0;i<sampleSpots.length;i++){//console.log("sample:", i, sampleSpots[i][0]);letpx=ctx.getImageData(sampleSpots[i][0],//xsampleSpots[i][1],//y1,//w1//h).data;samples[i]=px;samplesHex[i]="#"+("000000"+this.rgbToHex(px[0],px[1],px[2])).slice(-6);}// console.log("sH:", samplesHex);// console.log("mode:", this.mode(samplesHex));//filter White samples from ArrayletsamplesHexColor=samplesHex.filter(e=>e!=="#ffffff");// console.log("sHColor:", samplesHexColor);// console.log("mode:", this.mode(samplesHexColor));this.canvasColor=this.mode(samplesHexColor);},//https://bit.ly/2Zf1lthrgbToHex: function(r,g,b){if(r>255||g>255||b>255)throw"Invalid color component";return((r<<16)|(g<<8)|b).toString(16);},//https://bit.ly/2WwF2NKmode: function(arr){returnarr.sort((a,b)=>arr.filter(v=>v===a).length-arr.filter(v=>v===b).length).pop();}}`
The text was updated successfully, but these errors were encountered:
Hi there,
I have been working on an extension that analyses eight samples along the edge of the canvas and extracts the most frequently used color, excluding white. I am trying to extend uploaded brand logos in case they have a colored background and cannot be scaled.
Maybe this concept could spark a new feature idea for the vue-croppa plugin?
Cheers, Jonas
The text was updated successfully, but these errors were encountered: