title: Dynamically apply opacity to hex color
body: <p>I am currently working on a problem where the background of some UI component has to be: the main color of the screen plus a 30% opacity.</p>
  <p>The main color is retrieved from a backend service and comes in the form of: #224466.</p>
  <p>Now, I would like to apply 30% opacity to whatever color I receive. The solution I came up with, involves the string parsing, and it's working, but I am not happy with it:</p>
  <p>I am doing it like this:</p>
  <pre><code>if(mainColor.startsWith(&quot;#&quot;) &amp;&amp; mainColor.length == 7){
     return &quot;#4D&quot; + mainColor.substring(1) // 4D = 30% alpha
  }
  </code></pre>
  <p>Do you know if there's perhaps a better way, maybe involving the <code>Color</code> class, of solving the above task?</p>