元编程参考文档

颜色

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
所属包
图像处理