diff options
author | Ulrich-Matthias Schäfer <ulima.ums@googlemail.com> | 2019-11-01 13:37:24 +0100 |
---|---|---|
committer | Ulrich-Matthias Schäfer <ulima.ums@googlemail.com> | 2019-11-01 13:37:24 +0100 |
commit | 2827a27531c661726d204d6da9d17c6f72d8e404 (patch) | |
tree | a4180b1f462685cce0c314be16511a630d222b05 /src/types | |
parent | 0748382e9859c31253d93b0c258487da362bcade (diff) | |
download | svg.js-2827a27531c661726d204d6da9d17c6f72d8e404.tar.gz svg.js-2827a27531c661726d204d6da9d17c6f72d8e404.zip |
Updated dependencies to newest version, new linter fixed stuff
Diffstat (limited to 'src/types')
-rw-r--r-- | src/types/Box.js | 16 | ||||
-rw-r--r-- | src/types/Color.js | 26 | ||||
-rw-r--r-- | src/types/EventTarget.js | 4 | ||||
-rw-r--r-- | src/types/List.js | 2 | ||||
-rw-r--r-- | src/types/Matrix.js | 22 | ||||
-rw-r--r-- | src/types/PathArray.js | 4 | ||||
-rw-r--r-- | src/types/Point.js | 7 |
7 files changed, 40 insertions, 41 deletions
diff --git a/src/types/Box.js b/src/types/Box.js index 7621029..5c31535 100644 --- a/src/types/Box.js +++ b/src/types/Box.js @@ -51,10 +51,10 @@ export default class Box { // Merge rect box with another, return a new instance merge (box) { - let x = Math.min(this.x, box.x) - let y = Math.min(this.y, box.y) - let width = Math.max(this.x + this.width, box.x + box.width) - x - let height = Math.max(this.y + this.height, box.y + box.height) - y + const x = Math.min(this.x, box.x) + const y = Math.min(this.y, box.y) + const width = Math.max(this.x + this.width, box.x + box.width) - x + const height = Math.max(this.y + this.height, box.y + box.height) - y return new Box(x, y, width, height) } @@ -69,7 +69,7 @@ export default class Box { let yMin = Infinity let yMax = -Infinity - let pts = [ + const pts = [ new Point(this.x, this.y), new Point(this.x2, this.y), new Point(this.x, this.y2), @@ -130,8 +130,8 @@ function getBox (cb, retry) { export function bbox () { return new Box(getBox.call(this, (node) => node.getBBox(), (el) => { try { - let clone = el.clone().addTo(parser().svg).show() - let box = clone.node.getBBox() + const clone = el.clone().addTo(parser().svg).show() + const box = clone.node.getBBox() clone.remove() return box } catch (e) { @@ -141,7 +141,7 @@ export function bbox () { } export function rbox (el) { - let box = new Box(getBox.call(this, (node) => node.getBoundingClientRect(), (el) => { + const box = new Box(getBox.call(this, (node) => node.getBoundingClientRect(), (el) => { throw new Error('Getting rbox of element "' + el.node.nodeName + '" is not possible') })) if (el) return box.transform(el.screenCTM().inverse()) diff --git a/src/types/Color.js b/src/types/Color.js index 74f20df..e9bc0ce 100644 --- a/src/types/Color.js +++ b/src/types/Color.js @@ -68,7 +68,7 @@ export default class Color { // Reset all values in case the init function is rerun with new color space if (this.space) { - for (let component in this.space) { + for (const component in this.space) { delete this[this.space[component]] } } @@ -98,7 +98,7 @@ export default class Color { const hexParse = v => parseInt(v, 16) const [ , _a, _b, _c ] = hex.exec(sixDigitHex(a)).map(hexParse) Object.assign(this, { _a, _b, _c, _d: 0, space: 'rgb' }) - } else throw Error(`Unsupported string format, can't construct Color`) + } else throw Error('Unsupported string format, can\'t construct Color') } // Now add the components as a convenience @@ -127,7 +127,7 @@ export default class Color { // Get the values in the lab space let { l, a, b } = this if (this.space === 'lch') { - let { c, h } = this + const { c, h } = this const dToR = Math.PI / 180 a = c * Math.cos(dToR * h) b = c * Math.sin(dToR * h) @@ -153,8 +153,8 @@ export default class Color { const bU = x * 0.0557 + y * -0.2040 + z * 1.0570 // Convert the values to true rgb values - let pow = Math.pow - let bd = 0.0031308 + const pow = Math.pow + const bd = 0.0031308 const r = (rU > bd) ? (1.055 * pow(rU, 1 / 2.4) - 0.055) : 12.92 * rU const g = (gU > bd) ? (1.055 * pow(gU, 1 / 2.4) - 0.055) : 12.92 * gU const b = (bU > bd) ? (1.055 * pow(bU, 1 / 2.4) - 0.055) : 12.92 * bU @@ -173,7 +173,7 @@ export default class Color { // If we are grey, then just make the color directly if (s === 0) { l *= 255 - let color = new Color(l, l, l) + const color = new Color(l, l, l) return color } @@ -323,14 +323,14 @@ export default class Color { */ _clamped () { - let { _a, _b, _c } = this.rgb() - let { max, min, round } = Math - let format = v => max(0, min(round(v), 255)) + const { _a, _b, _c } = this.rgb() + const { max, min, round } = Math + const format = v => max(0, min(round(v), 255)) return [ _a, _b, _c ].map(format) } toHex () { - let [ r, g, b ] = this._clamped().map(componentHex) + const [ r, g, b ] = this._clamped().map(componentHex) return `#${r}${g}${b}` } @@ -339,13 +339,13 @@ export default class Color { } toRgb () { - let [ rV, gV, bV ] = this._clamped() - let string = `rgb(${rV},${gV},${bV})` + const [ rV, gV, bV ] = this._clamped() + const string = `rgb(${rV},${gV},${bV})` return string } toArray () { - let { _a, _b, _c, _d, space } = this + const { _a, _b, _c, _d, space } = this return [ _a, _b, _c, _d, space ] } diff --git a/src/types/EventTarget.js b/src/types/EventTarget.js index 06fc9a1..b4a137a 100644 --- a/src/types/EventTarget.js +++ b/src/types/EventTarget.js @@ -20,8 +20,8 @@ export default class EventTarget extends Base { const events = bag[event.type] - for (let i in events) { - for (let j in events[i]) { + for (const i in events) { + for (const j in events[i]) { events[i][j](event) } } diff --git a/src/types/List.js b/src/types/List.js index f66e3cd..27f1d5d 100644 --- a/src/types/List.js +++ b/src/types/List.js @@ -28,7 +28,7 @@ extend(List, { } }) -const reserved = ['toArray', 'constructor', 'each'] +const reserved = [ 'toArray', 'constructor', 'each' ] List.extend = function (methods) { methods = methods.reduce((obj, name) => { diff --git a/src/types/Matrix.js b/src/types/Matrix.js index c9bf435..c42adf7 100644 --- a/src/types/Matrix.js +++ b/src/types/Matrix.js @@ -53,7 +53,7 @@ export default class Matrix { // Get the proposed transformations and the current transformations var t = Matrix.formatTransforms(o) var current = this - let { x: ox, y: oy } = new Point(t.ox, t.oy).transform(current) + const { x: ox, y: oy } = new Point(t.ox, t.oy).transform(current) // Construct the resulting matrix var transformer = new Matrix() @@ -136,8 +136,8 @@ export default class Matrix { var sy = ((c * sx) / (lam * a - b)) || ((d * sx) / (lam * b + a)) // Use the translations - let tx = e - cx + cx * ct * sx + cy * (lam * ct * sx - st * sy) - let ty = f - cy + cx * st * sx + cy * (lam * st * sx + ct * sy) + const tx = e - cx + cx * ct * sx + cy * (lam * ct * sx - st * sy) + const ty = f - cy + cx * st * sx + cy * (lam * st * sx + ct * sy) // Construct the decomposition and return it return { @@ -252,7 +252,7 @@ export default class Matrix { y = x } - let { a, b, c, d, e, f } = this + const { a, b, c, d, e, f } = this this.a = a * x this.b = b * y @@ -273,10 +273,10 @@ export default class Matrix { // Convert degrees to radians r = radians(r) - let cos = Math.cos(r) - let sin = Math.sin(r) + const cos = Math.cos(r) + const sin = Math.sin(r) - let { a, b, c, d, e, f } = this + const { a, b, c, d, e, f } = this this.a = a * cos - b * sin this.b = b * cos + a * sin @@ -305,7 +305,7 @@ export default class Matrix { } shearO (lx, cx = 0, cy = 0) { - let { a, b, c, d, e, f } = this + const { a, b, c, d, e, f } = this this.a = a + b * lx this.c = c + d * lx @@ -331,10 +331,10 @@ export default class Matrix { x = radians(x) y = radians(y) - let lx = Math.tan(x) - let ly = Math.tan(y) + const lx = Math.tan(x) + const ly = Math.tan(y) - let { a, b, c, d, e, f } = this + const { a, b, c, d, e, f } = this this.a = a + b * lx this.b = b + a * ly diff --git a/src/types/PathArray.js b/src/types/PathArray.js index 56df5b6..f124b1b 100644 --- a/src/types/PathArray.js +++ b/src/types/PathArray.js @@ -108,7 +108,7 @@ const pathHandlers = { } } -let mlhvqtcsaz = 'mlhvqtcsaz'.split('') +const mlhvqtcsaz = 'mlhvqtcsaz'.split('') for (var i = 0, il = mlhvqtcsaz.length; i < il; ++i) { pathHandlers[mlhvqtcsaz[i]] = (function (i) { @@ -290,7 +290,7 @@ extend(PathArray, { // prepare for parsing var s - var paramCnt = { 'M': 2, 'L': 2, 'H': 1, 'V': 1, 'C': 6, 'S': 4, 'Q': 4, 'T': 2, 'A': 7, 'Z': 0 } + var paramCnt = { M: 2, L: 2, H: 1, V: 1, C: 6, S: 4, Q: 4, T: 2, A: 7, Z: 0 } if (typeof array === 'string') { array = array diff --git a/src/types/Point.js b/src/types/Point.js index 329b37d..634ffff 100644 --- a/src/types/Point.js +++ b/src/types/Point.js @@ -7,11 +7,10 @@ export default class Point { } init (x, y) { - let source - let base = { x: 0, y: 0 } + const base = { x: 0, y: 0 } // ensure source as object - source = Array.isArray(x) ? { x: x[0], y: x[1] } + const source = Array.isArray(x) ? { x: x[0], y: x[1] } : typeof x === 'object' ? { x: x.x, y: x.y } : { x: x, y: y } @@ -37,7 +36,7 @@ export default class Point { m = new Matrix(m) } - let { x, y } = this + const { x, y } = this // Perform the matrix multiplication this.x = m.a * x + m.c * y + m.e |