* @function Painter.Layer.prototype.clear * @description 清空该层画布。
()
| 1085 | * @description 清空该层画布。 |
| 1086 | */ |
| 1087 | clear() { |
| 1088 | var dom = this.dom; |
| 1089 | var ctx = this.ctx; |
| 1090 | var width = dom.width; |
| 1091 | var height = dom.height; |
| 1092 | |
| 1093 | var haveClearColor = this.clearColor; |
| 1094 | var haveMotionBLur = this.motionBlur; |
| 1095 | var lastFrameAlpha = this.lastFrameAlpha; |
| 1096 | |
| 1097 | if (haveMotionBLur) { |
| 1098 | if (!this.domBack) { |
| 1099 | this.createBackBuffer(); |
| 1100 | } |
| 1101 | |
| 1102 | this.ctxBack.globalCompositeOperation = 'copy'; |
| 1103 | this.ctxBack.drawImage( |
| 1104 | dom, 0, 0, |
| 1105 | width / Painter.devicePixelRatio, |
| 1106 | height / Painter.devicePixelRatio |
| 1107 | ); |
| 1108 | } |
| 1109 | |
| 1110 | if (haveClearColor) { |
| 1111 | ctx.save(); |
| 1112 | ctx.fillStyle = this.config.clearColor; |
| 1113 | ctx.fillRect( |
| 1114 | 0, 0, |
| 1115 | width / Painter.devicePixelRatio, |
| 1116 | height / Painter.devicePixelRatio |
| 1117 | ); |
| 1118 | ctx.restore(); |
| 1119 | } else { |
| 1120 | ctx.clearRect( |
| 1121 | 0, 0, |
| 1122 | width / Painter.devicePixelRatio, |
| 1123 | height / Painter.devicePixelRatio |
| 1124 | ); |
| 1125 | } |
| 1126 | |
| 1127 | if (haveMotionBLur) { |
| 1128 | var domBack = this.domBack; |
| 1129 | ctx.save(); |
| 1130 | ctx.globalAlpha = lastFrameAlpha; |
| 1131 | ctx.drawImage( |
| 1132 | domBack, 0, 0, |
| 1133 | width / Painter.devicePixelRatio, |
| 1134 | height / Painter.devicePixelRatio |
| 1135 | ); |
| 1136 | ctx.restore(); |
| 1137 | } |
| 1138 | } |
| 1139 | |
| 1140 | } |
nothing calls this directly
no test coverage detected