001/* 002Copyright 2006 Jerry Huxtable 003 004Licensed under the Apache License, Version 2.0 (the "License"); 005you may not use this file except in compliance with the License. 006You may obtain a copy of the License at 007 008 http://www.apache.org/licenses/LICENSE-2.0 009 010Unless required by applicable law or agreed to in writing, software 011distributed under the License is distributed on an "AS IS" BASIS, 012WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013See the License for the specific language governing permissions and 014limitations under the License. 015*/ 016 017package com.jhlabs.vecmath; 018 019import java.awt.*; 020 021/** 022 * Vector math package, converted to look similar to javax.vecmath. 023 */ 024public class Color4f extends Tuple4f { 025 026 public Color4f() { 027 this( 0, 0, 0, 0 ); 028 } 029 030 public Color4f( float[] x ) { 031 this.x = x[0]; 032 this.y = x[1]; 033 this.z = x[2]; 034 this.w = x[3]; 035 } 036 037 public Color4f( float x, float y, float z, float w ) { 038 this.x = x; 039 this.y = y; 040 this.z = z; 041 this.w = w; 042 } 043 044 public Color4f( Color4f t ) { 045 this.x = t.x; 046 this.y = t.y; 047 this.z = t.z; 048 this.w = t.w; 049 } 050 051 public Color4f( Tuple4f t ) { 052 this.x = t.x; 053 this.y = t.y; 054 this.z = t.z; 055 this.w = t.w; 056 } 057 058 public Color4f( Color c ) { 059 set( c ); 060 } 061 062 public void set( Color c ) { 063 set( c.getRGBComponents( null ) ); 064 } 065 066 public Color get() { 067 return new Color( x, y, z, w ); 068 } 069}