From 7da906e96c7090bc921c67518a4a4ff623d3d87c Mon Sep 17 00:00:00 2001 From: jremes Date: Fri, 20 Feb 2015 22:29:07 +0000 Subject: [PATCH] Added function to draw text --- js/app.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/js/app.js b/js/app.js index 01cf812..d8f5c49 100755 --- a/js/app.js +++ b/js/app.js @@ -25,6 +25,29 @@ var ctx = $canvas[0].getContext("2d"); var canvasScaleWidth; var canvasScaleHeight; +/** + * Function to "Draw" text on form + * Picks up form element id, returns drawing context of the canvas and fills the text + * + * https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Tutorial/Drawing_text + * + * Usage: drawText("Test", 10, 90) + * + * Enable fonts by, for example, adding to function: ctx.font = "30px Verdana"; + * + * @param {Object} $textInput + * @param {Object} textLocationX + * @param {Object} textLocationY + */ + +var drawText = function($textInput, textLocationX, textLocationY) +{ + c = document.getElementById("formCanvas"); + var ctx = c.getContext("2d"); + ctx.fillText($textInput, textLocationX, textLocationY); +}; + + var canvasRescale = function () { "use strict"; @@ -38,6 +61,8 @@ var setImageURL = function () { $saveButton.attr("href", dataURL); }; + + //Add canvas to overlay $overlay.append($canvas);