Here you can find the source of vectorToColor(float x, float y, float z)
Parameter | Description |
---|---|
x | X factor of the vector |
y | Y factor of the vector |
z | Z factor of the vector |
private static int vectorToColor(float x, float y, float z)
//package com.java2s; //License from project: Open Source License public class Main { /**//from ww w . java2s . c om * This method transforms given vector's coordinates into ARGB color (A is * always = 255). * * @param x * X factor of the vector * @param y * Y factor of the vector * @param z * Z factor of the vector * @return color representation of the given vector */ private static int vectorToColor(float x, float y, float z) { int r = Math.round(255 * (x + 1f) / 2f); int g = Math.round(255 * (y + 1f) / 2f); int b = Math.round(255 * (z + 1f) / 2f); return (255 << 24) + (r << 16) + (g << 8) + b; } }