10 examples of 'random color generator javascript' in JavaScript

Every line of 'random color generator javascript' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
63function genColor(colors) {
64 var rand = generator.random()
65 var idx = Math.floor(colors.length * generator.random())
66 var color = colors.splice(idx,1)[0]
67 return color
68}
23randomColor(){
24 var colors = ["#C0392B", "#E74C3C", "#9B59B6", "#8E44AD", "#2980B9",
25 "#3498DB", "#17A589", "#138D75", "#229954", "#28B463", "#D4AC0D",
26 "#D68910", "#CA6F1E", "#BA4A00"];
27 return colors[this.random(0, colors.length-1)]
28}
106return (function getRandomColor() {
107 return colors[Math.floor(Math.random() * colors.length)];
108});
49function randomColor() {
50 const colors = [
51 '#1abc9c',
52 '#2ecc71',
53 '#3498db',
54 '#9b59b6',
55 '#8e44ad',
56 '#2c3e50',
57 '#f1c40f',
58 '#e67e22',
59 '#e74c3c',
60 '#f39c12'
61 ]
62 return randomElement(colors)
63}
175function randomColor(colors) {
176 return colors[Math.floor(Math.random() * colors.length)];
177}
87function randomColor() {
88 return color(random(255), random(255), random(255))
89}
73function randColor() {
74 return new THREE.Color(parseInt(Math.random()*16777216));
75 }
9function random_color() {
10 var r = Math.floor(Math.random() * 256),
11 g = Math.floor(Math.random() * 256),
12 b = Math.floor(Math.random() * 256);
13 return 'rgb('+r+','+g+','+b+')';
14}
62function genColor() {
63 var num1 = Math.floor( Math.random() * 10 );
64 var num2 = Math.floor( Math.random() * 10 );
65 var num3 = Math.floor( Math.random() * 10 );
66 var num4 = Math.floor( Math.random() * 10 );
67 var num5 = Math.floor( Math.random() * 10 );
68 var num6 = Math.floor( Math.random() * 10 );
69 var color = "#" + num1 + num2 + num3 + "f" + "f" + "f";
70 return color;
71}
33function getRandomColor(min, max) {
34 var r = getRandomNumber(min, max),
35 g = getRandomNumber(min, max),
36 b = getRandomNumber(min, max),
37 a = getRandomNumber(0.1, 0.5),
38 color = 'rgba(' + r + ',' + g + ',' + b + ',' + a + ')';
39 return color;
40}

Related snippets