From a4ad7d719835f8bf382706fa4553ae3a8448df48 Mon Sep 17 00:00:00 2001 From: peteruithoven Date: Fri, 10 Jan 2014 13:59:55 +0100 Subject: [PATCH] Cleanup --- Gruntfile.js | 1 + js/AddShapeDialog.js | 76 +++++++++++++++++++++++++++++++++++++++++++ js/Shape.js | 77 -------------------------------------------- less/popup.less | 8 ++--- www/index.html | 12 +++---- 5 files changed, 87 insertions(+), 87 deletions(-) create mode 100644 js/AddShapeDialog.js diff --git a/Gruntfile.js b/Gruntfile.js index ee98f05..dfa8c5e 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -23,6 +23,7 @@ module.exports = function(grunt) { 'js/btnMove.js', 'js/WordArt.js', 'js/Shape.js', + 'js/AddShapeDialog.js', 'js/Svg.js', 'js/Keyboard.js', 'js/SettingsWindow.js', diff --git a/js/AddShapeDialog.js b/js/AddShapeDialog.js new file mode 100644 index 0000000..ad4c84a --- /dev/null +++ b/js/AddShapeDialog.js @@ -0,0 +1,76 @@ +var shapeResolution=3; + +function initShapeDialog() { + $("#btnShapeOk").on("onButtonClick",onShapeOk); + $("#btnShapeCancel").on("onButtonClick",onShapeCancel); + $("#btnShapePlus").on("onButtonHold",onShapePlus); + $("#btnShapeMin").on("onButtonHold",onShapeMin); + updateShapePreview(); +} + +function showShapeDialog() { + showPopup(popupShape); +} + +function onShapeCancel() { + hidePopup(popupShape); +} + +function onShapeOk() { + hidePopup(popupShape); + + var res = shapeResolution; + + if (res!=undefined) { + if (isNaN(res)) res=3; + if (res<2) res=2; + if (res>100) res=100; + drawCircle(canvasWidth/2,canvasHeight/2,80,res); + } +} + +function onShapePlus() { + shapeResolution++; + if (shapeResolution>50) shapeResolution=50; + updateShapePreview(); +} + +function onShapeMin() { + shapeResolution--; + if (shapeResolution<2) shapeResolution=2; + updateShapePreview(); +} + +function updateShapePreview() { + $(".lblShapeResolution").text(shapeResolution + " sides"); + + var canvas = $("#shapePreview")[0]; + var c = canvas.getContext('2d'); + var w = canvas.width; + var h = canvas.height; + console.log(w,h); + var r = w/2 - 20; + var x0 = w/2; + var y0 = h/2; + var res = shapeResolution; + var step = Math.PI * 2.0 / res; + + c.save(); + c.clearRect(0,0,canvas.width, canvas.height); + c.restore(); + c.beginPath(); + for (var a=0; a100) res=100; - drawCircle(canvasWidth/2,canvasHeight/2,80,res); - } -} - -function onShapePlus() { - shapeResolution++; - if (shapeResolution>50) shapeResolution=50; - updateShapePreview(); -} - -function onShapeMin() { - shapeResolution--; - if (shapeResolution<2) shapeResolution=2; - updateShapePreview(); -} - -function updateShapePreview() { - $(".lblShapeResolution").text(shapeResolution + " sides"); - - var canvas = $(".shapePreview")[0]; - var c = canvas.getContext('2d'); - var w = canvas.width; - var h = canvas.height; - console.log(w,h); - var r = w/2 - 20; - var x0 = w/2; - var y0 = h/2; - var res = shapeResolution; - var step = Math.PI * 2.0 / res; - - c.save(); - c.clearRect(0,0,canvas.width, canvas.height); - c.restore(); - c.beginPath(); - for (var a=0; a -
+