@leafer-in/robot 1.0.5 → 1.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/robot.cjs CHANGED
@@ -32,6 +32,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
32
32
  };
33
33
 
34
34
  class RobotData extends draw.UIData {
35
+ get __drawAfterFill() { return true; }
35
36
  setRobot(value) {
36
37
  this._robot = value;
37
38
  this.__leaf.__updateRobot();
@@ -47,7 +48,6 @@ exports.Robot = class Robot extends draw.UI {
47
48
  get nowFrame() { return this.robotFrames && this.robotFrames[this.now]; }
48
49
  constructor(data) {
49
50
  super(data);
50
- this.__.__drawAfterFill = true;
51
51
  }
52
52
  play() {
53
53
  this.running = true;
@@ -138,20 +138,10 @@ exports.Robot = class Robot extends draw.UI {
138
138
  data.__naturalHeight = height;
139
139
  }
140
140
  }
141
- __drawAfterFill(canvas, _options) {
142
- const { nowFrame } = this;
143
- if (nowFrame) {
144
- const { width, height, cornerRadius } = this.__;
145
- if (cornerRadius || this.pathInputed) {
146
- canvas.save();
147
- canvas.clip();
148
- canvas.drawImage(nowFrame.view, nowFrame.x, nowFrame.y, nowFrame.width, nowFrame.height, 0, 0, width, height);
149
- canvas.restore();
150
- }
151
- else {
152
- canvas.drawImage(nowFrame.view, nowFrame.x, nowFrame.y, nowFrame.width, nowFrame.height, 0, 0, width, height);
153
- }
154
- }
141
+ __drawContent(canvas, _options) {
142
+ const { nowFrame } = this, { width, height } = this.__;
143
+ if (nowFrame)
144
+ canvas.drawImage(nowFrame.view, nowFrame.x, nowFrame.y, nowFrame.width, nowFrame.height, 0, 0, width, height);
155
145
  }
156
146
  destroy() {
157
147
  if (this.robotFrames)
package/dist/robot.esm.js CHANGED
@@ -30,6 +30,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
30
30
  };
31
31
 
32
32
  class RobotData extends UIData {
33
+ get __drawAfterFill() { return true; }
33
34
  setRobot(value) {
34
35
  this._robot = value;
35
36
  this.__leaf.__updateRobot();
@@ -45,7 +46,6 @@ let Robot = class Robot extends UI {
45
46
  get nowFrame() { return this.robotFrames && this.robotFrames[this.now]; }
46
47
  constructor(data) {
47
48
  super(data);
48
- this.__.__drawAfterFill = true;
49
49
  }
50
50
  play() {
51
51
  this.running = true;
@@ -136,20 +136,10 @@ let Robot = class Robot extends UI {
136
136
  data.__naturalHeight = height;
137
137
  }
138
138
  }
139
- __drawAfterFill(canvas, _options) {
140
- const { nowFrame } = this;
141
- if (nowFrame) {
142
- const { width, height, cornerRadius } = this.__;
143
- if (cornerRadius || this.pathInputed) {
144
- canvas.save();
145
- canvas.clip();
146
- canvas.drawImage(nowFrame.view, nowFrame.x, nowFrame.y, nowFrame.width, nowFrame.height, 0, 0, width, height);
147
- canvas.restore();
148
- }
149
- else {
150
- canvas.drawImage(nowFrame.view, nowFrame.x, nowFrame.y, nowFrame.width, nowFrame.height, 0, 0, width, height);
151
- }
152
- }
139
+ __drawContent(canvas, _options) {
140
+ const { nowFrame } = this, { width, height } = this.__;
141
+ if (nowFrame)
142
+ canvas.drawImage(nowFrame.view, nowFrame.x, nowFrame.y, nowFrame.width, nowFrame.height, 0, 0, width, height);
153
143
  }
154
144
  destroy() {
155
145
  if (this.robotFrames)
@@ -1 +1 @@
1
- import{UIData as t,dataProcessor as e,boundsType as o,dataType as i,surfaceType as s,registerUI as r,UI as h,ImageManager as n,ImageEvent as a}from"@leafer-ui/draw";function _(t,e,o,i){var s,r=arguments.length,h=r<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,o):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)h=Reflect.decorate(t,e,o,i);else for(var n=t.length-1;n>=0;n--)(s=t[n])&&(h=(r<3?s(h):r>3?s(e,o,h):s(e,o))||h);return r>3&&h&&Object.defineProperty(e,o,h),h}"function"==typeof SuppressedError&&SuppressedError;class d extends t{setRobot(t){this._robot=t,this.__leaf.__updateRobot()}setAction(t){this._action=t,this.__leaf.__updateAction()}}let p=class extends h{get __tag(){return"Robot"}get nowFrame(){return this.robotFrames&&this.robotFrames[this.now]}constructor(t){super(t),this.__.__drawAfterFill=!0}play(){this.running=!0}pause(){this.running=!1}stop(){this.pause()}__updateRobot(){const{robot:t}=this;if(this.robotFrames=[],!t)return;let e=0;t instanceof Array?t.forEach((t=>this.__loadRobot(t,e,e+=t.total||1))):this.__loadRobot(t,0,t.total)}__updateAction(){const t=this.actions[this.action];if(this.stop(),this.__timer&&clearTimeout(this.__timer),void 0!==t)if("number"==typeof t)this.now=t;else if(t instanceof Array){const{length:e}=t;if(e>1){const e=this.now=t[0],o=t[t.length-1];this.play(),this.__runAction(e,o)}else e&&(this.now=t[0])}}__loadRobot(t,e,o){for(let t=e;t<o;t++)this.robotFrames.push(void 0);const i=n.get(t);i.ready?this.__createFrames(i,t,e,o):i.load((()=>this.__createFrames(i,t,e,o)))}__createFrames(t,e,o,i){const{offset:s,size:r,total:h}=e,{width:n,height:_}=r&&("number"==typeof r?{width:r,height:r}:r)||(h>1?this:t);let d=s?s.x:0,p=s?s.y:0;for(let e=o;e<i;e++)this.robotFrames[e]={view:t.view,x:d,y:p,width:n,height:_},d+n>=t.width?(d=0,p+=_):d+=n;this.__updateRobotBounds(),this.forceRender(),this.emitEvent(new a(a.LOADED,{image:t}))}__runAction(t,e){this.__timer=setTimeout((()=>{this.running&&(this.now===e?this.now=t:this.now++,this.__updateRobotBounds()),this.__runAction(t,e)}),1e3/this.FPS)}__updateRobotBounds(){const{nowFrame:t}=this;if(t){const e=this.__,o=t.width/e.pixelRatio,i=t.height/e.pixelRatio;e.width===o&&e.height===i||this.forceUpdate("width"),e.__naturalWidth=o,e.__naturalHeight=i}}__drawAfterFill(t,e){const{nowFrame:o}=this;if(o){const{width:e,height:i,cornerRadius:s}=this.__;s||this.pathInputed?(t.save(),t.clip(),t.drawImage(o.view,o.x,o.y,o.width,o.height,0,0,e,i),t.restore()):t.drawImage(o.view,o.x,o.y,o.width,o.height,0,0,e,i)}}destroy(){this.robotFrames&&(this.robotFrames=null),super.destroy()}};_([e(d)],p.prototype,"__",void 0),_([o()],p.prototype,"robot",void 0),_([i()],p.prototype,"actions",void 0),_([i("")],p.prototype,"action",void 0),_([s(0)],p.prototype,"now",void 0),_([i(12)],p.prototype,"FPS",void 0),_([i(!0)],p.prototype,"loop",void 0),p=_([r()],p);export{p as Robot,d as RobotData};
1
+ import{UIData as t,dataProcessor as o,boundsType as e,dataType as i,surfaceType as r,registerUI as s,UI as n,ImageManager as h,ImageEvent as a}from"@leafer-ui/draw";function _(t,o,e,i){var r,s=arguments.length,n=s<3?o:null===i?i=Object.getOwnPropertyDescriptor(o,e):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(t,o,e,i);else for(var h=t.length-1;h>=0;h--)(r=t[h])&&(n=(s<3?r(n):s>3?r(o,e,n):r(o,e))||n);return s>3&&n&&Object.defineProperty(o,e,n),n}"function"==typeof SuppressedError&&SuppressedError;class d extends t{get __drawAfterFill(){return!0}setRobot(t){this._robot=t,this.__leaf.__updateRobot()}setAction(t){this._action=t,this.__leaf.__updateAction()}}let p=class extends n{get __tag(){return"Robot"}get nowFrame(){return this.robotFrames&&this.robotFrames[this.now]}constructor(t){super(t)}play(){this.running=!0}pause(){this.running=!1}stop(){this.pause()}__updateRobot(){const{robot:t}=this;if(this.robotFrames=[],!t)return;let o=0;t instanceof Array?t.forEach((t=>this.__loadRobot(t,o,o+=t.total||1))):this.__loadRobot(t,0,t.total)}__updateAction(){const t=this.actions[this.action];if(this.stop(),this.__timer&&clearTimeout(this.__timer),void 0!==t)if("number"==typeof t)this.now=t;else if(t instanceof Array){const{length:o}=t;if(o>1){const o=this.now=t[0],e=t[t.length-1];this.play(),this.__runAction(o,e)}else o&&(this.now=t[0])}}__loadRobot(t,o,e){for(let t=o;t<e;t++)this.robotFrames.push(void 0);const i=h.get(t);i.ready?this.__createFrames(i,t,o,e):i.load((()=>this.__createFrames(i,t,o,e)))}__createFrames(t,o,e,i){const{offset:r,size:s,total:n}=o,{width:h,height:_}=s&&("number"==typeof s?{width:s,height:s}:s)||(n>1?this:t);let d=r?r.x:0,p=r?r.y:0;for(let o=e;o<i;o++)this.robotFrames[o]={view:t.view,x:d,y:p,width:h,height:_},d+h>=t.width?(d=0,p+=_):d+=h;this.__updateRobotBounds(),this.forceRender(),this.emitEvent(new a(a.LOADED,{image:t}))}__runAction(t,o){this.__timer=setTimeout((()=>{this.running&&(this.now===o?this.now=t:this.now++,this.__updateRobotBounds()),this.__runAction(t,o)}),1e3/this.FPS)}__updateRobotBounds(){const{nowFrame:t}=this;if(t){const o=this.__,e=t.width/o.pixelRatio,i=t.height/o.pixelRatio;o.width===e&&o.height===i||this.forceUpdate("width"),o.__naturalWidth=e,o.__naturalHeight=i}}__drawContent(t,o){const{nowFrame:e}=this,{width:i,height:r}=this.__;e&&t.drawImage(e.view,e.x,e.y,e.width,e.height,0,0,i,r)}destroy(){this.robotFrames&&(this.robotFrames=null),super.destroy()}};_([o(d)],p.prototype,"__",void 0),_([e()],p.prototype,"robot",void 0),_([i()],p.prototype,"actions",void 0),_([i("")],p.prototype,"action",void 0),_([r(0)],p.prototype,"now",void 0),_([i(12)],p.prototype,"FPS",void 0),_([i(!0)],p.prototype,"loop",void 0),p=_([s()],p);export{p as Robot,d as RobotData};
package/dist/robot.js CHANGED
@@ -32,6 +32,7 @@ this.LeaferIN.Robot = (function (exports, draw) {
32
32
  };
33
33
 
34
34
  class RobotData extends draw.UIData {
35
+ get __drawAfterFill() { return true; }
35
36
  setRobot(value) {
36
37
  this._robot = value;
37
38
  this.__leaf.__updateRobot();
@@ -47,7 +48,6 @@ this.LeaferIN.Robot = (function (exports, draw) {
47
48
  get nowFrame() { return this.robotFrames && this.robotFrames[this.now]; }
48
49
  constructor(data) {
49
50
  super(data);
50
- this.__.__drawAfterFill = true;
51
51
  }
52
52
  play() {
53
53
  this.running = true;
@@ -138,20 +138,10 @@ this.LeaferIN.Robot = (function (exports, draw) {
138
138
  data.__naturalHeight = height;
139
139
  }
140
140
  }
141
- __drawAfterFill(canvas, _options) {
142
- const { nowFrame } = this;
143
- if (nowFrame) {
144
- const { width, height, cornerRadius } = this.__;
145
- if (cornerRadius || this.pathInputed) {
146
- canvas.save();
147
- canvas.clip();
148
- canvas.drawImage(nowFrame.view, nowFrame.x, nowFrame.y, nowFrame.width, nowFrame.height, 0, 0, width, height);
149
- canvas.restore();
150
- }
151
- else {
152
- canvas.drawImage(nowFrame.view, nowFrame.x, nowFrame.y, nowFrame.width, nowFrame.height, 0, 0, width, height);
153
- }
154
- }
141
+ __drawContent(canvas, _options) {
142
+ const { nowFrame } = this, { width, height } = this.__;
143
+ if (nowFrame)
144
+ canvas.drawImage(nowFrame.view, nowFrame.x, nowFrame.y, nowFrame.width, nowFrame.height, 0, 0, width, height);
155
145
  }
156
146
  destroy() {
157
147
  if (this.robotFrames)
@@ -1 +1 @@
1
- "use strict";var t=require("@leafer-ui/draw");function o(t,o,e,i){var s,r=arguments.length,a=r<3?o:null===i?i=Object.getOwnPropertyDescriptor(o,e):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,o,e,i);else for(var n=t.length-1;n>=0;n--)(s=t[n])&&(a=(r<3?s(a):r>3?s(o,e,a):s(o,e))||a);return r>3&&a&&Object.defineProperty(o,e,a),a}"function"==typeof SuppressedError&&SuppressedError;class e extends t.UIData{setRobot(t){this._robot=t,this.__leaf.__updateRobot()}setAction(t){this._action=t,this.__leaf.__updateAction()}}exports.Robot=class extends t.UI{get __tag(){return"Robot"}get nowFrame(){return this.robotFrames&&this.robotFrames[this.now]}constructor(t){super(t),this.__.__drawAfterFill=!0}play(){this.running=!0}pause(){this.running=!1}stop(){this.pause()}__updateRobot(){const{robot:t}=this;if(this.robotFrames=[],!t)return;let o=0;t instanceof Array?t.forEach((t=>this.__loadRobot(t,o,o+=t.total||1))):this.__loadRobot(t,0,t.total)}__updateAction(){const t=this.actions[this.action];if(this.stop(),this.__timer&&clearTimeout(this.__timer),void 0!==t)if("number"==typeof t)this.now=t;else if(t instanceof Array){const{length:o}=t;if(o>1){const o=this.now=t[0],e=t[t.length-1];this.play(),this.__runAction(o,e)}else o&&(this.now=t[0])}}__loadRobot(o,e,i){for(let t=e;t<i;t++)this.robotFrames.push(void 0);const s=t.ImageManager.get(o);s.ready?this.__createFrames(s,o,e,i):s.load((()=>this.__createFrames(s,o,e,i)))}__createFrames(o,e,i,s){const{offset:r,size:a,total:n}=e,{width:h,height:p}=a&&("number"==typeof a?{width:a,height:a}:a)||(n>1?this:o);let _=r?r.x:0,d=r?r.y:0;for(let t=i;t<s;t++)this.robotFrames[t]={view:o.view,x:_,y:d,width:h,height:p},_+h>=o.width?(_=0,d+=p):_+=h;this.__updateRobotBounds(),this.forceRender(),this.emitEvent(new t.ImageEvent(t.ImageEvent.LOADED,{image:o}))}__runAction(t,o){this.__timer=setTimeout((()=>{this.running&&(this.now===o?this.now=t:this.now++,this.__updateRobotBounds()),this.__runAction(t,o)}),1e3/this.FPS)}__updateRobotBounds(){const{nowFrame:t}=this;if(t){const o=this.__,e=t.width/o.pixelRatio,i=t.height/o.pixelRatio;o.width===e&&o.height===i||this.forceUpdate("width"),o.__naturalWidth=e,o.__naturalHeight=i}}__drawAfterFill(t,o){const{nowFrame:e}=this;if(e){const{width:o,height:i,cornerRadius:s}=this.__;s||this.pathInputed?(t.save(),t.clip(),t.drawImage(e.view,e.x,e.y,e.width,e.height,0,0,o,i),t.restore()):t.drawImage(e.view,e.x,e.y,e.width,e.height,0,0,o,i)}}destroy(){this.robotFrames&&(this.robotFrames=null),super.destroy()}},o([t.dataProcessor(e)],exports.Robot.prototype,"__",void 0),o([t.boundsType()],exports.Robot.prototype,"robot",void 0),o([t.dataType()],exports.Robot.prototype,"actions",void 0),o([t.dataType("")],exports.Robot.prototype,"action",void 0),o([t.surfaceType(0)],exports.Robot.prototype,"now",void 0),o([t.dataType(12)],exports.Robot.prototype,"FPS",void 0),o([t.dataType(!0)],exports.Robot.prototype,"loop",void 0),exports.Robot=o([t.registerUI()],exports.Robot),exports.RobotData=e;
1
+ "use strict";var t=require("@leafer-ui/draw");function o(t,o,e,i){var r,s=arguments.length,a=s<3?o:null===i?i=Object.getOwnPropertyDescriptor(o,e):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,o,e,i);else for(var n=t.length-1;n>=0;n--)(r=t[n])&&(a=(s<3?r(a):s>3?r(o,e,a):r(o,e))||a);return s>3&&a&&Object.defineProperty(o,e,a),a}"function"==typeof SuppressedError&&SuppressedError;class e extends t.UIData{get __drawAfterFill(){return!0}setRobot(t){this._robot=t,this.__leaf.__updateRobot()}setAction(t){this._action=t,this.__leaf.__updateAction()}}exports.Robot=class extends t.UI{get __tag(){return"Robot"}get nowFrame(){return this.robotFrames&&this.robotFrames[this.now]}constructor(t){super(t)}play(){this.running=!0}pause(){this.running=!1}stop(){this.pause()}__updateRobot(){const{robot:t}=this;if(this.robotFrames=[],!t)return;let o=0;t instanceof Array?t.forEach((t=>this.__loadRobot(t,o,o+=t.total||1))):this.__loadRobot(t,0,t.total)}__updateAction(){const t=this.actions[this.action];if(this.stop(),this.__timer&&clearTimeout(this.__timer),void 0!==t)if("number"==typeof t)this.now=t;else if(t instanceof Array){const{length:o}=t;if(o>1){const o=this.now=t[0],e=t[t.length-1];this.play(),this.__runAction(o,e)}else o&&(this.now=t[0])}}__loadRobot(o,e,i){for(let t=e;t<i;t++)this.robotFrames.push(void 0);const r=t.ImageManager.get(o);r.ready?this.__createFrames(r,o,e,i):r.load((()=>this.__createFrames(r,o,e,i)))}__createFrames(o,e,i,r){const{offset:s,size:a,total:n}=e,{width:h,height:p}=a&&("number"==typeof a?{width:a,height:a}:a)||(n>1?this:o);let _=s?s.x:0,d=s?s.y:0;for(let t=i;t<r;t++)this.robotFrames[t]={view:o.view,x:_,y:d,width:h,height:p},_+h>=o.width?(_=0,d+=p):_+=h;this.__updateRobotBounds(),this.forceRender(),this.emitEvent(new t.ImageEvent(t.ImageEvent.LOADED,{image:o}))}__runAction(t,o){this.__timer=setTimeout((()=>{this.running&&(this.now===o?this.now=t:this.now++,this.__updateRobotBounds()),this.__runAction(t,o)}),1e3/this.FPS)}__updateRobotBounds(){const{nowFrame:t}=this;if(t){const o=this.__,e=t.width/o.pixelRatio,i=t.height/o.pixelRatio;o.width===e&&o.height===i||this.forceUpdate("width"),o.__naturalWidth=e,o.__naturalHeight=i}}__drawContent(t,o){const{nowFrame:e}=this,{width:i,height:r}=this.__;e&&t.drawImage(e.view,e.x,e.y,e.width,e.height,0,0,i,r)}destroy(){this.robotFrames&&(this.robotFrames=null),super.destroy()}},o([t.dataProcessor(e)],exports.Robot.prototype,"__",void 0),o([t.boundsType()],exports.Robot.prototype,"robot",void 0),o([t.dataType()],exports.Robot.prototype,"actions",void 0),o([t.dataType("")],exports.Robot.prototype,"action",void 0),o([t.surfaceType(0)],exports.Robot.prototype,"now",void 0),o([t.dataType(12)],exports.Robot.prototype,"FPS",void 0),o([t.dataType(!0)],exports.Robot.prototype,"loop",void 0),exports.Robot=o([t.registerUI()],exports.Robot),exports.RobotData=e;
package/dist/robot.min.js CHANGED
@@ -1 +1 @@
1
- this.LeaferIN=this.LeaferIN||{},this.LeaferIN.Robot=function(t,o){"use strict";function e(t,o,e,i){var s,r=arguments.length,a=r<3?o:null===i?i=Object.getOwnPropertyDescriptor(o,e):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,o,e,i);else for(var n=t.length-1;n>=0;n--)(s=t[n])&&(a=(r<3?s(a):r>3?s(o,e,a):s(o,e))||a);return r>3&&a&&Object.defineProperty(o,e,a),a}"function"==typeof SuppressedError&&SuppressedError;class i extends o.UIData{setRobot(t){this._robot=t,this.__leaf.__updateRobot()}setAction(t){this._action=t,this.__leaf.__updateAction()}}return t.Robot=class extends o.UI{get __tag(){return"Robot"}get nowFrame(){return this.robotFrames&&this.robotFrames[this.now]}constructor(t){super(t),this.__.__drawAfterFill=!0}play(){this.running=!0}pause(){this.running=!1}stop(){this.pause()}__updateRobot(){const{robot:t}=this;if(this.robotFrames=[],!t)return;let o=0;t instanceof Array?t.forEach((t=>this.__loadRobot(t,o,o+=t.total||1))):this.__loadRobot(t,0,t.total)}__updateAction(){const t=this.actions[this.action];if(this.stop(),this.__timer&&clearTimeout(this.__timer),void 0!==t)if("number"==typeof t)this.now=t;else if(t instanceof Array){const{length:o}=t;if(o>1){const o=this.now=t[0],e=t[t.length-1];this.play(),this.__runAction(o,e)}else o&&(this.now=t[0])}}__loadRobot(t,e,i){for(let t=e;t<i;t++)this.robotFrames.push(void 0);const s=o.ImageManager.get(t);s.ready?this.__createFrames(s,t,e,i):s.load((()=>this.__createFrames(s,t,e,i)))}__createFrames(t,e,i,s){const{offset:r,size:a,total:n}=e,{width:h,height:_}=a&&("number"==typeof a?{width:a,height:a}:a)||(n>1?this:t);let d=r?r.x:0,p=r?r.y:0;for(let o=i;o<s;o++)this.robotFrames[o]={view:t.view,x:d,y:p,width:h,height:_},d+h>=t.width?(d=0,p+=_):d+=h;this.__updateRobotBounds(),this.forceRender(),this.emitEvent(new o.ImageEvent(o.ImageEvent.LOADED,{image:t}))}__runAction(t,o){this.__timer=setTimeout((()=>{this.running&&(this.now===o?this.now=t:this.now++,this.__updateRobotBounds()),this.__runAction(t,o)}),1e3/this.FPS)}__updateRobotBounds(){const{nowFrame:t}=this;if(t){const o=this.__,e=t.width/o.pixelRatio,i=t.height/o.pixelRatio;o.width===e&&o.height===i||this.forceUpdate("width"),o.__naturalWidth=e,o.__naturalHeight=i}}__drawAfterFill(t,o){const{nowFrame:e}=this;if(e){const{width:o,height:i,cornerRadius:s}=this.__;s||this.pathInputed?(t.save(),t.clip(),t.drawImage(e.view,e.x,e.y,e.width,e.height,0,0,o,i),t.restore()):t.drawImage(e.view,e.x,e.y,e.width,e.height,0,0,o,i)}}destroy(){this.robotFrames&&(this.robotFrames=null),super.destroy()}},e([o.dataProcessor(i)],t.Robot.prototype,"__",void 0),e([o.boundsType()],t.Robot.prototype,"robot",void 0),e([o.dataType()],t.Robot.prototype,"actions",void 0),e([o.dataType("")],t.Robot.prototype,"action",void 0),e([o.surfaceType(0)],t.Robot.prototype,"now",void 0),e([o.dataType(12)],t.Robot.prototype,"FPS",void 0),e([o.dataType(!0)],t.Robot.prototype,"loop",void 0),t.Robot=e([o.registerUI()],t.Robot),t.RobotData=i,t}({},LeaferUI);
1
+ this.LeaferIN=this.LeaferIN||{},this.LeaferIN.Robot=function(t,o){"use strict";function e(t,o,e,i){var s,r=arguments.length,a=r<3?o:null===i?i=Object.getOwnPropertyDescriptor(o,e):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,o,e,i);else for(var n=t.length-1;n>=0;n--)(s=t[n])&&(a=(r<3?s(a):r>3?s(o,e,a):s(o,e))||a);return r>3&&a&&Object.defineProperty(o,e,a),a}"function"==typeof SuppressedError&&SuppressedError;class i extends o.UIData{get __drawAfterFill(){return!0}setRobot(t){this._robot=t,this.__leaf.__updateRobot()}setAction(t){this._action=t,this.__leaf.__updateAction()}}return t.Robot=class extends o.UI{get __tag(){return"Robot"}get nowFrame(){return this.robotFrames&&this.robotFrames[this.now]}constructor(t){super(t)}play(){this.running=!0}pause(){this.running=!1}stop(){this.pause()}__updateRobot(){const{robot:t}=this;if(this.robotFrames=[],!t)return;let o=0;t instanceof Array?t.forEach((t=>this.__loadRobot(t,o,o+=t.total||1))):this.__loadRobot(t,0,t.total)}__updateAction(){const t=this.actions[this.action];if(this.stop(),this.__timer&&clearTimeout(this.__timer),void 0!==t)if("number"==typeof t)this.now=t;else if(t instanceof Array){const{length:o}=t;if(o>1){const o=this.now=t[0],e=t[t.length-1];this.play(),this.__runAction(o,e)}else o&&(this.now=t[0])}}__loadRobot(t,e,i){for(let t=e;t<i;t++)this.robotFrames.push(void 0);const s=o.ImageManager.get(t);s.ready?this.__createFrames(s,t,e,i):s.load((()=>this.__createFrames(s,t,e,i)))}__createFrames(t,e,i,s){const{offset:r,size:a,total:n}=e,{width:h,height:_}=a&&("number"==typeof a?{width:a,height:a}:a)||(n>1?this:t);let d=r?r.x:0,p=r?r.y:0;for(let o=i;o<s;o++)this.robotFrames[o]={view:t.view,x:d,y:p,width:h,height:_},d+h>=t.width?(d=0,p+=_):d+=h;this.__updateRobotBounds(),this.forceRender(),this.emitEvent(new o.ImageEvent(o.ImageEvent.LOADED,{image:t}))}__runAction(t,o){this.__timer=setTimeout((()=>{this.running&&(this.now===o?this.now=t:this.now++,this.__updateRobotBounds()),this.__runAction(t,o)}),1e3/this.FPS)}__updateRobotBounds(){const{nowFrame:t}=this;if(t){const o=this.__,e=t.width/o.pixelRatio,i=t.height/o.pixelRatio;o.width===e&&o.height===i||this.forceUpdate("width"),o.__naturalWidth=e,o.__naturalHeight=i}}__drawContent(t,o){const{nowFrame:e}=this,{width:i,height:s}=this.__;e&&t.drawImage(e.view,e.x,e.y,e.width,e.height,0,0,i,s)}destroy(){this.robotFrames&&(this.robotFrames=null),super.destroy()}},e([o.dataProcessor(i)],t.Robot.prototype,"__",void 0),e([o.boundsType()],t.Robot.prototype,"robot",void 0),e([o.dataType()],t.Robot.prototype,"actions",void 0),e([o.dataType("")],t.Robot.prototype,"action",void 0),e([o.surfaceType(0)],t.Robot.prototype,"now",void 0),e([o.dataType(12)],t.Robot.prototype,"FPS",void 0),e([o.dataType(!0)],t.Robot.prototype,"loop",void 0),t.Robot=e([o.registerUI()],t.Robot),t.RobotData=i,t}({},LeaferUI);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leafer-in/robot",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
4
  "description": "@leafer-in/robot",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
@@ -34,8 +34,8 @@
34
34
  "leaferjs"
35
35
  ],
36
36
  "dependencies": {
37
- "@leafer-ui/draw": "^1.0.5",
38
- "@leafer-ui/interface": "^1.0.5",
39
- "@leafer-in/interface": "^1.0.5"
37
+ "@leafer-ui/draw": "^1.0.7",
38
+ "@leafer-ui/interface": "^1.0.7",
39
+ "@leafer-in/interface": "^1.0.7"
40
40
  }
41
41
  }
package/src/Robot.ts CHANGED
@@ -43,7 +43,6 @@ export class Robot extends UI implements IRobot {
43
43
 
44
44
  constructor(data?: IRobotInputData) {
45
45
  super(data)
46
- this.__.__drawAfterFill = true
47
46
  }
48
47
 
49
48
 
@@ -146,19 +145,10 @@ export class Robot extends UI implements IRobot {
146
145
  }
147
146
  }
148
147
 
149
- public __drawAfterFill(canvas: ILeaferCanvas, _options: IRenderOptions): void {
150
- const { nowFrame } = this
151
- if (nowFrame) {
152
- const { width, height, cornerRadius } = this.__
153
- if (cornerRadius || this.pathInputed) {
154
- canvas.save()
155
- canvas.clip()
156
- canvas.drawImage(nowFrame.view, nowFrame.x, nowFrame.y, nowFrame.width, nowFrame.height, 0, 0, width, height)
157
- canvas.restore()
158
- } else {
159
- canvas.drawImage(nowFrame.view, nowFrame.x, nowFrame.y, nowFrame.width, nowFrame.height, 0, 0, width, height)
160
- }
161
- }
148
+ // in __drawAfterFill()
149
+ public __drawContent(canvas: ILeaferCanvas, _options: IRenderOptions): void {
150
+ const { nowFrame } = this, { width, height } = this.__
151
+ if (nowFrame) canvas.drawImage(nowFrame.view, nowFrame.x, nowFrame.y, nowFrame.width, nowFrame.height, 0, 0, width, height)
162
152
  }
163
153
 
164
154
  public destroy(): void {
@@ -4,6 +4,8 @@ import { UIData } from '@leafer-ui/draw'
4
4
 
5
5
  export class RobotData extends UIData {
6
6
 
7
+ public get __drawAfterFill(): boolean { return true }
8
+
7
9
  protected _robot: IRobotKeyframe | IRobotKeyframe[]
8
10
  protected _action: IRobotActionName
9
11
 
package/types/index.d.ts CHANGED
@@ -24,11 +24,12 @@ declare class Robot extends UI implements IRobot {
24
24
  protected __createFrames(image: ILeaferImage, frame: IRobotKeyframe, start: number, end: number): void;
25
25
  protected __runAction(start: number, end: number): void;
26
26
  protected __updateRobotBounds(): void;
27
- __drawAfterFill(canvas: ILeaferCanvas, _options: IRenderOptions): void;
27
+ __drawContent(canvas: ILeaferCanvas, _options: IRenderOptions): void;
28
28
  destroy(): void;
29
29
  }
30
30
 
31
31
  declare class RobotData extends UIData {
32
+ get __drawAfterFill(): boolean;
32
33
  protected _robot: IRobotKeyframe | IRobotKeyframe[];
33
34
  protected _action: IRobotActionName;
34
35
  protected setRobot(value: IRobotKeyframe | IRobotKeyframe[]): void;