Implement possibility to export current states and connections and re-import these later
This commit is contained in:
@@ -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);
|
||||
|
||||
|
Reference in New Issue
Block a user