Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | export default class LinearScale { constructor(domain, range) { this.domain = domain this.range = range } compute(val) { const { domain: d, range: r } = this return ((val - d[0]) / (d[1] - d[0])) * (r[1] - r[0]) + r[0] } invert(val) { const { domain: d, range: r } = this return ((val - r[0]) / (r[1] - r[0])) * (d[1] - d[0]) + d[0] } } |