A pixel art painter geared specifically at NES pixel art. Includes export for .chr binary file as well as palette and namespace data.
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

68 行
1.6KB

  1. const utils = {
  2. isInt:function(v){
  3. if (isNaN(v)){
  4. return false;
  5. }
  6. var x = parseFloat(v);
  7. return (x | 0) === x;
  8. },
  9. isElement:function(el){
  10. // Code based on...
  11. // https://stackoverflow.com/questions/384286/javascript-isdom-how-do-you-check-if-a-javascript-object-is-a-dom-object
  12. try {
  13. // Using W3 DOM2 (works for FF, Opera and Chrome)
  14. return el instanceof HTMLElement;
  15. } catch(e) {
  16. // Browsers not supporting W3 DOM2 don't have HTMLElement and
  17. // an exception is thrown and we end up here. Testing some
  18. // properties that all elements have (works on IE7)
  19. return (typeof(el) === "object") &&
  20. (el.nodeType === 1) &&
  21. (typeof(el.style) === "object") &&
  22. (typeof(el.ownerDocument) === "object");
  23. }
  24. },
  25. debounce:function(func, delay, scope){
  26. var timeout = null;
  27. return function(){
  28. //var context = this;
  29. var context = scope || this;
  30. var args = arguments;
  31. clearTimeout(timeout);
  32. timeout = setTimeout(function(){
  33. func.apply(context, args);
  34. }, delay);
  35. };
  36. },
  37. throttle:function(func, threshold, scope){
  38. threshold || (threshold = 250);
  39. var lst = 0;
  40. var timer;
  41. return function(){
  42. var context = scope || this;
  43. var args = arguments;
  44. var now = Date.now();
  45. if (now < lst + threshold){
  46. clearTimeout(timer);
  47. timer = setTimeout(function(){
  48. lst = now;
  49. func.apply(context, args);
  50. }, threshold);
  51. } else {
  52. lst = now;
  53. func.apply(context, args);
  54. }
  55. };
  56. }
  57. };
  58. Object.freeze(utils);
  59. export default utils;