// RGBで対比させる色 黒/白 function colorOnRGB(rgb) { var red = rgb.r, green = rgb.g, blue = rgb.b; var color = 'black'; if ((red * 0.299 + green * 0.587 + blue * 0.114) < 186) { color = 'white'; } return color; } Register as a new user and use Qiita more conveniently You get articles that match your needsYou can efficiently read back useful informationYou can use dark themeWhat you can do with signing up