Skip to content
Snippets Groups Projects
Commit 2e04b05b authored by Johannes Eder's avatar Johannes Eder
Browse files

added new utility class

refs 1577
parent cd1fe986
No related branches found
No related tags found
No related merge requests found
/*--------------------------------------------------------------------------+
$Id$
| |
| Copyright 2013 ForTISS GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.graphicsGL.ui.util;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.RGB;
import org.fortiss.tooling.graphicsGL.model.Color3D;
import org.fortiss.tooling.graphicsGL.util.Graphics3DModelElementFactory;
/**
* Util methods for colors
*
* @author eder
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: 755511EFA211214AC8F99622469EA543
*/
public class ColorUtil {
/**
* RGB to Color3D
*
* @param rgb
* color
*
* @return rgb color as Color3D object
*/
public static Color3D rgbToColor3D(RGB rgb) {
return Graphics3DModelElementFactory.color(rgb.red / 255.f, rgb.green / 255.f,
rgb.blue / 255.f);
}
/**
* Color3D to Color (SWT)
*
* @param color
* Color3D
* @return Color3D as Color (SWT) object
*/
public static Color toSWTColor(Color3D color) {
return new Color(null, (int)(255 * color.getRed()), (int)(255 * color.getGreen()),
(int)(255 * color.getBlue()));
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment