createPattern not returning as expected
-
07-07-2021 - |
Frage
I am getting a TypeError on the variable "pattern" and my script does not execute past the marked break point. I am using the JCanvas and JQuery and all dependencies are in place. What is the reason for the error. There is a similar implementation used here.
function drawMe(thumbUrl){
function drawThumb(){
$("canvas").drawRect({
//Code breaks here.
fillStyle: pattern,
x: 200, y: 100,
width: 250, height: 100,
fromCenter: false
});
}
var pattern = $("canvas").createPattern({
source: thumbUrl,
repeat: "repeat",
load: drawThumb
})
}
drawMe("http://placehold.it/100x100");
Lösung
i think you need to change this
function drawThumb(){
$("canvas").drawRect({
//Code breaks here.
fillStyle: pattern,
x: 200, y: 100,
width: 250, height: 100,
fromCenter: false
});
}
to this
function drawThumb(pattern){
$("canvas").drawRect({
//Code breaks here.
fillStyle: pattern,
x: 200, y: 100,
width: 250, height: 100,
fromCenter: false
});
}
Andere Tipps
I had this problem on Chrome. After restarting chrome it solved me the problem...
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow