I am trying to render SVG images on a canvas the images are drawn one at a time to fill a given row, below is the code snippet of the same:
function createSVGUrl(svg) {
var svgBlob = new Blob([svg], {type: 'image/svg+xml;charset=utf-8'});
return DOMURL.createObjectURL(svgBlob);
};
/**
* Renders svg tile on the given context.
* @param {CanvasRenderingContext2D} ctx
* @param {SVGElement} svg The svg tile.
* @param {{x: number, y:number}} pos The position to draw the svg tile on.
* @throws Error
*/
function renderSVGTile(ctx, svg, pos) {
var img = new Image();
var url = createSVGUrl(svg);
img.onload = function() {
try {
ctx.drawImage(img, pos.x, pos.y);
ctx.imageSmoothingEnabled = false;
ctx.mozImageSmoothingEnabled = false;
DOMURL.revokeObjectURL(url);
} catch (e) {
throw new Error('Could not render image' + e);
}
};
img.src = url;
};
The problem is that I can see the partially filled rows which I don't want, is there any way to fill the whole row at once?