Skip to main content
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link

This'll do! :D

var sprite     = new Image(),
    sprite.src = "spritesheet.png",
    texture    = {y: 42, x: 2*14},
    ptrn       = generatePattern(sprite, texture.x, texture.y);
ctx.fillStyle  = ctx.createPattern(ptrn, "repeat");
ctx.fillRect(0, 0, 500, 500);

Thanks to @KeithThomas for linking to http://stackoverflow.com/questions/8761670/multiple-image-patterns-in-2d-context-of-html5-canvashttps://stackoverflow.com/questions/8761670/multiple-image-patterns-in-2d-context-of-html5-canvas

This'll do! :D

var sprite     = new Image(),
    sprite.src = "spritesheet.png",
    texture    = {y: 42, x: 2*14},
    ptrn       = generatePattern(sprite, texture.x, texture.y);
ctx.fillStyle  = ctx.createPattern(ptrn, "repeat");
ctx.fillRect(0, 0, 500, 500);

Thanks to @KeithThomas for linking to http://stackoverflow.com/questions/8761670/multiple-image-patterns-in-2d-context-of-html5-canvas

This'll do! :D

var sprite     = new Image(),
    sprite.src = "spritesheet.png",
    texture    = {y: 42, x: 2*14},
    ptrn       = generatePattern(sprite, texture.x, texture.y);
ctx.fillStyle  = ctx.createPattern(ptrn, "repeat");
ctx.fillRect(0, 0, 500, 500);

Thanks to @KeithThomas for linking to https://stackoverflow.com/questions/8761670/multiple-image-patterns-in-2d-context-of-html5-canvas

Source Link

This'll do! :D

var sprite     = new Image(),
    sprite.src = "spritesheet.png",
    texture    = {y: 42, x: 2*14},
    ptrn       = generatePattern(sprite, texture.x, texture.y);
ctx.fillStyle  = ctx.createPattern(ptrn, "repeat");
ctx.fillRect(0, 0, 500, 500);

Thanks to @KeithThomas for linking to http://stackoverflow.com/questions/8761670/multiple-image-patterns-in-2d-context-of-html5-canvas