ShapeProperty.js 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546
  1. import {
  2. degToRads,
  3. roundCorner,
  4. bmMin,
  5. } from '../common';
  6. import {
  7. extendPrototype,
  8. } from '../functionExtensions';
  9. import DynamicPropertyContainer from '../helpers/dynamicProperties';
  10. import PropertyFactory from '../PropertyFactory';
  11. import BezierFactory from '../../3rd_party/BezierEaser';
  12. import shapePool from '../pooling/shape_pool';
  13. import shapeCollectionPool from '../pooling/shapeCollection_pool';
  14. const ShapePropertyFactory = (function () {
  15. var initFrame = -999999;
  16. function interpolateShape(frameNum, previousValue, caching) {
  17. var iterationIndex = caching.lastIndex;
  18. var keyPropS;
  19. var keyPropE;
  20. var isHold;
  21. var j;
  22. var k;
  23. var jLen;
  24. var kLen;
  25. var perc;
  26. var vertexValue;
  27. var kf = this.keyframes;
  28. if (frameNum < kf[0].t - this.offsetTime) {
  29. keyPropS = kf[0].s[0];
  30. isHold = true;
  31. iterationIndex = 0;
  32. } else if (frameNum >= kf[kf.length - 1].t - this.offsetTime) {
  33. keyPropS = kf[kf.length - 1].s ? kf[kf.length - 1].s[0] : kf[kf.length - 2].e[0];
  34. /* if(kf[kf.length - 1].s){
  35. keyPropS = kf[kf.length - 1].s[0];
  36. }else{
  37. keyPropS = kf[kf.length - 2].e[0];
  38. } */
  39. isHold = true;
  40. } else {
  41. var i = iterationIndex;
  42. var len = kf.length - 1;
  43. var flag = true;
  44. var keyData;
  45. var nextKeyData;
  46. var keyframeMetadata;
  47. while (flag) {
  48. keyData = kf[i];
  49. nextKeyData = kf[i + 1];
  50. if ((nextKeyData.t - this.offsetTime) > frameNum) {
  51. break;
  52. }
  53. if (i < len - 1) {
  54. i += 1;
  55. } else {
  56. flag = false;
  57. }
  58. }
  59. keyframeMetadata = this.keyframesMetadata[i] || {};
  60. isHold = keyData.h === 1;
  61. iterationIndex = i;
  62. if (!isHold) {
  63. if (frameNum >= nextKeyData.t - this.offsetTime) {
  64. perc = 1;
  65. } else if (frameNum < keyData.t - this.offsetTime) {
  66. perc = 0;
  67. } else {
  68. var fnc;
  69. if (keyframeMetadata.__fnct) {
  70. fnc = keyframeMetadata.__fnct;
  71. } else {
  72. fnc = BezierFactory.getBezierEasing(keyData.o.x, keyData.o.y, keyData.i.x, keyData.i.y).get;
  73. keyframeMetadata.__fnct = fnc;
  74. }
  75. perc = fnc((frameNum - (keyData.t - this.offsetTime)) / ((nextKeyData.t - this.offsetTime) - (keyData.t - this.offsetTime)));
  76. }
  77. keyPropE = nextKeyData.s ? nextKeyData.s[0] : keyData.e[0];
  78. }
  79. keyPropS = keyData.s[0];
  80. }
  81. jLen = previousValue._length;
  82. kLen = keyPropS.i[0].length;
  83. caching.lastIndex = iterationIndex;
  84. for (j = 0; j < jLen; j += 1) {
  85. for (k = 0; k < kLen; k += 1) {
  86. vertexValue = isHold ? keyPropS.i[j][k] : keyPropS.i[j][k] + (keyPropE.i[j][k] - keyPropS.i[j][k]) * perc;
  87. previousValue.i[j][k] = vertexValue;
  88. vertexValue = isHold ? keyPropS.o[j][k] : keyPropS.o[j][k] + (keyPropE.o[j][k] - keyPropS.o[j][k]) * perc;
  89. previousValue.o[j][k] = vertexValue;
  90. vertexValue = isHold ? keyPropS.v[j][k] : keyPropS.v[j][k] + (keyPropE.v[j][k] - keyPropS.v[j][k]) * perc;
  91. previousValue.v[j][k] = vertexValue;
  92. }
  93. }
  94. }
  95. function interpolateShapeCurrentTime() {
  96. var frameNum = this.comp.renderedFrame - this.offsetTime;
  97. var initTime = this.keyframes[0].t - this.offsetTime;
  98. var endTime = this.keyframes[this.keyframes.length - 1].t - this.offsetTime;
  99. var lastFrame = this._caching.lastFrame;
  100. if (!(lastFrame !== initFrame && ((lastFrame < initTime && frameNum < initTime) || (lastFrame > endTime && frameNum > endTime)))) {
  101. /// /
  102. this._caching.lastIndex = lastFrame < frameNum ? this._caching.lastIndex : 0;
  103. this.interpolateShape(frameNum, this.pv, this._caching);
  104. /// /
  105. }
  106. this._caching.lastFrame = frameNum;
  107. return this.pv;
  108. }
  109. function resetShape() {
  110. this.paths = this.localShapeCollection;
  111. }
  112. function shapesEqual(shape1, shape2) {
  113. if (shape1._length !== shape2._length || shape1.c !== shape2.c) {
  114. return false;
  115. }
  116. var i;
  117. var len = shape1._length;
  118. for (i = 0; i < len; i += 1) {
  119. if (shape1.v[i][0] !== shape2.v[i][0]
  120. || shape1.v[i][1] !== shape2.v[i][1]
  121. || shape1.o[i][0] !== shape2.o[i][0]
  122. || shape1.o[i][1] !== shape2.o[i][1]
  123. || shape1.i[i][0] !== shape2.i[i][0]
  124. || shape1.i[i][1] !== shape2.i[i][1]) {
  125. return false;
  126. }
  127. }
  128. return true;
  129. }
  130. function setVValue(newPath) {
  131. if (!shapesEqual(this.v, newPath)) {
  132. this.v = shapePool.clone(newPath);
  133. this.localShapeCollection.releaseShapes();
  134. this.localShapeCollection.addShape(this.v);
  135. this._mdf = true;
  136. this.paths = this.localShapeCollection;
  137. }
  138. }
  139. function processEffectsSequence() {
  140. if (this.elem.globalData.frameId === this.frameId) {
  141. return;
  142. } if (!this.effectsSequence.length) {
  143. this._mdf = false;
  144. return;
  145. }
  146. if (this.lock) {
  147. this.setVValue(this.pv);
  148. return;
  149. }
  150. this.lock = true;
  151. this._mdf = false;
  152. var finalValue;
  153. if (this.kf) {
  154. finalValue = this.pv;
  155. } else if (this.data.ks) {
  156. finalValue = this.data.ks.k;
  157. } else {
  158. finalValue = this.data.pt.k;
  159. }
  160. var i;
  161. var len = this.effectsSequence.length;
  162. for (i = 0; i < len; i += 1) {
  163. finalValue = this.effectsSequence[i](finalValue);
  164. }
  165. this.setVValue(finalValue);
  166. this.lock = false;
  167. this.frameId = this.elem.globalData.frameId;
  168. }
  169. function ShapeProperty(elem, data, type) {
  170. this.propType = 'shape';
  171. this.comp = elem.comp;
  172. this.container = elem;
  173. this.elem = elem;
  174. this.data = data;
  175. this.k = false;
  176. this.kf = false;
  177. this._mdf = false;
  178. var pathData = type === 3 ? data.pt.k : data.ks.k;
  179. this.v = shapePool.clone(pathData);
  180. this.pv = shapePool.clone(this.v);
  181. this.localShapeCollection = shapeCollectionPool.newShapeCollection();
  182. this.paths = this.localShapeCollection;
  183. this.paths.addShape(this.v);
  184. this.reset = resetShape;
  185. this.effectsSequence = [];
  186. }
  187. function addEffect(effectFunction) {
  188. this.effectsSequence.push(effectFunction);
  189. this.container.addDynamicProperty(this);
  190. }
  191. ShapeProperty.prototype.interpolateShape = interpolateShape;
  192. ShapeProperty.prototype.getValue = processEffectsSequence;
  193. ShapeProperty.prototype.setVValue = setVValue;
  194. ShapeProperty.prototype.addEffect = addEffect;
  195. function KeyframedShapeProperty(elem, data, type) {
  196. this.propType = 'shape';
  197. this.comp = elem.comp;
  198. this.elem = elem;
  199. this.container = elem;
  200. this.offsetTime = elem.data.st;
  201. this.keyframes = type === 3 ? data.pt.k : data.ks.k;
  202. this.keyframesMetadata = [];
  203. this.k = true;
  204. this.kf = true;
  205. var len = this.keyframes[0].s[0].i.length;
  206. this.v = shapePool.newElement();
  207. this.v.setPathData(this.keyframes[0].s[0].c, len);
  208. this.pv = shapePool.clone(this.v);
  209. this.localShapeCollection = shapeCollectionPool.newShapeCollection();
  210. this.paths = this.localShapeCollection;
  211. this.paths.addShape(this.v);
  212. this.lastFrame = initFrame;
  213. this.reset = resetShape;
  214. this._caching = { lastFrame: initFrame, lastIndex: 0 };
  215. this.effectsSequence = [interpolateShapeCurrentTime.bind(this)];
  216. }
  217. KeyframedShapeProperty.prototype.getValue = processEffectsSequence;
  218. KeyframedShapeProperty.prototype.interpolateShape = interpolateShape;
  219. KeyframedShapeProperty.prototype.setVValue = setVValue;
  220. KeyframedShapeProperty.prototype.addEffect = addEffect;
  221. var EllShapeProperty = (function () {
  222. var cPoint = roundCorner;
  223. function EllShapePropertyFactory(elem, data) {
  224. this.v = shapePool.newElement();
  225. this.v.setPathData(true, 4);
  226. this.localShapeCollection = shapeCollectionPool.newShapeCollection();
  227. this.paths = this.localShapeCollection;
  228. this.localShapeCollection.addShape(this.v);
  229. this.d = data.d;
  230. this.elem = elem;
  231. this.comp = elem.comp;
  232. this.frameId = -1;
  233. this.initDynamicPropertyContainer(elem);
  234. this.p = PropertyFactory.getProp(elem, data.p, 1, 0, this);
  235. this.s = PropertyFactory.getProp(elem, data.s, 1, 0, this);
  236. if (this.dynamicProperties.length) {
  237. this.k = true;
  238. } else {
  239. this.k = false;
  240. this.convertEllToPath();
  241. }
  242. }
  243. EllShapePropertyFactory.prototype = {
  244. reset: resetShape,
  245. getValue: function () {
  246. if (this.elem.globalData.frameId === this.frameId) {
  247. return;
  248. }
  249. this.frameId = this.elem.globalData.frameId;
  250. this.iterateDynamicProperties();
  251. if (this._mdf) {
  252. this.convertEllToPath();
  253. }
  254. },
  255. convertEllToPath: function () {
  256. var p0 = this.p.v[0];
  257. var p1 = this.p.v[1];
  258. var s0 = this.s.v[0] / 2;
  259. var s1 = this.s.v[1] / 2;
  260. var _cw = this.d !== 3;
  261. var _v = this.v;
  262. _v.v[0][0] = p0;
  263. _v.v[0][1] = p1 - s1;
  264. _v.v[1][0] = _cw ? p0 + s0 : p0 - s0;
  265. _v.v[1][1] = p1;
  266. _v.v[2][0] = p0;
  267. _v.v[2][1] = p1 + s1;
  268. _v.v[3][0] = _cw ? p0 - s0 : p0 + s0;
  269. _v.v[3][1] = p1;
  270. _v.i[0][0] = _cw ? p0 - s0 * cPoint : p0 + s0 * cPoint;
  271. _v.i[0][1] = p1 - s1;
  272. _v.i[1][0] = _cw ? p0 + s0 : p0 - s0;
  273. _v.i[1][1] = p1 - s1 * cPoint;
  274. _v.i[2][0] = _cw ? p0 + s0 * cPoint : p0 - s0 * cPoint;
  275. _v.i[2][1] = p1 + s1;
  276. _v.i[3][0] = _cw ? p0 - s0 : p0 + s0;
  277. _v.i[3][1] = p1 + s1 * cPoint;
  278. _v.o[0][0] = _cw ? p0 + s0 * cPoint : p0 - s0 * cPoint;
  279. _v.o[0][1] = p1 - s1;
  280. _v.o[1][0] = _cw ? p0 + s0 : p0 - s0;
  281. _v.o[1][1] = p1 + s1 * cPoint;
  282. _v.o[2][0] = _cw ? p0 - s0 * cPoint : p0 + s0 * cPoint;
  283. _v.o[2][1] = p1 + s1;
  284. _v.o[3][0] = _cw ? p0 - s0 : p0 + s0;
  285. _v.o[3][1] = p1 - s1 * cPoint;
  286. },
  287. };
  288. extendPrototype([DynamicPropertyContainer], EllShapePropertyFactory);
  289. return EllShapePropertyFactory;
  290. }());
  291. var StarShapeProperty = (function () {
  292. function StarShapePropertyFactory(elem, data) {
  293. this.v = shapePool.newElement();
  294. this.v.setPathData(true, 0);
  295. this.elem = elem;
  296. this.comp = elem.comp;
  297. this.data = data;
  298. this.frameId = -1;
  299. this.d = data.d;
  300. this.initDynamicPropertyContainer(elem);
  301. if (data.sy === 1) {
  302. this.ir = PropertyFactory.getProp(elem, data.ir, 0, 0, this);
  303. this.is = PropertyFactory.getProp(elem, data.is, 0, 0.01, this);
  304. this.convertToPath = this.convertStarToPath;
  305. } else {
  306. this.convertToPath = this.convertPolygonToPath;
  307. }
  308. this.pt = PropertyFactory.getProp(elem, data.pt, 0, 0, this);
  309. this.p = PropertyFactory.getProp(elem, data.p, 1, 0, this);
  310. this.r = PropertyFactory.getProp(elem, data.r, 0, degToRads, this);
  311. this.or = PropertyFactory.getProp(elem, data.or, 0, 0, this);
  312. this.os = PropertyFactory.getProp(elem, data.os, 0, 0.01, this);
  313. this.localShapeCollection = shapeCollectionPool.newShapeCollection();
  314. this.localShapeCollection.addShape(this.v);
  315. this.paths = this.localShapeCollection;
  316. if (this.dynamicProperties.length) {
  317. this.k = true;
  318. } else {
  319. this.k = false;
  320. this.convertToPath();
  321. }
  322. }
  323. StarShapePropertyFactory.prototype = {
  324. reset: resetShape,
  325. getValue: function () {
  326. if (this.elem.globalData.frameId === this.frameId) {
  327. return;
  328. }
  329. this.frameId = this.elem.globalData.frameId;
  330. this.iterateDynamicProperties();
  331. if (this._mdf) {
  332. this.convertToPath();
  333. }
  334. },
  335. convertStarToPath: function () {
  336. var numPts = Math.floor(this.pt.v) * 2;
  337. var angle = (Math.PI * 2) / numPts;
  338. /* this.v.v.length = numPts;
  339. this.v.i.length = numPts;
  340. this.v.o.length = numPts; */
  341. var longFlag = true;
  342. var longRad = this.or.v;
  343. var shortRad = this.ir.v;
  344. var longRound = this.os.v;
  345. var shortRound = this.is.v;
  346. var longPerimSegment = (2 * Math.PI * longRad) / (numPts * 2);
  347. var shortPerimSegment = (2 * Math.PI * shortRad) / (numPts * 2);
  348. var i;
  349. var rad;
  350. var roundness;
  351. var perimSegment;
  352. var currentAng = -Math.PI / 2;
  353. currentAng += this.r.v;
  354. var dir = this.data.d === 3 ? -1 : 1;
  355. this.v._length = 0;
  356. for (i = 0; i < numPts; i += 1) {
  357. rad = longFlag ? longRad : shortRad;
  358. roundness = longFlag ? longRound : shortRound;
  359. perimSegment = longFlag ? longPerimSegment : shortPerimSegment;
  360. var x = rad * Math.cos(currentAng);
  361. var y = rad * Math.sin(currentAng);
  362. var ox = x === 0 && y === 0 ? 0 : y / Math.sqrt(x * x + y * y);
  363. var oy = x === 0 && y === 0 ? 0 : -x / Math.sqrt(x * x + y * y);
  364. x += +this.p.v[0];
  365. y += +this.p.v[1];
  366. this.v.setTripleAt(x, y, x - ox * perimSegment * roundness * dir, y - oy * perimSegment * roundness * dir, x + ox * perimSegment * roundness * dir, y + oy * perimSegment * roundness * dir, i, true);
  367. /* this.v.v[i] = [x,y];
  368. this.v.i[i] = [x+ox*perimSegment*roundness*dir,y+oy*perimSegment*roundness*dir];
  369. this.v.o[i] = [x-ox*perimSegment*roundness*dir,y-oy*perimSegment*roundness*dir];
  370. this.v._length = numPts; */
  371. longFlag = !longFlag;
  372. currentAng += angle * dir;
  373. }
  374. },
  375. convertPolygonToPath: function () {
  376. var numPts = Math.floor(this.pt.v);
  377. var angle = (Math.PI * 2) / numPts;
  378. var rad = this.or.v;
  379. var roundness = this.os.v;
  380. var perimSegment = (2 * Math.PI * rad) / (numPts * 4);
  381. var i;
  382. var currentAng = -Math.PI * 0.5;
  383. var dir = this.data.d === 3 ? -1 : 1;
  384. currentAng += this.r.v;
  385. this.v._length = 0;
  386. for (i = 0; i < numPts; i += 1) {
  387. var x = rad * Math.cos(currentAng);
  388. var y = rad * Math.sin(currentAng);
  389. var ox = x === 0 && y === 0 ? 0 : y / Math.sqrt(x * x + y * y);
  390. var oy = x === 0 && y === 0 ? 0 : -x / Math.sqrt(x * x + y * y);
  391. x += +this.p.v[0];
  392. y += +this.p.v[1];
  393. this.v.setTripleAt(x, y, x - ox * perimSegment * roundness * dir, y - oy * perimSegment * roundness * dir, x + ox * perimSegment * roundness * dir, y + oy * perimSegment * roundness * dir, i, true);
  394. currentAng += angle * dir;
  395. }
  396. this.paths.length = 0;
  397. this.paths[0] = this.v;
  398. },
  399. };
  400. extendPrototype([DynamicPropertyContainer], StarShapePropertyFactory);
  401. return StarShapePropertyFactory;
  402. }());
  403. var RectShapeProperty = (function () {
  404. function RectShapePropertyFactory(elem, data) {
  405. this.v = shapePool.newElement();
  406. this.v.c = true;
  407. this.localShapeCollection = shapeCollectionPool.newShapeCollection();
  408. this.localShapeCollection.addShape(this.v);
  409. this.paths = this.localShapeCollection;
  410. this.elem = elem;
  411. this.comp = elem.comp;
  412. this.frameId = -1;
  413. this.d = data.d;
  414. this.initDynamicPropertyContainer(elem);
  415. this.p = PropertyFactory.getProp(elem, data.p, 1, 0, this);
  416. this.s = PropertyFactory.getProp(elem, data.s, 1, 0, this);
  417. this.r = PropertyFactory.getProp(elem, data.r, 0, 0, this);
  418. if (this.dynamicProperties.length) {
  419. this.k = true;
  420. } else {
  421. this.k = false;
  422. this.convertRectToPath();
  423. }
  424. }
  425. RectShapePropertyFactory.prototype = {
  426. convertRectToPath: function () {
  427. var p0 = this.p.v[0];
  428. var p1 = this.p.v[1];
  429. var v0 = this.s.v[0] / 2;
  430. var v1 = this.s.v[1] / 2;
  431. var round = bmMin(v0, v1, this.r.v);
  432. var cPoint = round * (1 - roundCorner);
  433. this.v._length = 0;
  434. if (this.d === 2 || this.d === 1) {
  435. this.v.setTripleAt(p0 + v0, p1 - v1 + round, p0 + v0, p1 - v1 + round, p0 + v0, p1 - v1 + cPoint, 0, true);
  436. this.v.setTripleAt(p0 + v0, p1 + v1 - round, p0 + v0, p1 + v1 - cPoint, p0 + v0, p1 + v1 - round, 1, true);
  437. if (round !== 0) {
  438. this.v.setTripleAt(p0 + v0 - round, p1 + v1, p0 + v0 - round, p1 + v1, p0 + v0 - cPoint, p1 + v1, 2, true);
  439. this.v.setTripleAt(p0 - v0 + round, p1 + v1, p0 - v0 + cPoint, p1 + v1, p0 - v0 + round, p1 + v1, 3, true);
  440. this.v.setTripleAt(p0 - v0, p1 + v1 - round, p0 - v0, p1 + v1 - round, p0 - v0, p1 + v1 - cPoint, 4, true);
  441. this.v.setTripleAt(p0 - v0, p1 - v1 + round, p0 - v0, p1 - v1 + cPoint, p0 - v0, p1 - v1 + round, 5, true);
  442. this.v.setTripleAt(p0 - v0 + round, p1 - v1, p0 - v0 + round, p1 - v1, p0 - v0 + cPoint, p1 - v1, 6, true);
  443. this.v.setTripleAt(p0 + v0 - round, p1 - v1, p0 + v0 - cPoint, p1 - v1, p0 + v0 - round, p1 - v1, 7, true);
  444. } else {
  445. this.v.setTripleAt(p0 - v0, p1 + v1, p0 - v0 + cPoint, p1 + v1, p0 - v0, p1 + v1, 2);
  446. this.v.setTripleAt(p0 - v0, p1 - v1, p0 - v0, p1 - v1 + cPoint, p0 - v0, p1 - v1, 3);
  447. }
  448. } else {
  449. this.v.setTripleAt(p0 + v0, p1 - v1 + round, p0 + v0, p1 - v1 + cPoint, p0 + v0, p1 - v1 + round, 0, true);
  450. if (round !== 0) {
  451. this.v.setTripleAt(p0 + v0 - round, p1 - v1, p0 + v0 - round, p1 - v1, p0 + v0 - cPoint, p1 - v1, 1, true);
  452. this.v.setTripleAt(p0 - v0 + round, p1 - v1, p0 - v0 + cPoint, p1 - v1, p0 - v0 + round, p1 - v1, 2, true);
  453. this.v.setTripleAt(p0 - v0, p1 - v1 + round, p0 - v0, p1 - v1 + round, p0 - v0, p1 - v1 + cPoint, 3, true);
  454. this.v.setTripleAt(p0 - v0, p1 + v1 - round, p0 - v0, p1 + v1 - cPoint, p0 - v0, p1 + v1 - round, 4, true);
  455. this.v.setTripleAt(p0 - v0 + round, p1 + v1, p0 - v0 + round, p1 + v1, p0 - v0 + cPoint, p1 + v1, 5, true);
  456. this.v.setTripleAt(p0 + v0 - round, p1 + v1, p0 + v0 - cPoint, p1 + v1, p0 + v0 - round, p1 + v1, 6, true);
  457. this.v.setTripleAt(p0 + v0, p1 + v1 - round, p0 + v0, p1 + v1 - round, p0 + v0, p1 + v1 - cPoint, 7, true);
  458. } else {
  459. this.v.setTripleAt(p0 - v0, p1 - v1, p0 - v0 + cPoint, p1 - v1, p0 - v0, p1 - v1, 1, true);
  460. this.v.setTripleAt(p0 - v0, p1 + v1, p0 - v0, p1 + v1 - cPoint, p0 - v0, p1 + v1, 2, true);
  461. this.v.setTripleAt(p0 + v0, p1 + v1, p0 + v0 - cPoint, p1 + v1, p0 + v0, p1 + v1, 3, true);
  462. }
  463. }
  464. },
  465. getValue: function () {
  466. if (this.elem.globalData.frameId === this.frameId) {
  467. return;
  468. }
  469. this.frameId = this.elem.globalData.frameId;
  470. this.iterateDynamicProperties();
  471. if (this._mdf) {
  472. this.convertRectToPath();
  473. }
  474. },
  475. reset: resetShape,
  476. };
  477. extendPrototype([DynamicPropertyContainer], RectShapePropertyFactory);
  478. return RectShapePropertyFactory;
  479. }());
  480. function getShapeProp(elem, data, type) {
  481. var prop;
  482. if (type === 3 || type === 4) {
  483. var dataProp = type === 3 ? data.pt : data.ks;
  484. var keys = dataProp.k;
  485. if (keys.length) {
  486. prop = new KeyframedShapeProperty(elem, data, type);
  487. } else {
  488. prop = new ShapeProperty(elem, data, type);
  489. }
  490. } else if (type === 5) {
  491. prop = new RectShapeProperty(elem, data);
  492. } else if (type === 6) {
  493. prop = new EllShapeProperty(elem, data);
  494. } else if (type === 7) {
  495. prop = new StarShapeProperty(elem, data);
  496. }
  497. if (prop.k) {
  498. elem.addDynamicProperty(prop);
  499. }
  500. return prop;
  501. }
  502. function getConstructorFunction() {
  503. return ShapeProperty;
  504. }
  505. function getKeyframedConstructorFunction() {
  506. return KeyframedShapeProperty;
  507. }
  508. var ob = {};
  509. ob.getShapeProp = getShapeProp;
  510. ob.getConstructorFunction = getConstructorFunction;
  511. ob.getKeyframedConstructorFunction = getKeyframedConstructorFunction;
  512. return ob;
  513. }());
  514. export default ShapePropertyFactory;