update files

This commit is contained in:
nuintun 2015-12-03 18:06:30 +08:00
parent 242c989a60
commit 50458cb335

View File

@ -2,6 +2,14 @@
* Created by nuintun on 2015/12/3. * Created by nuintun on 2015/12/3.
*/ */
'use strict';
/**
* textRepeat
* @param text
* @param n
* @returns {string}
*/
function textRepeat(text, n){ function textRepeat(text, n){
var str = ''; var str = '';
@ -12,6 +20,11 @@ function textRepeat(text, n){
return str; return str;
} }
/**
* CanvasXTerm
* @param font
* @constructor
*/
function CanvasXTerm(font){ function CanvasXTerm(font){
this.font = font || { family: 'Consolas', lineHeight: 20, size: 13, color: '#fff' }; this.font = font || { family: 'Consolas', lineHeight: 20, size: 13, color: '#fff' };
this.canvas = document.createElement('canvas'); this.canvas = document.createElement('canvas');
@ -20,7 +33,12 @@ function CanvasXTerm(font){
this.baseY = this.font.lineHeight / 2; this.baseY = this.font.lineHeight / 2;
} }
// CanvasXTerm prototype
CanvasXTerm.prototype = { CanvasXTerm.prototype = {
/**
* draw
* @param screen
*/
draw: function (screen){ draw: function (screen){
var text = ''; var text = '';
var width, height; var width, height;
@ -75,6 +93,11 @@ CanvasXTerm.prototype = {
this.drawText(text, x, y, this.getStyles(stylesCache)); this.drawText(text, x, y, this.getStyles(stylesCache));
} }
}, },
/**
* getStyles
* @param node
* @returns {{}}
*/
getStyles: function (node){ getStyles: function (node){
var styles = {}; var styles = {};
@ -98,6 +121,14 @@ CanvasXTerm.prototype = {
return styles; return styles;
}, },
/**
* drawText
* @param text
* @param x
* @param y
* @param styles
* @returns {{x: *, y: *}}
*/
drawText: function (text, x, y, styles){ drawText: function (text, x, y, styles){
var font = (styles.italic ? 'italic ' : 'normal ') var font = (styles.italic ? 'italic ' : 'normal ')
+ (styles.bold ? 'bold ' : 'normal ') + (styles.bold ? 'bold ' : 'normal ')
@ -134,6 +165,12 @@ CanvasXTerm.prototype = {
y: y y: y
}; };
}, },
/**
* measureWidth
* @param text
* @param font
* @returns {Number}
*/
measureWidth: function (text, font){ measureWidth: function (text, font){
this.brush.save(); this.brush.save();