function initWordArt() { $("body").append('
'); $("#svgfont").load("img/font.svg?"); $("#btnWordArtOk").on("onButtonClick",onWordArtOk); $("#btnWordArtCancel").on("onButtonClick",onWordArtCancel); } function showWordArtDialog() { buttonGroupAdd.hide(); showPopup(popupWordArt); $("#txtWordArt").focus(); $("#txtWordArt").val(""); //clear textbox } function onWordArtCancel() { hidePopup(popupWordArt); } function onWordArtOk() { hidePopup(popupWordArt); var s = $("#txtWordArt").val(); if (s!=undefined) { var points = getStringAsPoints(s); var bounds = getBounds(points); var scaleX = (canvasWidth-50) / bounds.width; var scaleY = (canvasHeight-50) / bounds.height; var scale = Math.min(scaleX,scaleY); scalePoints(points,scale); var bounds = getBounds(points); translatePoints(points,-bounds.x,-bounds.y); //left top of text is (0,0) translatePoints(points,-bounds.width/2,-bounds.height/2); //anchor point center translatePoints(points,canvasWidth/2,canvasHeight/2); //center in canvas canvasDrawPoints(canvas,points); } } function getStringAsPoints(text) { var allPoints = []; var xPos = 0; for (var i=0; i