Colorクラス

提供: AB開発Wiki
ナビゲーションに移動検索に移動
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Color クラスは、色を扱うクラスです。

このクラスでは、色をRGBA各8ビットの計32ビットの値として取り扱います。

クラスの機能

プロパティ

Value

Function Value() As ARGB
Sub Value(value As ARGB)

カラー値を参照・設定します。

A

Function A() As Byte

透明度(アルファ成分)の値を返します。

R

Function R() As Byte

赤成分の値を返します。

G

Function G() As Byte

緑成分の値を返します。

B

Function B() As Byte

青成分の値を返します。

メソッド

コンストラクタ

Sub Color()
Sub Color(ByRef c As Color)
Sub Color(r As Byte, g As Byte, b As Byte)
Sub Color(a As Byte, r As Byte, g As Byte, b As Byte)
Sub Color(argb As ARGB)

引数が指定されない場合は透明でない黒 (a = 255, r = 0, g = 0, b = 0)で初期化されます。

c
コピー元のColorクラスのインスタンス。
a
透明度成分。省略すると255(完全に不透明)となります。
r
赤成分。
g
緑成分。
b
青成分。
argb
ARGB型による色の指定。

FromArgb

Static Function FromArgb(argb As ARGB) As Color
Static Function FromArgb(a As Byte, base As Color) As Color
Static Function FromArgb(r As Byte, g As Byte, b As Byte) As Color
Static Function FromArgb(a As Byte, r As Byte, g As Byte, b As Byte) As Color

それぞれ引数が同じであるコンストラクタを呼び出してColorクラスのインスタンスを作成し、それを返します。

Operator ==

Function Operator ==(c As Color) As BOOL

Equals(c)を返します。

Operator <>

Function Operator <>(c As Color) As BOOL

Not Equals(c)を返します。

SetFromCOLORREF

Sub SetFromCOLORREF(rgb As COLORREF)

このインスタンスを、Windows APIで用いられるCOLORREF型で指定された色に設定します。パレットインデックス値が指定されたCOLORREFインスタンスを引数に渡すことはできません。

ToCOLORREF

Function ToCOLORREF() As COLORREF

Windows APIで用いられるCOLORREF型に変換して返します。アルファ成分の情報は含まれません。

ToArgb

Function ToArgb() As ARGB

Argb型での値を返します。

Equals

Function Equals(c As Color) As BOOL

This.Value = c.Valueを返します。

GetHue

Function GetHue() As Single

HSB表色系における色合いを返します。

GetSaturation

Function GetSaturation() As Single

HSB表色系における鮮やかさを返します。

GetBrightness

Function GetBrightness() As Single

HSB表色系における輝度を返します。

MakeARGB

Static Function MakeARGB(a As Byte, r As Byte, g As Byte, b As Byte) As ARGB

引数で各成分の値を指定してARGB型のインスタンスを作成し、それを返します。

a
透明度成分。
r
赤成分。
g
緑成分。
b
青成分。

定数

注意:いずれも現在のABでは実装されていないため、コメントアウトされています。

シフト定数

Const Enum
    AlphaShift  = 24
    RedShift    = 16
    GreenShift  = 8
    BlueShift   = 0
End Enum

マスク定数

Const Enum
    AlphaMask   = &hff000000
    RedMask     = &h00ff0000
    GreenMask   = &h0000ff00
    BlueMask    = &h000000ff
End Enum

関連型

ARGB

TypeDef ARGB = DWord

色成分を保持するGDI+の型です。なお、ARGB型の値をマスク定数でAndを行った後、シフト定数で右シフトすると対応する色成分を取り出すことができます。