提交 0cc77571 编写于 作者: @ @pauloddr

Color: rename setStyleName() to setColorName()

上级 1aa5350b
......@@ -302,7 +302,7 @@ var color = new THREE.Color( 1, 0, 0 );
Note that for X11 color names, multiple words such as Dark Orange become the string 'darkorange' (all lowercase).
</p>
<h3>[method:Color setStyleName]( [param:String style] ) </h3>
<h3>[method:Color setColorName]( [param:String style] ) </h3>
<p>
[page:String style] — color name ( from [link:https://en.wikipedia.org/wiki/X11_color_names#Color_name_chart X11 color names] ).<br /><br />
......
......@@ -68,6 +68,13 @@ export class Color {
*/
setStyle( style: string ): Color;
/**
* Sets this color from a color name.
* Faster than {@link Color#setStyle .setStyle()} method if you don't need the other CSS-style formats.
* @param style Color name in X11 format.
*/
setColorName( style: string ): Color;
/**
* Clones this color.
*/
......@@ -183,4 +190,9 @@ export class Color {
*/
toArray( xyz: ArrayLike<number>, offset?: number ): ArrayLike<number>;
/**
* List of X11 color names.
*/
static NAMES: Record<string, number>;
}
......@@ -261,7 +261,7 @@ Object.assign( Color.prototype, {
if ( style && style.length > 0 ) {
return this.setStyleName( style );
return this.setColorName( style );
}
......@@ -269,7 +269,7 @@ Object.assign( Color.prototype, {
},
setStyleName: function ( style ) {
setColorName: function ( style ) {
// color keywords
var hex = _colorKeywords[ style ];
......
......@@ -144,12 +144,17 @@ export default QUnit.module( 'Maths', () => {
assert.ok( a.g == 0xAB / 255, "Green: " + a.g );
assert.ok( a.b == 0xC1 / 255, "Blue: " + a.b );
a.setStyle( "aliceblue" );
assert.ok( a.r == 0xF0 / 255, "Red: " + a.r );
assert.ok( a.g == 0xF8 / 255, "Green: " + a.g );
assert.ok( a.b == 0xFF / 255, "Blue: " + a.b );
} );
QUnit.test( "setStyleName", ( assert ) => {
QUnit.test( "setColorName", ( assert ) => {
var c = new Color();
var res = c.setStyleName( "aliceblue" );
var res = c.setColorName( "aliceblue" );
assert.ok( c.getHex() == 0xF0F8FF, "Hex: " + c.getHex() );
assert.ok( c == res, "Returns Self" );
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册