元編程參考文件

顏色

46 個節點

本頁內容 46

透明度

函數

Opacity (Transparency), higher value means more opaque.

簽名
透明度(顏色: 顏色) -> 位元組
byte Alpha(ColorElement Color)

參數

名稱型別預設值說明
顏色顏色—

返回

結果位元組
所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
資料流 函數 事件 例程 藍圖 狀態機狀態
宣告於
Color
所屬包
影像處理

藍

函數

Blue channel, from 0 (none) to 255 (full).

簽名
藍(顏色: 顏色) -> 位元組
byte Blue(ColorElement Color)

參數

名稱型別預設值說明
顏色顏色—

返回

結果位元組
所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
資料流 函數 事件 例程 藍圖 狀態機狀態
宣告於
Color
所屬包
影像處理

綠

函數

Green channel, from 0 (none) to 255 (full).

簽名
綠(顏色: 顏色) -> 位元組
byte Green(ColorElement Color)

參數

名稱型別預設值說明
顏色顏色—

返回

結果位元組
所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
資料流 函數 事件 例程 藍圖 狀態機狀態
宣告於
Color
所屬包
影像處理

紅

函數

Red channel, from 0 (none) to 255 (full).

簽名
紅(顏色: 顏色) -> 位元組
byte Red(ColorElement Color)

參數

名稱型別預設值說明
顏色顏色—

返回

結果位元組
所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
資料流 函數 事件 例程 藍圖 狀態機狀態
宣告於
Color
所屬包
影像處理

建立顏色

函數

過載 1/7

簽名
建立顏色() -> 顏色
ColorElement ColorElement()

Creates transparent black: every channel, alpha included, is 0.

返回

結果顏色

過載 2/7

簽名
建立顏色(單一值: 位元組) -> 顏色
ColorElement ColorElement(byte singleValue)

Creates an opaque gray, with red, green and blue all set to the same value and alpha 255.

參數

名稱型別預設值說明
單一值位元組—Gray level from 0 (black) to 255 (white).

返回

結果顏色

過載 3/7

簽名
建立顏色(單一值: 位元組, 透明度: 位元組) -> 顏色
ColorElement ColorElement(byte singleValue, byte alpha = 255)

Creates a gray, with red, green and blue all set to the same value, and the given opacity.

參數

名稱型別預設值說明
單一值位元組—Gray level from 0 (black) to 255 (white).
透明度位元組255Opacity from 0 (fully transparent) to 255 (fully opaque).

返回

結果顏色

過載 4/7

簽名
建立顏色 -> 顏色
    紅: 位元組
    綠: 位元組
    藍: 位元組
    透明度: 位元組
ColorElement ColorElement(
    byte red,
    byte green,
    byte blue,
    byte alpha = 255)

Creates a color from its red, green, blue and alpha channels, each from 0 to 255.

參數

名稱型別預設值說明
紅位元組—Red channel, 0-255.
綠位元組—Green channel, 0-255.
藍位元組—Blue channel, 0-255.
透明度位元組255Opacity, 0 (fully transparent) to 255 (fully opaque); opaque when omitted.

返回

結果顏色

過載 5/7

簽名
建立顏色(位元組: 位元組陣列) -> 顏色
ColorElement ColorElement(byte[] bytes)

Creates a color from the first four bytes of an array, read in red, green, blue, alpha order.

參數

名稱型別預設值說明
位元組位元組陣列—At least four bytes; any beyond the fourth are ignored. Fewer than four throws System.IndexOutOfRangeException.

返回

結果顏色

過載 6/7

簽名
建立顏色(像素: Pixel) -> 顏色
ColorElement ColorElement(Pixel pixel)

Creates a color from a BigGustave PNG pixel, copying its red, green, blue and alpha bytes unchanged.

參數

名稱型別預設值說明
像素Pixel—The PNG decoder's pixel.

返回

結果顏色

過載 7/7

簽名
建立顏色 -> 顏色
    R: 低精度數字
    克: 低精度數字
    B: 低精度數字
    A: 低精度數字
ColorElement ColorElement(float r, float g, float b, float a)

Creates a color from fractional channels in the 0-1 range, each multiplied by 255 and truncated (not rounded) to a byte.

參數

名稱型別預設值說明
R低精度數字—Red channel, 0-1.
克低精度數字—Green channel, 0-1.
B低精度數字—Blue channel, 0-1.
A低精度數字—Opacity, 0 (fully transparent) to 1 (fully opaque).

返回

結果顏色

備註

Inputs are not clamped before the conversion, so keep every channel within 0-1.

所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
資料流 函數 事件 例程 藍圖 狀態機狀態
宣告於
Color
所屬包
影像處理

相等

函數

過載 1/2

簽名
相等(顏色: 顏色, 另一個: 顏色) -> 真否
bool Equals(ColorElement Color, ColorElement other)

Whether both colors have exactly the same red, green, blue and alpha bytes.

參數

名稱型別預設值說明
顏色顏色—
另一個顏色—The color to compare with.

返回

結果真否

過載 2/2

簽名
相等(顏色: 顏色, 物件: 任意) -> 真否
bool Equals(ColorElement Color, object obj)

Whether Obj is a Image.ColorElement with exactly the same four channels.

參數

名稱型別預設值說明
顏色顏色—
物件任意—The object to compare with.

返回

結果真否
所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
事件 例程 狀態機狀態
宣告於
Color
所屬包
影像處理

透明度(浮點)

函數

The opacity as a fraction from 0 (fully transparent) to 1 (fully opaque).

簽名
透明度(浮點)(顏色: 顏色) -> 低精度數字
float AlphaFloat(ColorElement Color)

參數

名稱型別預設值說明
顏色顏色—

返回

結果低精度數字
所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
資料流 函數 事件 例程 藍圖 狀態機狀態
宣告於
Color
所屬包
影像處理

藍(浮點)

函數

The blue channel as a fraction from 0 to 1 (the byte divided by 255).

簽名
藍(浮點)(顏色: 顏色) -> 低精度數字
float BlueFloat(ColorElement Color)

參數

名稱型別預設值說明
顏色顏色—

返回

結果低精度數字
所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
資料流 函數 事件 例程 藍圖 狀態機狀態
宣告於
Color
所屬包
影像處理

綠(浮點)

函數

The green channel as a fraction from 0 to 1 (the byte divided by 255).

簽名
綠(浮點)(顏色: 顏色) -> 低精度數字
float GreenFloat(ColorElement Color)

參數

名稱型別預設值說明
顏色顏色—

返回

結果低精度數字
所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
資料流 函數 事件 例程 藍圖 狀態機狀態
宣告於
Color
所屬包
影像處理

紅(浮點)

函數

The red channel as a fraction from 0 to 1 (the byte divided by 255).

簽名
紅(浮點)(顏色: 顏色) -> 低精度數字
float RedFloat(ColorElement Color)

參數

名稱型別預設值說明
顏色顏色—

返回

結果低精度數字
所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
資料流 函數 事件 例程 藍圖 狀態機狀態
宣告於
Color
所屬包
影像處理

取得雜湊碼

函數

A hash code built from all four channels, consistent with ColorElement.Equals.

簽名
取得雜湊碼(顏色: 顏色) -> 整數
int GetHashCode(ColorElement Color)

參數

名稱型別預設值說明
顏色顏色—

返回

結果整數
所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
事件 例程 狀態機狀態
宣告於
Color
所屬包
影像處理

儲存為文字

函數

The color as text, in the same "#RRGGBBAA" hex form as ColorElement.ToString.

簽名
儲存為文字(顏色: 顏色) -> 文字
string SaveAsText(ColorElement Color)

參數

名稱型別預設值說明
顏色顏色—

返回

結果文字
所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
事件 例程 狀態機狀態
宣告於
Color
所屬包
影像處理

轉為主控台顏色

函數

Converts this Color instance to the closest matching ConsoleColor.
The match is determined by the Euclidean distance between RGB components.

簽名
轉為主控台顏色(顏色: 顏色) -> ConsoleColor
ConsoleColor ToConsoleColor(ColorElement Color)

參數

名稱型別預設值說明
顏色顏色—

返回

結果ConsoleColor
所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
事件 例程 狀態機狀態
宣告於
Color
所屬包
影像處理

轉為灰度

函數

A standard interpretation of (floating point) grayscale.

簽名
轉為灰度(顏色: 顏色) -> 低精度數字
float ToGrayscale(ColorElement Color)

參數

名稱型別預設值說明
顏色顏色—

返回

結果低精度數字
所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
事件 例程 狀態機狀態
宣告於
Color
所屬包
影像處理

轉為十六進位制

函數

Convert color to RGB hex representation.

簽名
轉為十六進位制(顏色: 顏色, 透明度: 真否) -> 文字
string ToHex(ColorElement Color, bool alpha = false)

參數

名稱型別預設值說明
顏色顏色—
透明度真否False

返回

結果文字
所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
事件 例程 狀態機狀態
宣告於
Color
所屬包
影像處理

轉為亮度

函數

The perceived brightness of the color as a gray level, weighting red, green and blue as 0.299, 0.587 and 0.114 (Rec. 601) and rounding to the nearest byte.

簽名
轉為亮度(顏色: 顏色) -> 位元組
byte ToLuminance(ColorElement Color)

參數

名稱型別預設值說明
顏色顏色—

返回

結果位元組

備註

The weights are applied to the stored bytes directly, without converting from sRGB to linear light. Alpha is ignored.

所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
事件 例程 狀態機狀態
宣告於
Color
所屬包
影像處理

轉為紅色通道灰度

函數

Treats the color as a grayscale value by taking its red channel alone, the convention this library uses for single-channel images.

簽名
轉為紅色通道灰度(顏色: 顏色) -> 位元組
byte ToRedGray(ColorElement Color)

參數

名稱型別預設值說明
顏色顏色—

返回

結果位元組
所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
事件 例程 狀態機狀態
宣告於
Color
所屬包
影像處理

轉為文字

函數

Returns a hexadecimal string representation of the Image.ColorElement.

簽名
轉為文字(顏色: 顏色) -> 文字
string ToString(ColorElement Color)

參數

名稱型別預設值說明
顏色顏色—

返回

結果文字
所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
事件 例程 狀態機狀態
宣告於
Color
所屬包
影像處理

轉為三元組

函數

The red, green and blue bytes (0-255) as a tuple, dropping alpha.

簽名
轉為三元組(顏色: 顏色) -> (位元組, 位元組, 位元組)
(byte, byte, byte) ToTuple3(ColorElement Color)

參數

名稱型別預設值說明
顏色顏色—

返回

結果(位元組, 位元組, 位元組)
所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
事件 例程 狀態機狀態
宣告於
Color
所屬包
影像處理

轉為四元組

函數

The red, green, blue and alpha bytes (0-255) as a tuple.

簽名
轉為四元組(顏色: 顏色) -> (位元組, 位元組, 位元組, 位元組)
(byte, byte, byte, byte) ToTuple4(ColorElement Color)

參數

名稱型別預設值說明
顏色顏色—

返回

結果(位元組, 位元組, 位元組, 位元組)
所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
事件 例程 狀態機狀態
宣告於
Color
所屬包
影像處理

轉為三維向量

函數

The red, green and blue channels as fractions from 0 to 1 in X, Y and Z, dropping alpha.

簽名
轉為三維向量(顏色: 顏色) -> Vector3
Vector3 ToVector3(ColorElement Color)

參數

名稱型別預設值說明
顏色顏色—

返回

結果Vector3

備註

The bytes are divided by 255 as stored; no sRGB-to-linear conversion is applied.

所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
事件 例程 狀態機狀態
宣告於
Color
所屬包
影像處理

轉為四維向量

函數

The red, green, blue and alpha channels as fractions from 0 to 1 in X, Y, Z and W.

簽名
轉為四維向量(顏色: 顏色) -> Vector4
Vector4 ToVector4(ColorElement Color)

參數

名稱型別預設值說明
顏色顏色—

返回

結果Vector4

備註

The bytes are divided by 255 as stored; no sRGB-to-linear conversion is applied.

所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
事件 例程 狀態機狀態
宣告於
Color
所屬包
影像處理

設定透明度

函數

Returns a copy of this color with the same red, green and blue but a different opacity.

簽名
設定透明度(顏色: 顏色, 透明度: 位元組) -> 顏色
ColorElement WithAlpha(ColorElement Color, byte alpha)

參數

名稱型別預設值說明
顏色顏色—
透明度位元組—The new opacity, 0 (fully transparent) to 255 (fully opaque).

返回

結果顏色
所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
事件 例程 狀態機狀態
宣告於
Color
所屬包
影像處理

寫入流

函數

Writes the color as four raw bytes, red, green, blue then alpha.

簽名
寫入流(顏色: 顏色, 寫入器: BinaryWriter) -> 大整數
long WriteToStream(ColorElement Color, BinaryWriter writer)

參數

名稱型別預設值說明
顏色顏色—
寫入器BinaryWriter—The writer to append to.

返回

結果大整數
所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
事件 例程 狀態機狀態
宣告於
Color
所屬包
影像處理

由 ARGB 生成顏色

函數

Creates a color from alpha, red, green and blue bytes, given alpha first.

簽名
由 ARGB 生成顏色 -> 顏色
    A: 位元組
    R: 位元組
    克: 位元組
    B: 位元組
ColorElement FromArgb(byte a, byte r, byte g, byte b)

參數

名稱型別預設值說明
A位元組—Opacity, 0 (fully transparent) to 255 (fully opaque).
R位元組—Red channel, 0-255.
克位元組—Green channel, 0-255.
B位元組—Blue channel, 0-255.

返回

結果顏色
所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
資料流 函數 事件 例程 藍圖 狀態機狀態
宣告於
Color
所屬包
影像處理

由主控台顏色生成

函數

Converts a ConsoleColor to a Color instance using a fixed mapping.

簽名
由主控台顏色生成(主控台顏色: ConsoleColor) -> 顏色
ColorElement FromConsoleColor(ConsoleColor consoleColor)

參數

名稱型別預設值說明
主控台顏色ConsoleColor—

返回

結果顏色
所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
資料流 函數 事件 例程 藍圖 狀態機狀態
宣告於
Color
所屬包
影像處理

由 RGB 生成顏色

函數

Creates a fully opaque color from red, green and blue bytes.

簽名
由 RGB 生成顏色(R: 位元組, 克: 位元組, B: 位元組) -> 顏色
ColorElement FromRgb(byte r, byte g, byte b)

參數

名稱型別預設值說明
R位元組—Red channel, 0-255.
克位元組—Green channel, 0-255.
B位元組—Blue channel, 0-255.

返回

結果顏色
所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
資料流 函數 事件 例程 藍圖 狀態機狀態
宣告於
Color
所屬包
影像處理

由 scRGB 生成顏色

函數

此節點沒有文件說明。

簽名
由 scRGB 生成顏色 -> 顏色
    A: 整數
    R: 低精度數字
    克: 低精度數字
    B: 低精度數字
ColorElement FromScRgb(int a, float r, float g, float b)

參數

名稱型別預設值說明
A整數—
R低精度數字—
克低精度數字—
B低精度數字—

返回

結果顏色

備註

TODO: looks broken. this forwards to the all-float constructor, so a gets multiplied by 255 again — FromScRgb(255, ...). Look at usages and see how to/whether to fix this.

所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
資料流 函數 事件 例程 藍圖 狀態機狀態
宣告於
Color
所屬包
影像處理

由單位浮點值生成顏色

函數

此節點沒有文件說明。

簽名
由單位浮點值生成顏色(值: 低精度數字) -> 顏色
ColorElement FromUnitFloat(float value)

參數

名稱型別預設值說明
值低精度數字—Value between 0-1

返回

結果顏色
所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
資料流 函數 事件 例程 藍圖 狀態機狀態
宣告於
Color
所屬包
影像處理

取得可空顏色

函數

Gets color from serialization.

簽名
取得可空顏色(位元組: 位元組陣列) -> 可選顏色
ColorElement? GetColorNullable(byte[] bytes)

參數

名稱型別預設值說明
位元組位元組陣列—

返回

結果可選顏色
所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
資料流 函數 事件 例程 藍圖 狀態機狀態
宣告於
Color
所屬包
影像處理

顏色插值

函數

過載 1/3

簽名
顏色插值(顏色 1: 顏色, 顏色 2: 顏色, 透明度: 位元組) -> 顏色
ColorElement Interp(
    ColorElement c1,
    ColorElement c2,
    byte alpha)

此節點沒有文件說明。

參數

名稱型別預設值說明
顏色 1顏色—
顏色 2顏色—
透明度位元組—

返回

結果顏色

備註

Ignores alpha, effectively assumping premultiplied.

過載 2/3

簽名
顏色插值(顏色 1: 顏色, 顏色 2: 顏色, 比例: 數字) -> 顏色
ColorElement Interp(
    ColorElement c1,
    ColorElement c2,
    double ratio)

此節點沒有文件說明。

參數

名稱型別預設值說明
顏色 1顏色—
顏色 2顏色—
比例數字—

返回

結果顏色

備註

Ignores alpha, effectively assumping premultiplied.

過載 3/3

簽名
顏色插值 -> 顏色
    起點: 顏色
    終點: 顏色
    混合係數: 低精度數字
    使用目標的透明度: 真否
ColorElement Interp(
    ColorElement from,
    ColorElement to,
    float blend,
    bool useAlphaFromTarget)

Linear interpolate with proper alpha treatment.

參數

名稱型別預設值說明
起點顏色—The color returned at a blend of 0.
終點顏色—The color blended towards; reached at a blend of 1 (and, when Use Alpha From Target is set, only if it is fully opaque).
混合係數低精度數字—Value between 0-1
使用目標的透明度真否—

返回

結果顏色

備註

In general, this is a weird operation; Use with care at call site - likely we would want something more well defined.

所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
資料流 函數 事件 例程 藍圖 狀態機狀態
宣告於
Color
所屬包
影像處理

從文字載入

函數

Reads a color from text, accepting the same hex codes and color names as ColorElement.Parse.

簽名
從文字載入(文字: 文字) -> 顏色
ColorElement LoadFromText(string text)

參數

名稱型別預設值說明
文字文字—A hex code such as "#RRGGBBAA" or a Image.MediaColors name.

返回

結果顏色
所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
資料流 函數 事件 例程 藍圖 狀態機狀態
宣告於
Color
所屬包
影像處理

RGB 相乘並保留透明度

函數

Brightens or darkens a color by multiplying red, green and blue by a factor, keeping its alpha unchanged.

簽名
RGB 相乘並保留透明度(顏色: 顏色, 乘數: 數字) -> 顏色
ColorElement MultiplyRgbPreserveAlpha(
    ColorElement color,
    double multiplier)

參數

名稱型別預設值說明
顏色顏色—The color to scale.
乘數數字—The factor applied to each of red, green and blue; 1 leaves the color unchanged.

返回

結果顏色

備註

Each channel is rounded and clamped to 0-255, so a large factor saturates at white rather than wrapping; a NaN or infinite product gives 0.

所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
資料流 函數 事件 例程 藍圖 狀態機狀態
宣告於
Color
所屬包
影像處理

加法運算

函數

Adds two colors channel by channel for red, green and blue; the result is always opaque.

簽名
加法運算(A: 顏色, B: 顏色) -> 顏色
ColorElement op_Addition(ColorElement a, ColorElement b)

參數

名稱型別預設值說明
A顏色—The first color; its alpha is ignored.
B顏色—The second color; its alpha is ignored.

返回

結果顏色

備註

The byte arithmetic wraps rather than clamps: a channel that would exceed 255 comes back near 0.

所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
資料流 函數 事件 例程 藍圖 狀態機狀態
宣告於
Color
所屬包
影像處理

相等運算

函數

Whether two colors have exactly the same red, green, blue and alpha bytes.

簽名
相等運算(左側: 顏色, 右側: 顏色) -> 真否
bool op_Equality(ColorElement left, ColorElement right)

參數

名稱型別預設值說明
左側顏色—The first color.
右側顏色—The second color.

返回

結果真否
所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
資料流 函數 事件 例程 藍圖 狀態機狀態
宣告於
Color
所屬包
影像處理

不等運算

函數

Whether two colors differ in any of red, green, blue or alpha.

簽名
不等運算(左側: 顏色, 右側: 顏色) -> 真否
bool op_Inequality(ColorElement left, ColorElement right)

參數

名稱型別預設值說明
左側顏色—The first color.
右側顏色—The second color.

返回

結果真否
所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
資料流 函數 事件 例程 藍圖 狀態機狀態
宣告於
Color
所屬包
影像處理

乘法運算

函數

Scales red, green and blue by a factor, truncating each result to a byte; the result is always opaque.

簽名
乘法運算(A: 顏色, 矩陣: 數字) -> 顏色
ColorElement op_Multiply(ColorElement a, double m)

參數

名稱型別預設值說明
A顏色—The color to scale; its alpha is ignored.
矩陣數字—The factor applied to each of red, green and blue.

返回

結果顏色

備註

Results are not clamped, so keep the factor small enough that no channel exceeds 255; ColorElement.MultiplyRgbPreserveAlpha clamps and keeps alpha.

所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
資料流 函數 事件 例程 藍圖 狀態機狀態
宣告於
Color
所屬包
影像處理

減法運算

函數

Subtracts one color from another channel by channel for red, green and blue; the result is always opaque.

簽名
減法運算(A: 顏色, B: 顏色) -> 顏色
ColorElement op_Subtraction(ColorElement a, ColorElement b)

參數

名稱型別預設值說明
A顏色—The color subtracted from; its alpha is ignored.
B顏色—The color subtracted; its alpha is ignored.

返回

結果顏色

備註

The byte arithmetic wraps rather than clamps: a channel that would go below 0 comes back near 255.

所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
資料流 函數 事件 例程 藍圖 狀態機狀態
宣告於
Color
所屬包
影像處理

解析顏色

函數

Parses a string representation of a color and returns the corresponding Image.ColorElement instance.

簽名
解析顏色(文字顏色: 文字) -> 顏色
ColorElement Parse(string textColor)

參數

名稱型別預設值說明
文字顏色文字—A string representing the color. This can either be a hexadecimal value (starting with '#') in the format "#RRGGBB" or "#RRGGBBAA" (with an optional alpha component) or the name of a predefined color in Image.MediaColors.

返回

結果顏色
所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
資料流 函數 事件 例程 藍圖 狀態機狀態
宣告於
Color
所屬包
影像處理

解析十六進位制 ARGB

函數

Parses a hexadecimal string representation of a color in ARGB order.

簽名
解析十六進位制 ARGB(十六進位制: 文字) -> 顏色
ColorElement ParseHexARGB(string hex)

參數

名稱型別預設值說明
十六進位制文字—A hexadecimal string representing the color. The string may optionally start with '#' and must be in the format "AARRGGBB", where the alpha component comes first.

返回

結果顏色
所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
資料流 函數 事件 例程 藍圖 狀態機狀態
宣告於
Color
所屬包
影像處理

解析十六進位制 RGBA

函數

Parses a hexadecimal string representation of a color in RGBA order.

簽名
解析十六進位制 RGBA(十六進位制: 文字) -> 顏色
ColorElement ParseHexRGBA(string hex)

參數

名稱型別預設值說明
十六進位制文字—A hexadecimal string representing the color. The string may optionally start with '#' and must be in the format "RRGGBB" or "RRGGBBAA", where the alpha component is optional and defaults to 255 if omitted.

返回

結果顏色
所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
資料流 函數 事件 例程 藍圖 狀態機狀態
宣告於
Color
所屬包
影像處理

從流讀取

函數

Reads a color written by ColorElement.WriteToStream: four bytes, red, green, blue then alpha.

簽名
從流讀取(讀取器: BinaryReader) -> (結果: 大整數, 值: 顏色)
long ReadFromStream(BinaryReader reader, out ColorElement value)

參數

名稱型別預設值說明
讀取器BinaryReader—The reader positioned at the color.

返回

結果大整數
值顏色
所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
資料流 函數 事件 例程 藍圖 狀態機狀態
宣告於
Color
所屬包
影像處理

序列化

函數

Nullable serialization helper.

簽名
序列化(值: 可選顏色) -> 位元組陣列
byte[] Serialize(ColorElement? value)

參數

名稱型別預設值說明
值可選顏色—Can be null

返回

結果位元組陣列
所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
資料流 函數 事件 例程 藍圖 狀態機狀態
宣告於
Color
所屬包
影像處理

嘗試解析顏色

函數

Tries to read a color from text, either a hex code starting with '#' or the name of a color in Image.MediaColors, without throwing on bad input.

簽名
嘗試解析顏色(文字顏色: 文字) -> (結果: 真否, 顏色: 顏色)
bool TryParse(string textColor, out ColorElement color)

參數

名稱型別預設值說明
文字顏色文字—The text to parse, such as "#FF8000", "#FF800080" or "Orange".

返回

結果真否
顏色顏色

備註

Surrounding whitespace is ignored and color names are matched case-insensitively. A hex code is read as "#RRGGBB" or "#RRGGBBAA" (see ColorElement.TryParseHexRGBA).

所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
資料流 函數 事件 例程 藍圖 狀態機狀態
宣告於
Color
所屬包
影像處理

嘗試解析十六進位制 ARGB

函數

Tries to read a hex color in alpha, red, green, blue order (the order XAML color codes use), without throwing on bad input.

簽名
嘗試解析十六進位制 ARGB(十六進位制: 文字) -> (結果: 真否, 顏色: 顏色)
bool TryParseHexARGB(string hex, out ColorElement color)

參數

名稱型別預設值說明
十六進位制文字—Exactly eight hex digits, "AARRGGBB", optionally preceded by '#' and surrounded by whitespace.

返回

結果真否
顏色顏色
所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
資料流 函數 事件 例程 藍圖 狀態機狀態
宣告於
Color
所屬包
影像處理

嘗試解析十六進位制 RGBA

函數

Tries to read a hex color in red, green, blue, alpha order, without throwing on bad input.

簽名
嘗試解析十六進位制 RGBA(十六進位制: 文字) -> (結果: 真否, 顏色: 顏色)
bool TryParseHexRGBA(string hex, out ColorElement color)

參數

名稱型別預設值說明
十六進位制文字—Six or eight hex digits, "RRGGBB" or "RRGGBBAA", optionally preceded by '#' and surrounded by whitespace. Alpha defaults to 255 (opaque) when only six digits are given.

返回

結果真否
顏色顏色
所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
資料流 函數 事件 例程 藍圖 狀態機狀態
宣告於
Color
所屬包
影像處理