Color3データ型
データ型日本語解説あり
ひとことで言うと
赤・緑・青の3つの値で色を表すデータ型です。Color3.fromRGB(255, 0, 0) のように、0〜255の数で作るのが分かりやすい方法です。
公式の説明(英語):A color value comprised of red, green, and blue components.
使用例
Script置く場所:パーツの中
local part = script.Parent :: BasePart
local clickDetector = Instance.new("ClickDetector")
clickDetector.Parent = part
clickDetector.MouseClick:Connect(function()
part.Color = Color3.fromRGB(math.random(0, 255), math.random(0, 255), math.random(0, 255))
end)スクリプトは、Luauの型チェック(luau-lsp)で確認しています。
コンストラクター(作り方)(4)
| 名前と書き方 | 説明 |
|---|---|
newColor3.new(red: number, green: number, blue: number) | 赤・緑・青を0〜1で指定して色を作ります。Returns a Color3 with the given red, green, and blue values. |
fromRGBColor3.fromRGB(red: number, green: number, blue: number) | 赤・緑・青を0〜255で指定して色を作ります。Returns a Color3 from given components within the range of 0 to 255. |
fromHSVColor3.fromHSV(hue: number, saturation: number, value: number) | 色相・彩度・明度から色を作ります。Returns a Color3 from the given hue, saturation, and value components. |
fromHexColor3.fromHex(hex: string) | Returns a Color3 from a given hex value. |
プロパティ(3)
| 名前と書き方 | 説明 |
|---|---|
RColor3.R: number | The red value of the color. |
GColor3.G: number | The green value of the color. |
BColor3.B: number | The blue value of the color. |
メソッド(6)
| 名前と書き方 | 説明 |
|---|---|
LerpColor3:Lerp(color: Color3, alpha: number): Color3 | 2つの色のあいだの色を作ります。Returns a Color3 interpolated between two colors. |
ToHSVColor3:ToHSV(): number, number, number | Returns the hue, saturation, and value of a Color3. |
ToHexColor3:ToHex(): string | Returns the hex code of a Color3. |
GetLuminanceColor3:GetLuminance(): number | Returns the relative luminance of a Color3. |
GetContrastRatioColor3:GetContrastRatio(other: Color3): number | Returns the WCAG contrast ratio between a Color3 and another color. |
GetContrastingColorColor3:GetContrastingColor(...: Color3): Color3 | Returns whichever candidate color has the highest contrast against a Color3. |
Color3を使う記事
英語の説明とメンバーの一覧は、Roblox Creator Documentation(Color3)をもとにしています(CC BY 4.0)。日本語の解説は、このサイトで独自に書いたものです。