Skip to content

Commit

Permalink
fix: replace deprecated substr with substring
Browse files Browse the repository at this point in the history
  • Loading branch information
sibiraj-s committed Jan 29, 2022
1 parent d51c9ad commit 9089c5a
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ export class ColorPickerComponent implements OnInit, OnDestroy {
private canExecute = true;

getContrastYIQ(hexcolor: string): string {
hexcolor = hexcolor.replace('#', '');
const r = parseInt(hexcolor.substr(0, 2), 16);
const g = parseInt(hexcolor.substr(2, 2), 16);
const b = parseInt(hexcolor.substr(4, 2), 16);
const color = hexcolor.replace('#', '');
const r = parseInt(color.substring(0, 2), 16);
const g = parseInt(color.substring(2, 4), 16);
const b = parseInt(color.substring(4, 6), 16);
const yiq = ((r * 299) + (g * 587) + (b * 114)) / 1000;
return (yiq >= 128) ? 'black' : 'white';
}
Expand Down

0 comments on commit 9089c5a

Please sign in to comment.