Skip to content

Added function to draw text #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand All @@ -38,6 +61,8 @@ var setImageURL = function () {
$saveButton.attr("href", dataURL);
};



//Add canvas to overlay
$overlay.append($canvas);

Expand Down