Make line colors more different, fix line interpolation having no tension

main
Chris Vickery 2019-11-06 16:51:12 -08:00
parent f5b3c9cc41
commit 02d1969cd5
4 changed files with 18 additions and 10 deletions

View File

@ -44,6 +44,7 @@
"node-sass": "^4.12.0",
"prettier": "^1.9.2",
"prop-types": "^15.5.10",
"randomcolor": "^0.5.4",
"raven-js": "^3.16.0",
"react": "^16.2.0",
"react-dom": "^16.2.0",

View File

@ -1,3 +1,4 @@
import randomcolor from 'randomcolor';
import DbcUtils from '../../utils/dbc';
export default class Signal {
@ -165,17 +166,20 @@ export default class Signal {
}
getColors(messageId) {
const parts = messageId.split(':').map((p) => ((3 + Number.parseInt(p, 16)) * 3) % 253);
let parts = messageId.split(':').map((p) => ((3 + Number.parseInt(p, 16)) * 3) % 253);
const colors = this._colors || this.generateColors();
return colors.map((c) => parts.reduce((m, v) => m ^ v, c));
let lastColor = 0;
return colors.map((c) => {
parts = parts.map(p => p ^ lastColor);
lastColor = parts.reduce((m, v) => m ^ v, c);
return lastColor;
});
}
generateColors() {
const colors = Array(3);
for (let i = 0; i < 3; i++) {
colors[i] = Math.floor(Math.random() * 211);
}
const colors = randomcolor({ format: 'rgbArray' });
return colors;
}

View File

@ -269,10 +269,8 @@ export default {
"interactive": true,
"encode": {
"update": {
"interpolate": {
"value": "cardinal",
"tension": 1
},
"interpolate": "cardinal",
"tension": 0,
"x": {
"scale": "xrelscale",
"field": "relTime"

View File

@ -10649,6 +10649,11 @@ randombytes@^2.0.0, randombytes@^2.0.1, randombytes@^2.0.5:
dependencies:
safe-buffer "^5.1.0"
randomcolor@^0.5.4:
version "0.5.4"
resolved "https://registry.yarnpkg.com/randomcolor/-/randomcolor-0.5.4.tgz#df615b13f25b89ea58c5f8f72647f0a6f07adcc3"
integrity sha512-nYd4nmTuuwMFzHL6W+UWR5fNERGZeVauho8mrJDUSXdNDbao4rbrUwhuLgKC/j8VCS5+34Ria8CsTDuBjrIrQA==
randomfill@^1.0.3:
version "1.0.4"
resolved "https://registry.yarnpkg.com/randomfill/-/randomfill-1.0.4.tgz#c92196fc86ab42be983f1bf31778224931d61458"