이 예제가 있습니다
myImage = $('#myImage');
dominantColor = getDominantColor(myImage);
paletteArray = createPalette(myImage, 10); // 2nd argument sets # of colors in palette
기사는 오래된, 그래서 코드가 더 이상 동일하지만, 나는 당신의 예에서 sourceImage
이 경우 myImage
와 동일한 것으로 가정합니다. 데모의 코드에서 또한
:
$('.run-functions-button').on('click', function(event) {
var $this = $(this);
$this.text('...');
var $imageSection = $this.closest('.image-section');
var $colorThiefOutput = $imageSection.find('.color-thief-output');
var $targetimage = $imageSection.find('.target-image');
showColorsForImage($targetimage, $imageSection);
});
.run-functions-button
는 "TAP"노란색 버튼입니다. 그것은 닫는 image-section
및 target-image
내부를 검색합니다. 그런 다음 showColorsForImage($targetImage, $imageSection)
으로 전화합니다.
colorThief.getColor(image)
: showColorsForImage
에서
이 라인이있다. 그래서 저는 Frèdéric이 이미 그의 코멘트에서 지적했듯이 이미지 객체라고 확신합니다.
플러그인의 소스 코드에서 보면 [Image] (https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement) 인스턴스입니다. –
방금 시도했을 수 ... – ZiNNED
그것이 무엇을보고 그것을 시도 했습니까? 물어보기 전에 실험 해보십시오. –