- 最后登录
- 2024-6-3
- 注册时间
- 2009-10-16
- 阅读权限
- 100
- 积分
- 18803
  
- 纳金币
- 17488
- 精华
- 1
|
HSV Colors (Script Utilities Behavior)
Summary
Extends all Color objects to support hue/saturation/value properties.
Category
Latest Behaviors
Author
Gavin Kistner
Difficulty
(Reference)
Time to Complete
5 Minutes
Downloads
Click Here
to download the associated files.
(This document covers version 1.0 of the 'HSV Colors' behavior, current as of 2005-Feb-11)
Description
This utility library extends Color objects to support
.h
,
.s
, and
.v
properties for
HSV
(Hue, Saturation, Value) manipulations.
Hue values are specified and returned as numbers in the range 0..360, with pure red being 0, pure green 120, and pure blue 240.
Saturation and Value values are specified and returned as numbers in the range 0..100.
To use, simply attach this behavior anywhere in the scene. (You have to actually attach it to add the functionality; loading it into the library for the project is not enough.)
Example code:
//Set the material to a dark red color
myMaterial.diffuse = new Color( 150, 0, 0 );
var theColor = myMaterial.diffuse;
alert(theColor.h+', '+theColor.h+', '+theColor.v);
//alerts "0, 0, 58.82352941176471"
theColor.h = 120;
//theColor is now 0, 150, 0
theColor.h = 30;
//theColor is now 150, 75, 0
theColor.v = 100
//theColor is now 255, 128, 0
theColor.s = 50;
//theColor is now 255 192 128
Note that changes to the hue or saturation do not take effect when the value is exactly 0, and changes to the hue will not take effect when the saturation is 0.
Demonstration
![]()
View Demonstration Project
![]()
Download Project File
|
|