class Dvl::Color::FakeRgba

Public Class Methods

calculate(background, foreground, alpha) click to toggle source
# File lib/dvl/color/fake_rgba.rb, line 2
def self.calculate(background, foreground, alpha)
  bg = background.rgb
  fg = foreground.rgb

  r = (fg.r * alpha) + (bg.r * (1 - alpha))
  g = (fg.g * alpha) + (bg.g * (1 - alpha))
  b = (fg.b * alpha) + (bg.b * (1 - alpha))

  Chroma::Color.new(Chroma::ColorModes::Rgb.new(r, g,  b), :hex)
end