2020-03-10 20:15:47 +08:00
|
|
|
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: {
|
2020-03-12 14:41:53 +08:00
|
|
|
stroke:'#00FF00',
|
2020-03-10 20:15:47 +08:00
|
|
|
lineWidth: 0.5,
|
2020-03-12 14:41:53 +08:00
|
|
|
fill: '#00FF00'
|
2020-03-10 20:15:47 +08:00
|
|
|
}
|
|
|
|
});
|
|
|
|
this.add(this.angle);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
updateTriangle(model, right) {
|
|
|
|
const trainRight = right == 1 ? 1 : -1;
|
|
|
|
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 });
|
2020-03-10 20:24:24 +08:00
|
|
|
this.angle.attr({
|
|
|
|
shape: {
|
|
|
|
points:data
|
|
|
|
}
|
|
|
|
});
|
2020-03-10 20:15:47 +08:00
|
|
|
this.angle.animateTo({
|
|
|
|
shape: {
|
|
|
|
points:data
|
|
|
|
}
|
|
|
|
}, 10, 0, 'elasticOut', function () {
|
|
|
|
});
|
|
|
|
this.dirty();
|
|
|
|
}
|
|
|
|
}
|