refactor: Use Dylex7x13 font for calculator UI
This commit is contained in:
@@ -8,11 +8,11 @@
|
||||
*/
|
||||
|
||||
g.clear();
|
||||
require("Font7x11Numeric7Seg").add(Graphics);
|
||||
require("FontDylex7x13").add(Graphics);
|
||||
|
||||
var DEFAULT_SELECTION_NUMBERS = '5';
|
||||
var RESULT_HEIGHT = 40;
|
||||
var RESULT_MAX_LEN = Math.floor((g.getWidth() - 20) / 14);
|
||||
var RESULT_MAX_LEN = Math.floor((g.getWidth() - 20) / 16);
|
||||
var COLORS = {
|
||||
// [normal, selected]
|
||||
DEFAULT: ['#7F8183', '#A6A6A7'],
|
||||
@@ -112,7 +112,7 @@ function prepareScreen(screen, grid, defaultColor) {
|
||||
function drawKey(name, k, selected) {
|
||||
var color = k.color || COLORS.DEFAULT;
|
||||
g.setColor(color[selected ? 1 : 0]);
|
||||
g.setFont('Vector', 20).setFontAlign(0,0);
|
||||
g.setFont('Dylex7x13', 2).setFontAlign(0,0);
|
||||
g.fillRect(k.xy[0], k.xy[1], k.xy[2], k.xy[3]);
|
||||
g.setColor(0);
|
||||
g.drawString(k.val || name, (k.xy[0] + k.xy[2])/2, (k.xy[1] + k.xy[3])/2);
|
||||
@@ -235,7 +235,7 @@ function displayOutput(num) {
|
||||
operator = null;
|
||||
specials.R.val = 'AC';
|
||||
if (!swipeEnabled) drawKey('R', specials.R);
|
||||
g.setFont('Vector', 22);
|
||||
g.setFont('Dylex7x13', 2);
|
||||
} else {
|
||||
// might not be a number due to display of dot "."
|
||||
var numNumeric = Number(num);
|
||||
@@ -269,7 +269,7 @@ function displayOutput(num) {
|
||||
if (num.charAt(0) === '-') {
|
||||
num = '- ' + num.substr(1);
|
||||
}
|
||||
g.setFont('7x11Numeric7Seg', 2);
|
||||
g.setFont('Dylex7x13', 2);
|
||||
if (num.length > RESULT_MAX_LEN) {
|
||||
if (num.indexOf("E") < 0)
|
||||
num = num.substr(0, RESULT_MAX_LEN - 1)+'...';
|
||||
@@ -278,7 +278,7 @@ function displayOutput(num) {
|
||||
g.setFontAlign(1,0);
|
||||
g.drawString(num, g.getWidth()-20, RESULT_HEIGHT/2);
|
||||
if (operator) {
|
||||
g.setFont('Vector', 22).setFontAlign(1,0);
|
||||
g.setFont('Dylex7x13', 2).setFontAlign(1,0);
|
||||
g.drawString(operator, g.getWidth()-1, RESULT_HEIGHT/2);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user