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
As the subject line says, color-thief creates canvas from an image param.
In some cases, I already have canvas created from the image, would be great if I could pass it as-is.
Quick hack - this also allows color-thief to work with image, canvas or video elements:
/* CanvasImage Class Class that wraps the html image/canvas/video element and internal canvas. It also simplifies some of the canvas context manipulation with a set of helper functions.*/constCanvasImage=function(element){if(element.nodeName==='CANVAS'){this.canvas=element;this.context=element.getContext('2d');this.width=element.width;this.height=element.height;}elseif(element.nodeName==='VIDEO'){this.canvas=document.createElement('canvas');this.context=this.canvas.getContext('2d');this.width=this.canvas.width=video.videoWidth;this.height=this.canvas.height=element.videoHeight;this.context.drawImage(element,0,0,this.width,this.height);}else{this.canvas=document.createElement('canvas');this.context=this.canvas.getContext('2d');this.width=this.canvas.width=element.naturalWidth;this.height=this.canvas.height=element.naturalHeight;this.context.drawImage(element,0,0,this.width,this.height);}};
The text was updated successfully, but these errors were encountered:
vladmandic
changed the title
Suggestion: Allow to pass canvas instead of image
Suggestion: Allow to pass video or canvas instead just image element type
Sep 7, 2020
As the subject line says, color-thief creates canvas from an image param.
In some cases, I already have canvas created from the image, would be great if I could pass it as-is.
Quick hack - this also allows color-thief to work with image, canvas or video elements:
#198
The text was updated successfully, but these errors were encountered: