78 lines
1.5 KiB
JavaScript
78 lines
1.5 KiB
JavaScript
import Group from 'zrender/src/container/Group';
|
|
import Line from 'zrender/src/graphic/shape/Line';
|
|
|
|
class ESwCore extends Group {
|
|
constructor(model) {
|
|
super();
|
|
this.model = model;
|
|
this.create();
|
|
}
|
|
|
|
create() {
|
|
const model = this.model;
|
|
const style = this.model.style;
|
|
this.skewLine = new Line({
|
|
zlevel: model.zlevel,
|
|
z: model.z,
|
|
silent: true,
|
|
shape: {
|
|
x1: model.intersectionX,
|
|
y1: model.intersectionY,
|
|
x2: model.intersectionX + model.triangle.drictx * model.triangle.getCotRate() * model.coverLength,
|
|
y2: model.intersectionY + model.triangle.dricty * model.coverLength
|
|
},
|
|
style: {
|
|
lineWidth: model.lineWidth,
|
|
stroke: style.backgroundColor
|
|
}
|
|
});
|
|
|
|
this.line = new Line({
|
|
zlevel: model.zlevel,
|
|
z: model.z,
|
|
silent: true,
|
|
shape: {
|
|
x1: model.intersectionX - model.triangle.getCotRate() * model.coverLength,
|
|
y1: model.intersectionY,
|
|
x2: model.intersectionX + model.triangle.getCotRate() * model.coverLength,
|
|
y2: model.intersectionY
|
|
},
|
|
style: {
|
|
lineWidth: model.lineWidth,
|
|
stroke: style.backgroundColor
|
|
}
|
|
});
|
|
|
|
this.add(this.line);
|
|
this.add(this.skewLine);
|
|
}
|
|
|
|
hide() {
|
|
this.line.hide();
|
|
this.skewLine.hide();
|
|
}
|
|
|
|
show() {
|
|
this.line.show();
|
|
this.skewLine.show();
|
|
}
|
|
|
|
setColor(color) {
|
|
this.line.setStyle('stroke', color);
|
|
this.skewLine.setStyle('stroke', color);
|
|
}
|
|
|
|
stopAnimation(flag) {
|
|
this.line.stopAnimation(flag);
|
|
this.skewLine.stopAnimation(flag);
|
|
}
|
|
|
|
animateStyle(cb) {
|
|
this.eachChild((child) => {
|
|
cb(child);
|
|
});
|
|
}
|
|
}
|
|
|
|
export default ESwCore;
|