blob: 1b19c22597df55d6b524d79f126c87d2de626b27 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# coding: utf-8
# Copyright 2019 DragonRuby LLC
# MIT License
# console_color.rb has been released under MIT (*only this file*).
# Contributors outside of DragonRuby who also hold Copyright:
# - Kevin Fischer: https://github.com/kfischer-okarin
module GTK
class Console
class Color
def initialize(color)
@color = color
@color << 255 if @color.size == 3
end
def mult_alpha(alpha_modifier)
Color.new [@color[0], @color[1], @color[2], (@color[3].to_f * alpha_modifier).to_i]
end
# Support splat operator
def to_a
@color
end
def to_s
"GTK::Console::Color #{to_h}"
end
def to_h
{ r: @color[0], g: @color[1], b: @color[2], a: @color[3] }
end
end
end
end
|