I have a code:
function draw(ctx) { // create new image object to use as pattern var img = new Image(); img.onload = function(){ // create pattern
In response to the accepted answer: rather than undo the offset, I would use save() & restore() to avoid potential problems:
save()
restore()
ctx.save(); ctx.translate(offset_x, offset_y); ctx.fillRect(-offset_x, -offset_y, fill_x, fill_y); ctx.restore();