web 3d图形渲染器
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
967 B

  1. // Generated by CoffeeScript 1.9.3
  2. var AnsiPainter, _common;
  3. AnsiPainter = require('../../AnsiPainter');
  4. module.exports = _common = {
  5. getStyleTagsFor: function(style) {
  6. var i, len, ret, tag, tagName, tagsToAdd;
  7. tagsToAdd = [];
  8. if (style.color != null) {
  9. tagName = 'color-' + style.color;
  10. if (AnsiPainter.tags[tagName] == null) {
  11. throw Error("Unknown color `" + style.color + "`");
  12. }
  13. tagsToAdd.push(tagName);
  14. }
  15. if (style.background != null) {
  16. tagName = 'bg-' + style.background;
  17. if (AnsiPainter.tags[tagName] == null) {
  18. throw Error("Unknown background `" + style.background + "`");
  19. }
  20. tagsToAdd.push(tagName);
  21. }
  22. ret = {
  23. before: '',
  24. after: ''
  25. };
  26. for (i = 0, len = tagsToAdd.length; i < len; i++) {
  27. tag = tagsToAdd[i];
  28. ret.before = ("<" + tag + ">") + ret.before;
  29. ret.after = ret.after + ("</" + tag + ">");
  30. }
  31. return ret;
  32. }
  33. };