From 7c87efb225f04cc4e63f0054c272b440747e8267 Mon Sep 17 00:00:00 2001 From: Vlad Chernushevich Date: Tue, 25 Jun 2013 14:36:43 +0200 Subject: [PATCH] =?utf8?q?=E2=88=92=20Rename=20text=5Fwidth,=20text=5Fheig?= =?utf8?q?ht=20to=20bubble=5Fwidth,=20bubble=5Fheight=20for=20clarity=20?= =?utf8?q?=E2=88=92=20Add=20comment=20explaining=20bubble=5Fheight=20varia?= =?utf8?q?ble?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- client/assets/src/views/favicon.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/client/assets/src/views/favicon.js b/client/assets/src/views/favicon.js index e5b1237..a741771 100644 --- a/client/assets/src/views/favicon.js +++ b/client/assets/src/views/favicon.js @@ -58,7 +58,7 @@ _kiwi.view.Favicon = Backbone.View.extend({ _drawBubble: function (label, canvas) { var letter_spacing = -1.5, - text_width = 0, text_height = 0, + bubble_width = 0, bubble_height = 0, context = test = canvas.getContext('2d'), canvas_width = canvas.width, canvas_height = canvas.height; @@ -68,17 +68,18 @@ _kiwi.view.Favicon = Backbone.View.extend({ test.textAlign = 'right'; this._renderText(test, label, 0, 0, letter_spacing); - // Calculate text width based on letter spacing and padding - text_width = test.measureText(label).width + letter_spacing * (label.length - 1) + 2; - text_height = 9; + // Calculate bubble width based on letter spacing and padding + bubble_width = test.measureText(label).width + letter_spacing * (label.length - 1) + 2; + // Canvas does not have any way of measuring text height, so we just do it manually and add 1px top/bottom padding + bubble_height = 9; - // Set bubble parameters - bubbleX = canvas_width - text_width; - bubbleY = canvas_height - text_height; + // Set bubble coordinates + bubbleX = canvas_width - bubble_width; + bubbleY = canvas_height - bubble_height; // Draw bubble background context.fillStyle = 'red'; - context.fillRect(bubbleX, bubbleY, text_width, text_height); + context.fillRect(bubbleX, bubbleY, bubble_width, bubble_height); // Draw the text context.fillStyle = 'white'; -- 2.25.1