Skip to content

Commit 5e9f757

Browse files
committed
method shorthand
1 parent e4bc34e commit 5e9f757

File tree

3 files changed

+22
-22
lines changed

3 files changed

+22
-22
lines changed

src/color.js

+13-13
Original file line numberDiff line numberDiff line change
@@ -168,10 +168,10 @@ var named = {
168168
};
169169

170170
define(Color, color, {
171-
copy: function(channels) {
171+
copy(channels) {
172172
return Object.assign(new this.constructor, this, channels);
173173
},
174-
displayable: function() {
174+
displayable() {
175175
return this.rgb().displayable();
176176
},
177177
hex: color_formatHex, // Deprecated! Use color.formatHex.
@@ -245,21 +245,21 @@ export function Rgb(r, g, b, opacity) {
245245
}
246246

247247
define(Rgb, rgb, extend(Color, {
248-
brighter: function(k) {
248+
brighter(k) {
249249
k = k == null ? brighter : Math.pow(brighter, k);
250250
return new Rgb(this.r * k, this.g * k, this.b * k, this.opacity);
251251
},
252-
darker: function(k) {
252+
darker(k) {
253253
k = k == null ? darker : Math.pow(darker, k);
254254
return new Rgb(this.r * k, this.g * k, this.b * k, this.opacity);
255255
},
256-
rgb: function() {
256+
rgb() {
257257
return this;
258258
},
259-
clamp: function() {
259+
clamp() {
260260
return new Rgb(clampi(this.r), clampi(this.g), clampi(this.b), clampa(this.opacity));
261261
},
262-
displayable: function() {
262+
displayable() {
263263
return (-0.5 <= this.r && this.r < 255.5)
264264
&& (-0.5 <= this.g && this.g < 255.5)
265265
&& (-0.5 <= this.b && this.b < 255.5)
@@ -343,15 +343,15 @@ function Hsl(h, s, l, opacity) {
343343
}
344344

345345
define(Hsl, hsl, extend(Color, {
346-
brighter: function(k) {
346+
brighter(k) {
347347
k = k == null ? brighter : Math.pow(brighter, k);
348348
return new Hsl(this.h, this.s, this.l * k, this.opacity);
349349
},
350-
darker: function(k) {
350+
darker(k) {
351351
k = k == null ? darker : Math.pow(darker, k);
352352
return new Hsl(this.h, this.s, this.l * k, this.opacity);
353353
},
354-
rgb: function() {
354+
rgb() {
355355
var h = this.h % 360 + (this.h < 0) * 360,
356356
s = isNaN(h) || isNaN(this.s) ? 0 : this.s,
357357
l = this.l,
@@ -364,15 +364,15 @@ define(Hsl, hsl, extend(Color, {
364364
this.opacity
365365
);
366366
},
367-
clamp: function() {
367+
clamp() {
368368
return new Hsl(clamph(this.h), clampt(this.s), clampt(this.l), clampa(this.opacity));
369369
},
370-
displayable: function() {
370+
displayable() {
371371
return (0 <= this.s && this.s <= 1 || isNaN(this.s))
372372
&& (0 <= this.l && this.l <= 1)
373373
&& (0 <= this.opacity && this.opacity <= 1);
374374
},
375-
formatHsl: function() {
375+
formatHsl() {
376376
const a = clampa(this.opacity);
377377
return `${a === 1 ? "hsl(" : "hsla("}${clamph(this.h)}, ${clampt(this.s) * 100}%, ${clampt(this.l) * 100}%${a === 1 ? ")" : `, ${a})`}`;
378378
}

src/cubehelix.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,15 @@ export function Cubehelix(h, s, l, opacity) {
3737
}
3838

3939
define(Cubehelix, cubehelix, extend(Color, {
40-
brighter: function(k) {
40+
brighter(k) {
4141
k = k == null ? brighter : Math.pow(brighter, k);
4242
return new Cubehelix(this.h, this.s, this.l * k, this.opacity);
4343
},
44-
darker: function(k) {
44+
darker(k) {
4545
k = k == null ? darker : Math.pow(darker, k);
4646
return new Cubehelix(this.h, this.s, this.l * k, this.opacity);
4747
},
48-
rgb: function() {
48+
rgb() {
4949
var h = isNaN(this.h) ? 0 : (this.h + 120) * radians,
5050
l = +this.l,
5151
a = isNaN(this.s) ? 0 : this.s * l * (1 - l),

src/lab.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,13 @@ export function Lab(l, a, b, opacity) {
4343
}
4444

4545
define(Lab, lab, extend(Color, {
46-
brighter: function(k) {
46+
brighter(k) {
4747
return new Lab(this.l + K * (k == null ? 1 : k), this.a, this.b, this.opacity);
4848
},
49-
darker: function(k) {
49+
darker(k) {
5050
return new Lab(this.l - K * (k == null ? 1 : k), this.a, this.b, this.opacity);
5151
},
52-
rgb: function() {
52+
rgb() {
5353
var y = (this.l + 16) / 116,
5454
x = isNaN(this.a) ? y : y + this.a / 500,
5555
z = isNaN(this.b) ? y : y - this.b / 200;
@@ -111,13 +111,13 @@ function hcl2lab(o) {
111111
}
112112

113113
define(Hcl, hcl, extend(Color, {
114-
brighter: function(k) {
114+
brighter(k) {
115115
return new Hcl(this.h, this.c, this.l + K * (k == null ? 1 : k), this.opacity);
116116
},
117-
darker: function(k) {
117+
darker(k) {
118118
return new Hcl(this.h, this.c, this.l - K * (k == null ? 1 : k), this.opacity);
119119
},
120-
rgb: function() {
120+
rgb() {
121121
return hcl2lab(this).rgb();
122122
}
123123
}));

0 commit comments

Comments
 (0)