Sha256: d98d60fef34fdc6b9f1fdb5f0a7a6172edfac2feca982df941dbc3ce625d185a

Contents?: true

Size: 972 Bytes

Versions: 11

Compression:

Stored size: 972 Bytes

Contents

# frozen_string_literal: true

def extract_rgb_alpha(color_string)
  match_data = color_string.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+(?:\.\d+)?))?\)/)
  red = match_data[1].to_i
  green = match_data[2].to_i
  blue = match_data[3].to_i
  alpha = match_data[4] ? match_data[4].to_f : nil
  { red: red, green: green, blue: blue, alpha: alpha }
end

new({ particle: :red }) do
  # we return self to allow syntax of the type : a.color(:black).red(1).green(0.3)
  self
end
new({ particle: :green }) do
  # we return self to allow syntax of the type : a.color(:black).red(1).green(0.3)
  self
end
new({ particle: :blue }) do
  # we return self to allow syntax of the type : a.color(:black).red(1).green(0.3)
  self
end
new({ particle: :alpha }) do
  # we return self to allow syntax of the type : a.color(:black).red(1).green(0.3)
  self
end
new({ particle: :diffusion }) do
  # we return self to allow syntax of the type : a.color(:black).red(1).green(0.3)
  self
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
atome-0.5.5.7.7 lib/atome/genesis/generators/property.rb
atome-0.5.5.7.5 lib/atome/genesis/generators/property.rb
atome-0.5.5.7.3 lib/atome/genesis/generators/property.rb
atome-0.5.5.7.1 lib/atome/genesis/generators/property.rb
atome-0.5.5.7.0 lib/atome/genesis/generators/property.rb
atome-0.5.5.6.9 lib/atome/genesis/generators/property.rb
atome-0.5.5.6.8 lib/atome/genesis/generators/property.rb
atome-0.5.5.6.7.9 lib/atome/genesis/generators/property.rb
atome-0.5.5.6.6 lib/atome/genesis/generators/property.rb
atome-0.5.5.6.5 lib/atome/genesis/generators/property.rb
atome-0.5.5.6.4 lib/atome/genesis/generators/property.rb