Category:LSL Color/ko

From Second Life Wiki

Second Life Wiki > > Category: LSL Color/ko
Jump to: navigation, search

LSL 색상

LSL은 자체 색상형식을 갖추고 있다. LSL은 색상을 저장하기 위해 벡터를 사용한다. 각 채널이 0 -> 255의 값을 갖는 일반적인 RGB과 달리, LSL 색상 채널은 0 -> 1의 값을 갖는다.

형식: <R, G, B>

• float x 빨강 [0, 1]
• float y 초록 [0, 1]
• float z 파랑 [0, 1]

예제

vector white = <1.0, 1.0, 1.0>;
vector grey = <0.5, 0.5, 0.5>;
vector black = <0.0, 0.0, 0.0>;
vector red = <1.0, 0.0, 0.0>;
vector green = <0.0, 1.0, 0.0>;
vector blue = <0.0, 0.0, 1.0>;
vector yellow = <1.0, 1.0, 0.0>;
vector cyan = <0.0, 1.0, 1.0>;
vector magenta = <1.0, 0.0, 1.0>;

유용한 조각

색상과 투명도를 정수로/에서 저장/반환하는 함수

integer ColorAlphatoRGBA(vector color, float alpha) {
	return (((integer)(alpha * 255.0) & 0xFF) << 24) |
		(((integer)(color.x * 255.0) & 0xFF) << 16) |
		(((integer)(color.y * 255.0) & 0xFF) << 8) |
		((integer)(color.z * 255.0) & 0xFF);
}
 
vector RGBAtoColor(integer rgba) {
	return < (rgba >> 16) & 0xFF, (rgba >> 8) & 0xFF, rgba & 0xFF > / 255.0;
}
 
float RGBAtoAlpha(integer rgba) {
	return ((rgba >> 24) & 0xFF) / 255.0;
}

This category currently contains no pages or media.