title: Is there a way to use a variable as a parameter in rgba() in JavaScript?
body: <p>This is my Javascript code.</p>
  
  <pre><code>var radius = random(20,200);
      var randRed = random(210,255);
      var randAlpha = random(0.25,0.4);
      var Color = 'rgba(255,255,255,0.25)';
      this.x = random(100, 700);
      this.y = random(100, 500);
      this.width = radius;
      this.height = radius;
      this.color = Color;
      this.velocityX = random(-5, +5);
      this.velocityY= random(-5, +5);
  </code></pre>
  
  <p>For context, this is used in a constructor in a class <code>Bubble</code> to create randomized circular bubbles. I found a way to randomize radius and position, but is there any way to use <code>randRed</code> and <code>randAlpha</code> as the red and alpha values for the <code>rgba()</code> in the <code>Color</code> variable?</p>
  
  <p>I want to be able to do something like:</p>
  
  <pre><code>var Color = 'rgba(randRed,255,255,randAlpha);
  </code></pre>
  
  <p>Is this possible?
  Here is the rest of the code:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>class Bubble {
  
    constructor() {
      var allInstances = [];
  
      var radius = random(20, 200);
      var randRed = random(210, 255);
      var randAlpha = random(0.25, 0.4);
      var Color = 'rgba(255,255,255,0.25)';
      this.x = random(100, 700);
      this.y = random(100, 500);
      this.width = radius;
      this.height = radius;
      this.color = Color;
      this.velocityX = random(-5, +5);
      this.velocityY = random(-5, +5);
  
      this.display = function() {
        stroke(255);
        fill(this.color);
        ellipse(this.x, this.y, this.width, this.height);
      }
  
      this.move = function() {
        this.x = this.x + this.velocityX;
        this.y = this.y + this.velocityY;
      }
  
    }
  }
  
  var bubbles = [];
  
  function setup() {
    createCanvas(800, 600);
    bubble1 = new Bubble();
    bubble2 = new Bubble();
    bubble3 = new Bubble();
    bubble4 = new Bubble();
    bubble5 = new Bubble();
    bubble6 = new Bubble();
  }
  
  
  function draw() {
    background(56, 226, 232);
    bubble1.move();
    bubble2.move();
    bubble3.move();
    bubble4.move();
    bubble5.move();
    bubble6.move();
  
    bubble1.display();
    bubble2.display();
    bubble3.display();
    bubble4.display();
    bubble5.display();
    bubble6.display();
  }
  
  setInterval(function() {
    setup();
    draw();
  }, 2900);</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>html,
  body {
    margin: 0;
    padding: 0;
  }
  
  canvas {
    display: block;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  
  &lt;head&gt;
    &lt;script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.9.0/p5.js"&gt;&lt;/script&gt;
    &lt;script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.9.0/addons/p5.dom.min.js"&gt;&lt;/script&gt;
    &lt;script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.9.0/addons/p5.sound.min.js"&gt;&lt;/script&gt;
    &lt;link rel="stylesheet" type="text/css" href="style.css"&gt;
    &lt;meta charset="utf-8" /&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
    &lt;script src="sketch.js"&gt;&lt;/script&gt;
  &lt;/body&gt;
  
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>