Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
qq_34031325
engine
提交
7127a18b
E
engine
项目概览
qq_34031325
/
engine
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
E
engine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
7127a18b
编写于
12月 12, 2016
作者:
I
Ian Hickson
提交者:
GitHub
12月 12, 2016
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Color docs (#3310)
上级
60681a23
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
52 addition
and
16 deletion
+52
-16
lib/ui/painting.dart
lib/ui/painting.dart
+52
-16
未找到文件。
lib/ui/painting.dart
浏览文件 @
7127a18b
...
...
@@ -8,14 +8,48 @@ Color _scaleAlpha(Color a, double factor) {
return
a
.
withAlpha
((
a
.
alpha
*
factor
).
round
());
}
/// An immutable 32 bit color value in ARGB
/// An immutable 32 bit color value in ARGB format.
///
/// Consider the light teal of the Flutter logo. It is fully opaque, with a red
/// channel value of 0x42 (66), a green channel value of 0xA5 (165), and a blue
/// channel value of 0xF5 (245). In the common "hash syntax" for colour values,
/// it would be described as `#42A5F5`.
///
/// Here are some ways it could be constructed:
///
/// ```dart
/// Color c = const Color(0xFF42A5F5);
/// Color c = const Color.fromARGB(0xFF, 0x42, 0xA5, 0xF5);
/// Color c = const Color.fromARGB(255, 66, 165, 245);
/// Color c = const Color.fromRGBO(66, 165, 245, 1.0);
/// ```
///
/// If you are having a problem with `Color` wherein it seems your color is just
/// not painting, check to make sure you are specifying the full 8 hexadecimal
/// digits. If you only specify six, then the leading two digits are assumed to
/// be zero, which means fully-transparent:
///
/// ```dart
/// Color c1 = const Color(0xFFFFFF); // fully transparent white (invisible)
/// Color c2 = const Color(0xFFFFFFFF); // fully opaque white (visible)
/// ```
class
Color
{
/// Construct a color from the lower 32 bits of an
int
.
/// Construct a color from the lower 32 bits of an
[int]
.
///
/// Bits 24-31 are the alpha value.
/// Bits 16-23 are the red value.
/// Bits 8-15 are the green value.
/// Bits 0-7 are the blue value.
/// The bits are interpreted as follows:
///
/// * Bits 24-31 are the alpha value.
/// * Bits 16-23 are the red value.
/// * Bits 8-15 are the green value.
/// * Bits 0-7 are the blue value.
///
/// In other words, if AA is the alpha value in hex, RR the red value in hex,
/// GG the green value in hex, and BB the blue value in hex, a color can be
/// expressed as `const Color(0xAARRGGBB)`.
///
/// For example, to get a fully opaque orange, you would use `const
/// Color(0xFFFF9000)` (`FF` for the alpha, `FF` for the red, `90` for the
/// green, and `00` for the blue).
const
Color
(
int
value
)
:
value
=
value
&
0xFFFFFFFF
;
/// Construct a color from the lower 8 bits of four integers.
...
...
@@ -55,10 +89,12 @@ class Color {
/// A 32 bit value representing this color.
///
/// Bits 24-31 are the alpha value.
/// Bits 16-23 are the red value.
/// Bits 8-15 are the green value.
/// Bits 0-7 are the blue value.
/// The bits are assigned as follows:
///
/// * Bits 24-31 are the alpha value.
/// * Bits 16-23 are the red value.
/// * Bits 8-15 are the green value.
/// * Bits 0-7 are the blue value.
final
int
value
;
/// The alpha channel of this color in an 8 bit value.
...
...
@@ -83,37 +119,37 @@ class Color {
int
get
blue
=>
(
0x000000ff
&
value
)
>>
0
;
/// Returns a new color that matches this color with the alpha channel
/// replaced with
a
(which ranges from 0 to 255).
/// replaced with
`a`
(which ranges from 0 to 255).
Color
withAlpha
(
int
a
)
{
return
new
Color
.
fromARGB
(
a
,
red
,
green
,
blue
);
}
/// Returns a new color that matches this color with the alpha channel
/// replaced with the given
opacity
(which ranges from 0.0 to 1.0).
/// replaced with the given
`opacity`
(which ranges from 0.0 to 1.0).
Color
withOpacity
(
double
opacity
)
{
assert
(
opacity
>=
0.0
&&
opacity
<=
1.0
);
return
withAlpha
((
255.0
*
opacity
).
round
());
}
/// Returns a new color that matches this color with the red channel replaced
/// with
r
.
/// with
`r`
.
Color
withRed
(
int
r
)
{
return
new
Color
.
fromARGB
(
alpha
,
r
,
green
,
blue
);
}
/// Returns a new color that matches this color with the green channel
/// replaced with
g
.
/// replaced with
`g`
.
Color
withGreen
(
int
g
)
{
return
new
Color
.
fromARGB
(
alpha
,
red
,
g
,
blue
);
}
/// Returns a new color that matches this color with the blue channel replaced
/// with
b
.
/// with
`b`
.
Color
withBlue
(
int
b
)
{
return
new
Color
.
fromARGB
(
alpha
,
red
,
green
,
b
);
}
/// Linearly interpolate between two colors
/// Linearly interpolate between two colors
.
///
/// If either color is null, this function linearly interpolates from a
/// transparent instance of the other color.
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录