You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
cardGame/public/js/canvas/helpers.js

23 lines
655 B
JavaScript

function printText(text, positionX, positionY, alignment = 'left', baseline = 'alphabetic', style = 'normal', weight = 'normal', size = '10', font = 'Arial', colour = '#000'){
// Save the styling, and content already on the canvas
ctx.save();
// Do the alterations and print the text
context.textAlign = alignment;
context.textBaseline = baseline;
// Set the font styling
ctx.font = style+' '+weight+' '+size+'pt'+' '+font;
//ctx.font-style = fontStyle; // normal, italic, oblique
ctx.fillStyle = colour;
// Actually add the text
ctx.fillText(text, positionX, positionY);
// Restore the prior existing canvas content
ctx.restore();
}