2017-02-22 5 views
1

정말 누군가가 도울 수 있기를 바라고 있습니다 ... 나는 Pixastic 라이브러리가로드 중임을 두 배로 확인했습니다. <head> 태그에서Pixastic ColorAdjust 유형 오류 정의되지 않음

: 다음 <body> 태그에서

<script src="pathto.../pixastic.js"></script> 
<script src="pathto.../pixastic.effects.js"></script> 
<script src="pathto.../pixastic.worker.js"></script> 

:

여기
<div id="pattern-div" class=""> 
<div id="preview-background-print"><img id="preview-image" src="/image.png"/></div> 
</div> 

가 jQuery를하다

여기 내 HTML 코드입니다. 관련성이 없어 보이기 때문에 RGB 오프셋을 계산하는 수식을 생략했습니다. 그러나 그들이 사실인지 알려주세요. :)

$('#preview-image').pixastic('coloradjust',{ 
    red : pixadjustR, 
    green : pixadjustG, 
    blue : pixadjustB 
}); 

내가지고있어 오류입니다 :

TypeError: $('#preview-image').pixastic is not a function. (In '$('#preview-image').pixastic('coloradjust',{ 
     red : pixadjustR, 
     green : pixadjustG, 
     blue : pixadjustB 
    })', '$('#preview-image').pixastic' is undefined)` 

(나는 또한 Pixastic.process(document.getElementById("preview-image"), "coloradjust"...을 시도하고 Pixastic.process is not a function

답변

1

당신이 pixastic jquery plugin

포함 했는가 등을 얻을 수 있나요?를 jquery 플러그인을 사용하지 않고이 작업을 수행하려는 경우 다음과 같은 방법으로 작동합니다. demo :

function pixastic(img, method, options){ 
    // Copy image to canvas 
    var canvas = document.createElement('canvas'); 
    canvas.width = img.width; 
    canvas.height = img.height; 
    var ctx = canvas.getContext("2d"); 
    ctx.drawImage(img, 0, 0); 
    // Create Pixastic object and execute filter. 
    // The second parameter is the path to the folder containing the worker script 
    var P = new Pixastic(ctx); 
    P[method](options).done(function(){ 
     // Copy the data back to the image as dataURI 
     img.src = canvas.toDataURL(); 
    }); 
} 
pixastic($('img')[0], "coloradjust", { 
    red : pixadjustR, 
    green : pixadjustG, 
    blue : pixadjustB 
}) 
+0

도움 주셔서 감사합니다. 나는 그것을 포함시켰다. 그리고 궁극적으로 내 문제를 해결했지만, 내가 한 일을 잊어 버렸다는 말은 싫어. 당신이 1,000 가지를 시도하고 그것들 중 하나가 작동하면 (어쨌든 나에게) 일어나는 경향이 있습니다. – NYCjbd