BrickColorデータ型
データ型日本語解説あり
ひとことで言うと
ロブロックス(Roblox)で決められた、名前の付いた色を表すデータ型です。BrickColor.new("Bright red") のように名前で作れます。
公式の説明(英語):A data type that provides a predefined list of named colors.
使用例
Script置く場所:ServerScriptService
for i = 1, 10 do
local part = Instance.new("Part")
part.Size = Vector3.new(4, 1, 4)
part.Position = Vector3.new(i * 5, 10, 0)
part.Anchored = true
part.BrickColor = BrickColor.random()
part.Parent = workspace
endスクリプトは、Luauの型チェック(luau-lsp)で確認しています。
コンストラクター(作り方)(14)
| 名前と書き方 | 説明 |
|---|---|
newBrickColor.new(val: number) | 色の名前などを指定してBrickColorを作ります。Constructs a BrickColor from its numerical index. |
newBrickColor.new(r: number, g: number, b: number) | 色の名前などを指定してBrickColorを作ります。Constructs the closest BrickColor that can be matched to the specified RGB components. |
newBrickColor.new(name: string) | 色の名前などを指定してBrickColorを作ります。Constructs a BrickColor from its name. |
newBrickColor.new(color: Color3) | 色の名前などを指定してBrickColorを作ります。Constructs the closest BrickColor that can be matched to the specified Color3. |
paletteBrickColor.palette(paletteValue: number) | Constructs a BrickColor from its palette index. |
randomBrickColor.random() | ランダムな色を作ります。Returns a random BrickColor. |
WhiteBrickColor.White() | Returns the "White" BrickColor. |
GrayBrickColor.Gray() | Returns the "Medium stone grey" BrickColor. |
DarkGrayBrickColor.DarkGray() | Returns the "Dark stone grey" BrickColor. |
BlackBrickColor.Black() | Returns the "Black" BrickColor. |
RedBrickColor.Red() | Returns the "Bright red" BrickColor. |
YellowBrickColor.Yellow() | Returns the "Bright yellow" BrickColor. |
GreenBrickColor.Green() | Returns the "Dark green" BrickColor. |
BlueBrickColor.Blue() | Returns the "Bright blue" BrickColor. |
プロパティ(6)
| 名前と書き方 | 説明 |
|---|---|
NumberBrickColor.Number: number | The unique number that identifies the BrickColor. |
rBrickColor.r: number | The red component of the BrickColor (between 0 and 1). |
gBrickColor.g: number | The green component of the BrickColor (between 0 and 1). |
bBrickColor.b: number | The blue component of the BrickColor (between 0 and 1). |
NameBrickColor.Name: string | 色の名前。The name associated with the BrickColor. |
ColorBrickColor.Color: Color3 | The Color3 associated with the BrickColor. |
BrickColorを使う記事
英語の説明とメンバーの一覧は、Roblox Creator Documentation(BrickColor)をもとにしています(CC BY 4.0)。日本語の解説は、このサイトで独自に書いたものです。