63 lines
2.1 KiB
JavaScript
63 lines
2.1 KiB
JavaScript
|
import Group from 'zrender/src/container/Group';
|
||
|
import Polygon from 'zrender/src/graphic/shape/Polygon';
|
||
|
|
||
|
/** 创建三角形*/
|
||
|
export default class ETriangle extends Group {
|
||
|
constructor(model) {
|
||
|
super();
|
||
|
this.model = model;
|
||
|
this.zlevel = model.zlevel;
|
||
|
this.z = model.z;
|
||
|
this.create(model);
|
||
|
}
|
||
|
|
||
|
create(model) {
|
||
|
if (model && model.point) {
|
||
|
const right = model.right == 1 ? 1 : -1;
|
||
|
this.angle = new Polygon({
|
||
|
zlevel: model.zlevel,
|
||
|
z: model.z,
|
||
|
shape: {
|
||
|
points:[[model.point.x + 10 * right, model.point.y], [model.point.x, model.point.y - 6], [model.point.x, model.point.y + 6]]
|
||
|
},
|
||
|
style: {
|
||
|
stroke:'#FFFF00',
|
||
|
lineWidth: 0.5,
|
||
|
fill: '#FFFF00'
|
||
|
}
|
||
|
});
|
||
|
this.add(this.angle);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
updateTriangle(model, right) {
|
||
|
const trainRight = right == 1 ? 1 : -1;
|
||
|
// const data = this.angle.shape.points;
|
||
|
// this.angle.shape.points.pop();
|
||
|
// this.angle.shape.points.pop();
|
||
|
// this.angle.shape.points.pop();
|
||
|
// this.angle.shape.points.push([model.x + 10 * trainRight, model.y]);
|
||
|
// this.angle.shape.points.push([model.x, model.y - 6]);
|
||
|
// this.angle.shape.points.push([model.x, model.y + 6]);
|
||
|
const data = [[model.x + 10 * trainRight, model.y], [model.x, model.y - 6], [model.x, model.y + 6]];
|
||
|
// this.angle.shape.points.push([model.x + 10 * trainRight, model.y]);
|
||
|
// this.angle.attr('shape', { points: this.angle.shape.points });
|
||
|
// this.angle.attr({
|
||
|
// shape: {
|
||
|
// points:data
|
||
|
// }
|
||
|
// });
|
||
|
// const object = this.angle;
|
||
|
this.angle.animateTo({
|
||
|
shape: {
|
||
|
points:data
|
||
|
}
|
||
|
}, 10, 0, 'elasticOut', function () {
|
||
|
// done
|
||
|
// object.stopAnimation(true);
|
||
|
});
|
||
|
// this.angle.setS
|
||
|
this.dirty();
|
||
|
}
|
||
|
}
|