A pixel art painter geared specifically at NES pixel art. Includes export for .chr binary file as well as palette and namespace data.
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

94 Zeilen
2.5KB

  1. function isElement(obj) {
  2. try {
  3. // Using W3 DOM2 (works for FF, Opera and Chrome)
  4. return obj instanceof HTMLElement;
  5. } catch(e) {
  6. //Browsers not supporting W3 DOM2 don't have HTMLElement and
  7. //an exception is thrown and we end up here. Testing some
  8. //properties that all elements have (works on IE7)
  9. return (typeof obj==="object") &&
  10. (obj.nodeType===1) && (typeof obj.style === "object") &&
  11. (typeof obj.ownerDocument ==="object");
  12. }
  13. }
  14. function appendCTX(el, ctx){
  15. if (isElement(ctx)){
  16. el.appendChild(ctx);
  17. } else {
  18. var t = document.createTextNode(ctx.toString());
  19. el.appendChild(t);
  20. }
  21. }
  22. export function el(ename, ctx, cls, attr){
  23. var e = document.createElement(ename);
  24. if (ctx){
  25. if (ctx instanceof Array){
  26. ctx.forEach(item => appendCTX(el, item));
  27. } else {
  28. appendCTX(el, ctx);
  29. }
  30. }
  31. if (cls){
  32. var cl = cls;
  33. if (typeof(cl) === "String")
  34. cl = cl.split(" ");
  35. if (cl instanceof Array){
  36. cl.forEach(c => el.classList.add(c.trim()));
  37. }
  38. }
  39. if (attr){
  40. var keys = Object.keys(attr);
  41. keys.forEach(function(key){
  42. if (attr.hasOwnProperty(key)){
  43. var att = document.createAttribute(key.toString());
  44. if (typeof(attr[key]) === "String"){
  45. att.value = attr[key];
  46. el.setAttributeNode(att);
  47. }
  48. }
  49. });
  50. }
  51. }
  52. export const header = el.bind(null, "header");
  53. export const title = el.bind(null, "title");
  54. export const script = el.bind(null, "script");
  55. export const link = el.bind(null, "link");
  56. export const meta = el.bind(null, "meta");
  57. export const div = el.bind(null, "div");
  58. export const span = el.bind(null, "span");
  59. export const a = el.bind(null, "a");
  60. export const p = el.bind(null, "p");
  61. export const b = el.bind(null, "b");
  62. export const i = el.bind(null, "i");
  63. export const br = el.bind(null, "br");
  64. export const ol = el.bind(null, "ol");
  65. export const ul = el.bind(null, "ul");
  66. export const li = el.bind(null, "li");
  67. export const em = el.bind(null, "em");
  68. export const font = el.bind(null, "font");
  69. export const h1 = el.bind(null, "h1");
  70. export const h2 = el.bind(null, "h2");
  71. export const h3 = el.bind(null, "h3");
  72. export const h4 = el.bind(null, "h4");
  73. export const h5 = el.bind(null, "h5");
  74. export const h6 = el.bind(null, "h6");
  75. export const hr = el.bind(null, "hr");
  76. export const blockquote = el.bind(null, "blockquote");
  77. export const button = el.bind(null, "button");
  78. export const nav = el.bind(null, "nav");
  79. export const canvas = el.bind(null, "canvas");
  80. export const caption = el.bind(null, "caption");