Implement possibility to export current states and connections and re-import these later

This commit is contained in:
KingOfDog
2019-03-04 10:29:32 +01:00
parent e5cdf549d2
commit 1af3c8a72e
4 changed files with 168 additions and 17 deletions

View File

@@ -1,11 +1,14 @@
class State {
constructor(x, y) {
this.id = guid();
this.x = x;
this.y = y;
this.mouseOffsetX = 0;
this.mouseOffsetY = 0;
this.color = '#f0f';
this.isActive = false;
this.activeTime = 0;
this.isAcceptState = false;
this.text = '';
}
@@ -21,7 +24,9 @@ class State {
}
draw() {
ctx.fillStyle = this.color;
const activeTimeDuration = Date.now() - this.activeTime;
ctx.fillStyle = this.isActive && activeTimeDuration > simulationStepDuration ? '#0f0' : this.color;
ctx.strokeStyle = settings.colors.getColor(this);
ctx.beginPath();
@@ -32,6 +37,26 @@ class State {
ctx.closePath();
if(activeTimeDuration < simulationStepDuration) {
let size = 0;
const percent = Math.min(Math.max(activeTimeDuration / simulationStepDuration, 0), 1);
if(this.isActive) {
size = easeInOutCubic(percent) * radius;
} else {
size = easeInOutCubic(1 - percent) * radius;
}
ctx.fillStyle = '#0f0';
ctx.beginPath();
ctx.arc(this.x, this.y, size, 0, 2 * Math.PI);
ctx.fill();
ctx.closePath();
}
ctx.fillStyle = settings.colors.getColor(this);
ctx.drawText(this.text, this.x, this.y, null, selectedObject === this);