Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
13582628
T
three.js
项目概览
车家大少爷
/
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,发现更多精彩内容 >>
提交
13582628
编写于
3月 07, 2018
作者:
W
WestLangley
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove optionalTarget
上级
f3d71a6e
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
62 addition
and
28 deletion
+62
-28
docs/api/math/Color.html
docs/api/math/Color.html
+2
-3
examples/js/math/ColorConverter.js
examples/js/math/ColorConverter.js
+37
-13
src/math/Color.js
src/math/Color.js
+23
-12
未找到文件。
docs/api/math/Color.html
浏览文件 @
13582628
...
...
@@ -162,10 +162,9 @@ var color = new THREE.Color( 1, 0, 0 );
<h3>
[method:String getHexString]()
</h3>
<div>
Returns the hexadecimal value of this color as a string (for example, 'FFFFFF').
</div>
<h3>
[method:Object getHSL]( [param:Object
optionalT
arget] )
</h3>
<h3>
[method:Object getHSL]( [param:Object
t
arget] )
</h3>
<div>
[page:Object optionalTarget] — (optional) if specified, adds h, s and l keys to the object (if not already present)
and sets the results there. Otherwise, a new Object will be created.
<br
/><br
/>
[page:Object target] — the result will be copied into this Object. Adds h, s and l keys to the object (if not already present).
<br
/><br
/>
Convert this Color's [page:.r r], [page:.g g] and [page:.b b] values to [link:https://en.wikipedia.org/wiki/HSL_and_HSV HSL]
format and returns an object of the form:
...
...
examples/js/math/ColorConverter.js
浏览文件 @
13582628
...
...
@@ -17,20 +17,33 @@ THREE.ColorConverter = {
},
getHSV
:
function
(
color
)
{
getHSV
:
function
()
{
var
hsl
=
color
.
getHSL
()
;
var
hsl
=
{}
;
// based on https://gist.github.com/xpansive/1337890#file-index-js
hsl
.
s
*=
(
hsl
.
l
<
0.5
)
?
hsl
.
l
:
(
1
-
hsl
.
l
);
return
function
getHSV
(
color
,
target
)
{
if
(
target
===
undefined
)
{
console
.
warn
(
'
THREE.ColorConverter: .getHSV() target is now required
'
);
target
=
{
h
:
0
,
s
:
0
,
l
:
0
};
}
color
.
getHSL
(
hsl
);
// based on https://gist.github.com/xpansive/1337890#file-index-js
hsl
.
s
*=
(
hsl
.
l
<
0.5
)
?
hsl
.
l
:
(
1
-
hsl
.
l
);
target
.
h
=
hsl
.
h
;
target
.
s
=
2
*
hsl
.
s
/
(
hsl
.
l
+
hsl
.
s
);
target
.
v
=
hsl
.
l
+
hsl
.
s
;
return
target
;
return
{
h
:
hsl
.
h
,
s
:
2
*
hsl
.
s
/
(
hsl
.
l
+
hsl
.
s
),
v
:
hsl
.
l
+
hsl
.
s
};
},
}
()
,
// where c, m, y, k is between 0 and 1
...
...
@@ -44,19 +57,30 @@ THREE.ColorConverter = {
},
getCMYK
:
function
(
color
)
{
getCMYK
:
function
(
color
,
target
)
{
if
(
target
===
undefined
)
{
console
.
warn
(
'
THREE.ColorConverter: .getCMYK() target is now required
'
);
target
=
{
c
:
0
,
m
:
0
,
y
:
0
,
k
:
0
};
}
var
r
=
color
.
r
;
var
g
=
color
.
g
;
var
b
=
color
.
b
;
var
k
=
1
-
Math
.
max
(
r
,
g
,
b
);
var
c
=
(
1
-
r
-
k
)
/
(
1
-
k
);
var
m
=
(
1
-
g
-
k
)
/
(
1
-
k
);
var
y
=
(
1
-
b
-
k
)
/
(
1
-
k
);
return
{
c
:
c
,
m
:
m
,
y
:
y
,
k
:
k
};
target
.
c
=
c
;
target
.
m
=
m
;
target
.
y
=
y
;
target
.
k
=
k
;
return
target
;
}
...
...
src/math/Color.js
浏览文件 @
13582628
...
...
@@ -347,11 +347,16 @@ Object.assign( Color.prototype, {
},
getHSL
:
function
(
optionalT
arget
)
{
getHSL
:
function
(
t
arget
)
{
// h,s,l ranges are in 0.0 - 1.0
var
hsl
=
optionalTarget
||
{
h
:
0
,
s
:
0
,
l
:
0
};
if
(
target
===
undefined
)
{
console
.
warn
(
'
THREE.Color: .getHSL() target is now required
'
);
target
=
{
h
:
0
,
s
:
0
,
l
:
0
};
}
var
r
=
this
.
r
,
g
=
this
.
g
,
b
=
this
.
b
;
...
...
@@ -384,11 +389,11 @@ Object.assign( Color.prototype, {
}
hsl
.
h
=
hue
;
hsl
.
s
=
saturation
;
hsl
.
l
=
lightness
;
target
.
h
=
hue
;
target
.
s
=
saturation
;
target
.
l
=
lightness
;
return
hsl
;
return
target
;
},
...
...
@@ -398,17 +403,23 @@ Object.assign( Color.prototype, {
},
offsetHSL
:
function
(
h
,
s
,
l
)
{
offsetHSL
:
function
()
{
var
hsl
=
this
.
getHSL
()
;
var
hsl
=
{}
;
hsl
.
h
+=
h
;
hsl
.
s
+=
s
;
hsl
.
l
+=
l
;
return
function
(
h
,
s
,
l
)
{
this
.
setHSL
(
hsl
.
h
,
hsl
.
s
,
hsl
.
l
);
this
.
getHSL
(
hs
l
);
return
this
;
hsl
.
h
+=
h
;
hsl
.
s
+=
s
;
hsl
.
l
+=
l
;
},
this
.
setHSL
(
hsl
.
h
,
hsl
.
s
,
hsl
.
l
);
return
this
;
};
}(),
add
:
function
(
color
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录