Skip to content

Commit f465feb

Browse files
remove unnecessary if code
1 parent 2271a30 commit f465feb

1 file changed

Lines changed: 13 additions & 15 deletions

File tree

src/color/p5.Color.js

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -330,27 +330,25 @@ class Color {
330330
if (!colorString) {
331331
colorString = serialize(this._color, {
332332
format: outputFormat
333-
});
333+
});
334334

335-
if (format === '#rrggbb') {
336-
colorString = String(colorString);
335+
colorString = String(colorString);
337336

338-
if (colorString.length <= 5) {
339-
const match = colorString.match(/^#?([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])/);
340-
if (match) {
341-
colorString = `#${match[1]}${match[1]}${match[2]}${match[2]}${match[3]}${match[3]}`;
342-
}
343-
}
344-
if (colorString.length > 7) {
345-
colorString = colorString.substring(0, 7);
346-
}
347-
colorString = colorString.toLowerCase();
337+
if (colorString.length <= 5) {
338+
const match = colorString.match(/^#?([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])/);
339+
if (match) {
340+
colorString = `#${match[1]}${match[1]}${match[2]}${match[2]}${match[3]}${match[3]}`;
348341
}
349-
350-
serializationMap[key] = colorString;
351342
}
343+
if (colorString.length > 7) {
344+
colorString = colorString.substring(0, 7);
345+
}
346+
colorString = colorString.toLowerCase();
347+
serializationMap[key] = colorString;
348+
352349
return colorString;
353350
}
351+
}
354352

355353
/**
356354
* Checks the contrast between two colors. This method returns a boolean

0 commit comments

Comments
 (0)