Sha256: 7dd45ca121e56dddef8d11f97bde73e8730c02b8579be9931bb242a5f883361d
Contents?: true
Size: 1.67 KB
Versions: 3
Compression:
Stored size: 1.67 KB
Contents
# frozen_string_literal: true # # 2D Particle Effects # module ParticleFX2D # @!visibility private module Private # @!visibility private # # RGBA colour representation by its four components, for internal use only. # class Color attr_accessor :r, :g, :b, :a def initialize(other) case other when Array @r = other[0].to_f @g = other[1].to_f @b = other[2].to_f @a = other[3].to_f else @r = other.r @g = other.g @b = other.b @a = other.a end end alias opacity a alias opacity= a= def to_a [@r, @g, @b, @a] end def subtract!(other) case other when Numeric @r -= other @g -= other @b -= other @a -= other else @r -= other.r @g -= other.g @b -= other.b @a -= other.a end self end def add!(other, each_times: 1) case other when Numeric value = other * each_times @r += value @g += value @b += value @a += value else @r += other.r * each_times @g += other.g * each_times @b += other.b * each_times @a += other.a * each_times end self end def divide_by!(other) case other when Numeric @r /= other @g /= other @b /= other @a /= other else @r /= other.r @g /= other.g @b /= other.b @a /= other.a end self end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
particlefx2d-0.5.0 | lib/particlefx2d/private/color.rb |
particlefx2d-0.4.0 | lib/particlefx2d/private/color.rb |
particlefx2d-0.3.0 | lib/particlefx2d/private/color.rb |