Skip to content

Commit

Permalink
sensor value styling
Browse files Browse the repository at this point in the history
  • Loading branch information
SillyFreak committed Aug 25, 2020
1 parent 582cc0b commit 9d49251
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
13 changes: 3 additions & 10 deletions src/components/ide/Simulator/simulation/Robot.js
Expand Up @@ -55,14 +55,10 @@ export default class Robot {
},
};
const styleLineSensor = {
render: {
fillStyle: '#777777',
},
// fillStyle controlled by sensor
};
const styleTouchSensor = {
render: {
fillStyle: '#777777',
},
// fillStyle controlled by sensor
};
const styleDistanceSensor = {
render: {
Expand All @@ -73,10 +69,7 @@ export default class Robot {
isSensor: true,
density: 0,
frictionAir: 0,
render: {
fillStyle: '#555555',
opacity: 0.2,
},
// fillStyle & opacity controlled by sensor
};
// const styleGrabber = {
// render: {
Expand Down
12 changes: 10 additions & 2 deletions src/components/ide/Simulator/simulation/sensors.js
Expand Up @@ -94,6 +94,9 @@ export class SimpleCollisionSensor extends CollisionSensor {
colliding = this.isColliding();
}

// update sensor body style
this.sensorBody.render.fillStyle = colliding ? '#ffa500' : '#777777';

const value = colliding ? this.values[1] : this.values[0];
this.controller.setSensor(this.port, value);
}
Expand Down Expand Up @@ -185,12 +188,17 @@ export class DistanceSensor {
distance = this.getDistance();
}


// update sensor segment styles
for (const segment of this.segments) {
if (segment.distance < distance) {
segment.sensorBody.render.opacity = 0.2;
segment.sensorBody.render.fillStyle = '#555555';
segment.sensorBody.render.opacity = 0.4;
} else if (segment.distance === distance) {
segment.sensorBody.render.opacity = 0.7;
segment.sensorBody.render.fillStyle = '#000000';
segment.sensorBody.render.opacity = 0.8;
} else {
segment.sensorBody.render.fillStyle = '#555555';
segment.sensorBody.render.opacity = 0.05;
}
}
Expand Down

0 comments on commit 9d49251

Please sign in to comment.