Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
0642eea1
T
three.js
项目概览
Ablesons
/
three.js
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
three.js
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
0642eea1
编写于
12月 31, 2012
作者:
B
Brian Cajes
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
up Color.js test coverage to 78%
上级
9265c017
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
167 addition
and
1 deletion
+167
-1
test/unit/math/Color.js
test/unit/math/Color.js
+167
-1
未找到文件。
test/unit/math/Color.js
浏览文件 @
0642eea1
...
...
@@ -18,8 +18,174 @@ test( "copy", function(){
test
(
"
setRGB
"
,
function
(){
var
c
=
new
THREE
.
Color
()
c
.
setRGB
(
0
,
1
,
2
);
c
.
setRGB
(
0
,
1
,
1
);
ok
(
c
.
r
==
0
,
"
Red:
"
+
c
.
r
);
ok
(
c
.
g
==
1
,
"
Green:
"
+
c
.
g
);
ok
(
c
.
b
==
1
,
"
Blue:
"
+
c
.
b
);
});
test
(
"
copyGammaToLinear
"
,
function
(){
var
c
=
new
THREE
.
Color
();
var
c2
=
new
THREE
.
Color
();
c2
.
setRGB
(
2
,
2
,
2
)
c
.
copyGammaToLinear
(
c2
)
ok
(
c
.
r
==
4
,
"
Red c:
"
+
c
.
r
+
"
Red c2:
"
+
c2
.
r
);
ok
(
c
.
g
==
4
,
"
Green c:
"
+
c
.
g
+
"
Green c2:
"
+
c2
.
g
);
ok
(
c
.
b
==
4
,
"
Blue c:
"
+
c
.
g
+
"
Blue c2:
"
+
c2
.
b
);
});
test
(
"
copyLinearToGamma
"
,
function
(){
var
c
=
new
THREE
.
Color
();
var
c2
=
new
THREE
.
Color
();
c2
.
setRGB
(
4
,
4
,
4
)
c
.
copyLinearToGamma
(
c2
)
ok
(
c
.
r
==
2
,
"
Red c:
"
+
c
.
r
+
"
Red c2:
"
+
c2
.
r
);
ok
(
c
.
g
==
2
,
"
Green c:
"
+
c
.
g
+
"
Green c2:
"
+
c2
.
g
);
ok
(
c
.
b
==
2
,
"
Blue c:
"
+
c
.
g
+
"
Blue c2:
"
+
c2
.
b
);
});
test
(
"
convertGammaToLinear
"
,
function
(){
var
c
=
new
THREE
.
Color
();
c
.
setRGB
(
2
,
2
,
2
)
c
.
convertGammaToLinear
()
ok
(
c
.
r
==
4
,
"
Red:
"
+
c
.
r
);
ok
(
c
.
g
==
4
,
"
Green:
"
+
c
.
g
);
ok
(
c
.
b
==
4
,
"
Blue:
"
+
c
.
b
);
});
test
(
"
convertLinearToGamma
"
,
function
(){
var
c
=
new
THREE
.
Color
();
c
.
setRGB
(
4
,
4
,
4
)
c
.
convertLinearToGamma
()
ok
(
c
.
r
==
2
,
"
Red:
"
+
c
.
r
);
ok
(
c
.
g
==
2
,
"
Green:
"
+
c
.
g
);
ok
(
c
.
b
==
2
,
"
Blue:
"
+
c
.
b
);
});
test
(
"
setWithNum
"
,
function
(){
var
c
=
new
THREE
.
Color
();
c
.
set
(
0xFF0000
);
ok
(
c
.
r
==
1
,
"
Red:
"
+
c
.
r
);
ok
(
c
.
g
==
0
,
"
Green:
"
+
c
.
g
);
ok
(
c
.
b
==
0
,
"
Blue:
"
+
c
.
b
);
});
test
(
"
setWithString
"
,
function
(){
var
c
=
new
THREE
.
Color
();
c
.
set
(
'
red
'
);
ok
(
c
.
r
==
1
,
"
Red:
"
+
c
.
r
);
ok
(
c
.
g
==
0
,
"
Green:
"
+
c
.
g
);
ok
(
c
.
b
==
0
,
"
Blue:
"
+
c
.
b
);
});
test
(
"
clone
"
,
function
(){
var
c
=
new
THREE
.
Color
(
'
red
'
);
var
c2
=
c
.
clone
();
ok
(
c2
.
r
==
1
,
"
Red c:
"
+
c
.
r
+
"
Red c2:
"
+
c2
.
r
);
ok
(
c2
.
g
==
0
,
"
Green c:
"
+
c
.
g
+
"
Green c2:
"
+
c2
.
g
);
ok
(
c2
.
b
==
0
,
"
Blue c:
"
+
c
.
g
+
"
Blue c2:
"
+
c2
.
b
);
});
test
(
"
lerpSelf
"
,
function
(){
var
c
=
new
THREE
.
Color
();
var
c2
=
new
THREE
.
Color
();
c
.
setRGB
(
0
,
0
,
0
);
c
.
lerpSelf
(
c2
,
2
);
ok
(
c
.
r
==
2
,
"
Red:
"
+
c
.
r
);
ok
(
c
.
g
==
2
,
"
Green:
"
+
c
.
g
);
ok
(
c
.
b
==
2
,
"
Blue:
"
+
c
.
b
);
});
test
(
"
setStyleRGBRed
"
,
function
(){
var
c
=
new
THREE
.
Color
();
c
.
setStyle
(
'
rgb(255,0,0)
'
);
ok
(
c
.
r
==
1
,
"
Red:
"
+
c
.
r
);
ok
(
c
.
g
==
0
,
"
Green:
"
+
c
.
g
);
ok
(
c
.
b
==
0
,
"
Blue:
"
+
c
.
b
);
});
test
(
"
setStyleRGBPercentRed
"
,
function
(){
var
c
=
new
THREE
.
Color
();
c
.
setStyle
(
'
rgb(100%,0%,0%)
'
);
ok
(
c
.
r
==
1
,
"
Red:
"
+
c
.
r
);
ok
(
c
.
g
==
0
,
"
Green:
"
+
c
.
g
);
ok
(
c
.
b
==
0
,
"
Blue:
"
+
c
.
b
);
});
test
(
"
setStyleHexRed
"
,
function
(){
var
c
=
new
THREE
.
Color
();
c
.
setStyle
(
'
#ff0000
'
);
ok
(
c
.
r
==
1
,
"
Red:
"
+
c
.
r
);
ok
(
c
.
g
==
0
,
"
Green:
"
+
c
.
g
);
ok
(
c
.
b
==
0
,
"
Blue:
"
+
c
.
b
);
});
test
(
"
setStyleHex2Red
"
,
function
(){
var
c
=
new
THREE
.
Color
();
c
.
setStyle
(
'
#f00
'
);
ok
(
c
.
r
==
1
,
"
Red:
"
+
c
.
r
);
ok
(
c
.
g
==
0
,
"
Green:
"
+
c
.
g
);
ok
(
c
.
b
==
0
,
"
Blue:
"
+
c
.
b
);
});
test
(
"
setStyleColorName
"
,
function
(){
var
c
=
new
THREE
.
Color
();
c
.
setStyle
(
'
red
'
);
ok
(
c
.
r
==
1
,
"
Red:
"
+
c
.
r
);
ok
(
c
.
g
==
0
,
"
Green:
"
+
c
.
g
);
ok
(
c
.
b
==
0
,
"
Blue:
"
+
c
.
b
);
});
test
(
"
getHex
"
,
function
(){
var
c
=
new
THREE
.
Color
(
'
red
'
);
var
res
=
c
.
getHex
();
ok
(
res
==
0xFF0000
,
"
Hex:
"
+
res
);
});
test
(
"
setHex
"
,
function
(){
var
c
=
new
THREE
.
Color
();
c
.
setHex
(
0xFF0000
);
ok
(
c
.
r
==
1
,
"
Red:
"
+
c
.
r
);
ok
(
c
.
g
==
0
,
"
Green:
"
+
c
.
g
);
ok
(
c
.
b
==
0
,
"
Blue:
"
+
c
.
b
);
});
test
(
"
getHexString
"
,
function
(){
var
c
=
new
THREE
.
Color
(
'
red
'
);
var
res
=
c
.
getHexString
();
ok
(
res
==
'
ff0000
'
,
"
Hex:
"
+
res
);
});
test
(
"
getStyle
"
,
function
(){
var
c
=
new
THREE
.
Color
(
'
red
'
);
var
res
=
c
.
getStyle
();
ok
(
res
==
'
rgb(255,0,0)
'
,
"
style:
"
+
res
);
});
test
(
"
getHSV
"
,
function
(){
var
c
=
new
THREE
.
Color
(
'
red
'
);
var
hsv
=
c
.
getHSV
();
ok
(
hsv
.
h
==
0
,
"
hue:
"
+
hsv
.
h
);
ok
(
hsv
.
s
==
1
,
"
saturation:
"
+
hsv
.
s
);
ok
(
hsv
.
v
==
1
,
"
value:
"
+
hsv
.
v
);
});
test
(
"
setHSV
"
,
function
(){
var
c
=
new
THREE
.
Color
();
c
.
setHSV
(
0
,
1
,
1
);
var
hsv
=
c
.
getHSV
();
ok
(
hsv
.
h
==
0
,
"
hue:
"
+
hsv
.
h
);
ok
(
hsv
.
s
==
1
,
"
saturation:
"
+
hsv
.
s
);
ok
(
hsv
.
v
==
1
,
"
value:
"
+
hsv
.
v
);
});
// xxx todo more hsv tests
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录