Sha256: 0cb9d2e98e3868e3783787dce7e33ca089525df5a287bfb7c2665aa5fd1b3847

Contents?: true

Size: 683 Bytes

Versions: 2

Compression:

Stored size: 683 Bytes

Contents

# -*- coding: utf-8 -*-

module DXRubySDL
  module Color
    module_function

    def to_sdl_color(color)
      if color.length == 4
        return color[1..3]
      else
        color
      end
    end

    def to_sdl_alpha(color)
      if color.length == 4
        color[0]
      else
        0xFF
      end
    end

    def to_sdl_rgba(color)
      [*to_sdl_color(color), to_sdl_alpha(color)]
    end

    def to_dxruby_argb(color)
      if color.length == 4
        [color[3], *color[0..2]]
      else
        [0xFF, *color]
      end
    end

    def normalize_dxruby(color)
      if color.length == 4
        color
      else
        [0xFF] + color
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dxruby_sdl-0.0.17 lib/dxruby_sdl/color.rb
dxruby_sdl-0.0.16 lib/dxruby_sdl/color.rb