summaryrefslogtreecommitdiff
path: root/js/vendor/colorcode.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/vendor/colorcode.js')
-rw-r--r--js/vendor/colorcode.js99
1 files changed, 17 insertions, 82 deletions
diff --git a/js/vendor/colorcode.js b/js/vendor/colorcode.js
index 07f93bf..fe90253 100644
--- a/js/vendor/colorcode.js
+++ b/js/vendor/colorcode.js
@@ -2,14 +2,13 @@
var colorcode = {};
module.exports = colorcode;
colorcode.to_json = require('./src/to_json');
-colorcode.to_ansi = require('./src/to_ansi');
colorcode.from_json = require('./src/from_json');
colorcode.style = require('./src/style');
colorcode.to_canvas = require('./src/canvas');
colorcode.color = require('./src/color');
colorcode.font = require('./src/font');
-},{"./src/canvas":2,"./src/color":3,"./src/font":4,"./src/from_json":8,"./src/style":9,"./src/to_ansi":10,"./src/to_json":11}],2:[function(require,module,exports){
+},{"./src/canvas":2,"./src/color":3,"./src/font":4,"./src/from_json":8,"./src/style":9,"./src/to_json":10}],2:[function(require,module,exports){
var to_json = require('./to_json');
var fontload = require('./font').load;
var style = require('./style');
@@ -41,7 +40,7 @@ var render_colorcode = function(json, canvas, font, opts){
canvas_tmp.width = cw;
canvas_tmp.height = ch;
-
+
canvas.width = json.w * cw;
canvas.height = json.h * ch;
@@ -115,7 +114,7 @@ var to_canvas = function(string_or_json, opts){
module.exports = to_canvas;
-},{"./color":3,"./font":4,"./style":9,"./to_json":11,"canvas":12}],3:[function(require,module,exports){
+},{"./color":3,"./font":4,"./style":9,"./to_json":10,"canvas":11}],3:[function(require,module,exports){
var style = require('./style');
var color = {};
@@ -272,7 +271,7 @@ font.load = function(font_name, callback_fn){
}
-},{"./font/cp437":5,"./font/fixedsys":6,"./style":9,"canvas":12}],5:[function(require,module,exports){
+},{"./font/cp437":5,"./font/fixedsys":6,"./style":9,"canvas":11}],5:[function(require,module,exports){
var cp437s = [[8,8],[8,12],[8,14],[8,16],[10,10],[10,16],[12,12],[16,16]]
var fonts = {};
module.exports = fonts;
@@ -319,12 +318,21 @@ var render_char = function(font, char_value, ctx, ctx_x, ctx_y, char){
if (char.i){ // italic
sheet_y = 1 * font.char_h_sheet + 3
}
- } else if (char_value >= 0x2500 && char_value <= 0x25ff){ // geom
- sheet_x = (char_value - 0x2500) * font.char_w_sheet;
+ } else if (char_value >= 0x80 && char_value <= 0xff){ // latin-1
+ sheet_x = (char_value - 0x80) * font.char_w_sheet;
sheet_y = 2 * font.char_h_sheet + 3
+ } else if (char_value >= 0x0100 && char_value <= 0x017f){ // latin a
+ sheet_x = (char_value - 0x0100) * font.char_w_sheet;
+ sheet_y = 3 * font.char_h_sheet + 3
+ } else if (char_value >= 0x0180 && char_value <= 0x024f){ // latin b
+ sheet_x = (char_value - 0x0180) * font.char_w_sheet;
+ sheet_y = 4 * font.char_h_sheet + 3
+ } else if (char_value >= 0x2500 && char_value <= 0x25ff){ // geom
+ sheet_x = (char_value - 0x2500) * font.char_w_sheet;
+ sheet_y = 5 * font.char_h_sheet + 3
} else if (char_value >= 0x2600 && char_value <= 0x26ff){ // emoji
sheet_x = (char_value - 0x2600) * font.char_w_sheet;
- sheet_y = 3 * font.char_h_sheet + 3
+ sheet_y = 6 * font.char_h_sheet + 3
}
// var sheet_x = (char_value % font.sheet_w_in_chars) * font.char_w
@@ -401,79 +409,6 @@ var style = {};
module.exports = style;
},{}],10:[function(require,module,exports){
-var to_json = require('./to_json')
-var color = require('./color')
-
-var palette = color.palettes.mirc
-
-/**
- * Translates a 255 RGB value to a 0-5 ANSI RGV value,
- * then returns the single ANSI color code to use.
- */
-
-function rgb (r, g, b) {
- var red = Number(r) / 255 * 5
- , green = Number(g) / 255 * 5
- , blue = Number(b) / 255 * 5
- return rgb5(red, green, blue)
-}
-
-/**
- * Turns rgb 0-5 values into a single ANSI color code to use.
- */
-
-function rgb5 (r, g, b) {
- var red = Math.round(r)
- , green = Math.round(g)
- , blue = Math.round(b)
- return 16 + (red*36) + (green*6) + blue
-}
-
-var palette_ansi = []
-
-for (var i=0, rgb_css; rgb_css = palette[i]; i++){
- var rgbs = rgb_css
- .replace('rgb(', '')
- .replace(')', '')
- .split(',');
- var rgb_ansi = '5;' + rgb(rgbs[0],rgbs[1],rgbs[2])
- palette_ansi.push(rgb_ansi);
-}
-
-var char_escape = '\x1b[';
-// var char_escape = '\x1b[';
-var char_reset = char_escape + '0m';
-
-var mirc_color_to_ansi_color = [
-
-]
-
-var colorcode_to_ansi = function(string_or_json, opts){
- opts = opts || {};
-
- var json = to_json(string_or_json, opts);
-
- var out = "";
-
- for (var l = 0, line; line = json.lines[l]; l++){
- for (var c = 0, char; char = line[c]; c++){
- out += char_escape;
- out += '38;' + palette_ansi[char.fg]
- out += ';'
- out += '48;' + palette_ansi[char.bg]
- out += 'm'
- out += String.fromCharCode(char.value);
- }
- out += char_reset + '\n';
- }
-
- return out;
-
-}
-
-module.exports = colorcode_to_ansi;
-
-},{"./color":3,"./to_json":11}],11:[function(require,module,exports){
var char_color = '\x03';
var regexp_color = /(^[\d]{1,2})?(?:,([\d]{1,2}))?/;
@@ -610,7 +545,7 @@ var line_to_json = function(line, base_style){
module.exports = colorcode_to_json;
-},{}],12:[function(require,module,exports){
+},{}],11:[function(require,module,exports){
},{}]},{},[1])
(1)