本文整理了Java中javafx.scene.paint.Color.hsb()
方法的一些代码示例,展示了Color.hsb()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Color.hsb()
方法的具体详情如下:
包路径:javafx.scene.paint.Color
类名称:Color
方法名:hsb
暂无
代码示例来源:origin: us.ihmc/IHMCJavaFXToolkit
private Color getColorAtIndex(int x)
{
double hue;
if (hueResolution != -1)
hue = 360.0 * (double) x / (double) hueResolution;
else
hue = 360.0 * hueConstant;
double saturation;
if (saturationResolution != -1)
{
saturation = (double) x / (double) saturationResolution;
}
else
saturation = saturationConstant;
double brightness;
if (brightnessResolution != -1)
brightness = (double) x / (double) brightnessResolution;
else
brightness = brightnessConstant;
return Color.hsb(hue, saturation, brightness);
}
代码示例来源:origin: us.ihmc/ihmc-javafx-toolkit
private Color getColorAtIndex(int x)
{
double hue;
if (hueResolution != -1)
hue = 360.0 * (double) x / (double) hueResolution;
else
hue = 360.0 * hueConstant;
double saturation;
if (saturationResolution != -1)
{
saturation = (double) x / (double) saturationResolution;
}
else
saturation = saturationConstant;
double brightness;
if (brightnessResolution != -1)
brightness = (double) x / (double) brightnessResolution;
else
brightness = brightnessConstant;
return Color.hsb(hue, saturation, brightness);
}
代码示例来源:origin: us.ihmc/ihmc-javafx-toolkit
private Color getColorAtLocation(int x, int y)
{
double hue;
if (hueResolution != -1)
hue = 360.0 * (double) x / (double) hueResolution;
else
hue = 360.0 * hueConstant;
double saturation;
if (saturationResolution != -1)
{
int index = hueResolution == -1 ? x : y;
saturation = (double) index / (double) saturationResolution;
}
else
saturation = saturationConstant;
double brightness;
if (brightnessResolution != -1)
brightness = (double) y / (double) brightnessResolution;
else
brightness = brightnessConstant;
return Color.hsb(hue, saturation, brightness);
}
代码示例来源:origin: us.ihmc/IHMCJavaFXToolkit
private Color getColorAtLocation(int x, int y)
{
double hue;
if (hueResolution != -1)
hue = 360.0 * (double) x / (double) hueResolution;
else
hue = 360.0 * hueConstant;
double saturation;
if (saturationResolution != -1)
{
int index = hueResolution == -1 ? x : y;
saturation = (double) index / (double) saturationResolution;
}
else
saturation = saturationConstant;
double brightness;
if (brightnessResolution != -1)
brightness = (double) y / (double) brightnessResolution;
else
brightness = brightnessConstant;
return Color.hsb(hue, saturation, brightness);
}
代码示例来源:origin: us.ihmc/IHMCJavaFXToolkit
private Color randomColor()
{
return Color.hsb(360.0 * random.nextDouble(), random.nextDouble(), random.nextDouble());
}
代码示例来源:origin: us.ihmc/ihmc-javafx-toolkit
public static JavaFXGraphColors javaFXStyle()
{
JavaFXGraphColors simulationConstructionSetStyle = new JavaFXGraphColors();
simulationConstructionSetStyle.setLabelColor(Color.BLACK);
simulationConstructionSetStyle.setBackgroundColor(Color.hsb(0.0, 0.0, 0.93));
simulationConstructionSetStyle.setGridAxisColor(Color.hsb(0.0, 0.0, 0.81));
simulationConstructionSetStyle.setGridEveryOneColor(Color.hsb(0.0, 0.0, 0.81));
simulationConstructionSetStyle.setGridEveryFiveColor(Color.hsb(0.0, 0.0, 0.81));
simulationConstructionSetStyle.setGridEveryTenColor(Color.hsb(0.0, 0.0, 0.81));
simulationConstructionSetStyle.setSelectionColor(Color.RED);
return simulationConstructionSetStyle;
}
代码示例来源:origin: us.ihmc/robot-environment-awareness-visualizers
public Color getNormalBasedColor(Vector3D normal, boolean isNormalSet)
{
Color color = DEFAULT_COLOR;
if (isNormalSet)
{
Vector3D zUp = new Vector3D(0.0, 0.0, 1.0);
normal.normalize();
double angle = Math.abs(zUp.dot(normal));
double hue = 120.0 * angle;
color = Color.hsb(hue, 1.0, 1.0);
}
return color;
}
代码示例来源:origin: us.ihmc/robot-environment-awareness-visualizers
public Color getNormalBasedColor(Vector3D normal, boolean isNormalSet)
{
Color color = DEFAULT_COLOR;
if (isNormalSet)
{
Vector3D zUp = new Vector3D(0.0, 0.0, 1.0);
normal.normalize();
double angle = Math.abs(zUp.dot(normal));
double hue = 120.0 * angle;
color = Color.hsb(hue, 1.0, 1.0);
}
return color;
}
代码示例来源:origin: edu.utah.bmi.nlp/nlp-core
public static int[] getRandomBeautifulColors() {
String colorString=Integer.toHexString((int)Math.floor(Math.random()*16777215));
if(colorString.length()==5) {
colorString = "0" + colorString;
// System.out.println(colorString);
}
Color color = Color.valueOf(colorString);
if(color.getSaturation()>0.78){
color=Color.hsb(color.getHue(),0.78,color.getBrightness());
}
if(color.getBrightness()<0.43){
color=Color.hsb(color.getHue(),color.getSaturation(),0.43);
}
// System.out.println(color.getRed());
// System.out.println(color.getGreen());
// System.out.println(color.getBlue());
int red = (int) (color.getRed() * 255);
int green = (int) (color.getGreen() * 255);
int blue = (int) (color.getBlue() * 255);
return new int[]{red, green, blue};
}
代码示例来源:origin: org.jrebirth.af/core
/**
* Build an HSB color.
*
* @param hsbColor the hsb color enum
*
* @return the javafx color
*/
private Color buildHSBColor(final HSBColor hsbColor) {
Color color = null;
if (hsbColor.opacity() >= 1.0) {
color = Color.hsb(hsbColor.hue(), hsbColor.saturation(), hsbColor.brightness());
} else {
color = Color.hsb(hsbColor.hue(), hsbColor.saturation(), hsbColor.brightness(), hsbColor.opacity());
}
return color;
}
代码示例来源:origin: us.ihmc/robot-environment-awareness-visualizers
private Node createConvexPolygonGraphics(PlanarRegion data)
{
List<ConvexPolygon2D> convexPolygons = new ArrayList<>();
for (int i = 0; i < data.getNumberOfConvexPolygons(); i++)
convexPolygons.add(data.getConvexPolygon(i));
JavaFXMultiColorMeshBuilder meshBuilder = new JavaFXMultiColorMeshBuilder(new TextureColorAdaptivePalette(64));
int regionId = data.getRegionId();
RigidBodyTransform rigidBodyTransform = new RigidBodyTransform();
data.getTransformToWorld(rigidBodyTransform);
Color regionColor = OcTreeMeshBuilder.getRegionColor(regionId);
for (int i = 0; i < convexPolygons.size(); i++)
{
ConvexPolygon2D convexPolygon = convexPolygons.get(i);
Color color = Color.hsb(regionColor.getHue(), 0.9, 0.5 + 0.5 * ((double) i / (double) convexPolygons.size()));
meshBuilder.addPolygon(rigidBodyTransform, convexPolygon, color);
}
MeshView meshView = new MeshView(meshBuilder.generateMesh());
meshView.setMaterial(meshBuilder.generateMaterial());
return meshView;
}
代码示例来源:origin: us.ihmc/robot-environment-awareness-visualizers
private Node createConcaveHullGraphics(PlanarRegion data)
{
int regionId = data.getRegionId();
JavaFXMultiColorMeshBuilder meshBuilder = new JavaFXMultiColorMeshBuilder(new TextureColorAdaptivePalette(16));
RigidBodyTransform transform = new RigidBodyTransform();
data.getTransformToWorld(transform);
Point2D[] concaveHullVerticesLocal = data.getConcaveHull();
Color regionColor = OcTreeMeshBuilder.getRegionColor(regionId);
List<Point3D> concaveHullVertices = Arrays.stream(concaveHullVerticesLocal).map(Point3D::new).map(p -> {
transform.transform(p);
return p;
}).collect(Collectors.toList());
for (int vertexIndex = 0; vertexIndex < concaveHullVertices.size(); vertexIndex++)
{
Point3D vertex = concaveHullVertices.get(vertexIndex);
Point3D nextVertex = ListWrappingIndexTools.getNext(vertexIndex, concaveHullVertices);
Color lineColor = Color.hsb(regionColor.getHue(), regionColor.getSaturation(), regionColor.getBrightness());
meshBuilder.addLine(vertex, nextVertex, 0.0015, lineColor);
}
MeshView meshView = new MeshView(meshBuilder.generateMesh());
meshView.setMaterial(meshBuilder.generateMaterial());
meshView.setMouseTransparent(true);
return meshView;
}
代码示例来源:origin: us.ihmc/robot-environment-awareness-visualizers
private Node createConvexDecompositionGraphics(PlanarRegionSegmentationRawData rawData,
ConcaveHullFactoryResult concaveHullFactoryResult)
{
ConcaveHullCollection concaveHullCollection = concaveHullFactoryResult.getConcaveHullCollection();
double depthThreshold = polygonizerParameters.getDepthThreshold();
List<ConvexPolygon2D> convexPolygons = new ArrayList<>();
ConcaveHullDecomposition.recursiveApproximateDecomposition(concaveHullCollection, depthThreshold, convexPolygons);
JavaFXMultiColorMeshBuilder meshBuilder = new JavaFXMultiColorMeshBuilder(new TextureColorAdaptivePalette(64));
int regionId = rawData.getRegionId();
RigidBodyTransform rigidBodyTransform = rawData.getTransformFromLocalToWorld();
Color regionColor = OcTreeMeshBuilder.getRegionColor(regionId);
for (int i = 0; i < convexPolygons.size(); i++)
{
ConvexPolygon2D convexPolygon = convexPolygons.get(i);
Color color = Color.hsb(regionColor.getHue(), 0.9, 0.5 + 0.5 * ((double) i / (double) convexPolygons.size()));
meshBuilder.addPolygon(rigidBodyTransform, convexPolygon, color);
}
MeshView meshView = new MeshView(meshBuilder.generateMesh());
meshView.setMaterial(meshBuilder.generateMaterial());
return meshView;
}
代码示例来源:origin: us.ihmc/robot-environment-awareness-visualizers
private Node createDelaunayTriangulationGraphics(PlanarRegionSegmentationRawData rawData,
ConcaveHullFactoryResult concaveHullFactoryResult)
{
JavaFXMultiColorMeshBuilder meshBuilder = new JavaFXMultiColorMeshBuilder(new TextureColorAdaptivePalette(512));
Point3D planeOrigin = rawData.getOrigin();
Vector3D planeNormal = rawData.getNormal();
List<QuadEdgeTriangle> allTriangles = concaveHullFactoryResult.getAllTriangles();
for (QuadEdgeTriangle triangle : allTriangles)
{
List<Point2D> triangleVerticesLocal = Arrays.stream(triangle.getVertices()).map(v -> new Point2D(v.getX(), v.getY())).collect(Collectors.toList());
triangleVerticesLocal.forEach(vertex -> {
vertex.setX(vertex.getX() * scaleX);
vertex.setY(vertex.getY() * scaleY);
});
List<Point3D> triangleVerticesWorld = PolygonizerTools.toPointsInWorld(triangleVerticesLocal, planeOrigin, planeNormal);
double hue = 360.0 * random.nextDouble();
double saturation = 0.8 * random.nextDouble() + 0.1;
double brightness = 0.9;
meshBuilder.addPolyon(triangleVerticesWorld, Color.hsb(hue, saturation, brightness));
}
MeshView trianglesMeshView = new MeshView(meshBuilder.generateMesh());
trianglesMeshView.setMaterial(meshBuilder.generateMaterial());
return trianglesMeshView;
}
代码示例来源:origin: us.ihmc/robot-environment-awareness
@Override
public void run()
{
if (!enable.get())
return;
LidarScanMessage message = newMessageToRender.getAndSet(null);
if (message == null)
return;
Point3D32 scanPoint = new Point3D32();
meshBuilder.clear();
int numberOfScanPoints = message.getScan().size() / 3;
for (int i = 0; i < numberOfScanPoints; i++)
{
double alpha = i / (double) numberOfScanPoints;
Color color = Color.hsb(alpha * 240.0, 1.0, 1.0);
MessageTools.unpackScanPoint(message, i, scanPoint);
meshBuilder.addMesh(MeshDataGenerator.Tetrahedron(SCAN_POINT_SIZE), scanPoint, color);
}
MeshView scanMeshView = new MeshView(meshBuilder.generateMesh());
scanMeshView.setMaterial(meshBuilder.generateMaterial());
scanMeshToRender.set(scanMeshView);
meshBuilder.clear();
}
代码示例来源:origin: us.ihmc/ihmc-robot-data-visualizer
private void computeScanMesh()
{
LidarScanMessage message = newMessageToRender.getAndSet(null);
if (message == null)
return;
Point3D32 scanPoint = new Point3D32();
scanMeshBuilder.clear();
int numberOfScanPoints = message.getScan().size() / 3;
for (int i = 0; i < numberOfScanPoints; i++)
{
double alpha = i / (double) numberOfScanPoints;
Color color = Color.hsb(alpha * 240.0, 1.0, 1.0);
MessageTools.unpackScanPoint(message, i, scanPoint);
scanMeshBuilder.addMesh(MeshDataGenerator.Tetrahedron(SCAN_POINT_SIZE), scanPoint, color);
}
MeshView scanMeshView = new MeshView(scanMeshBuilder.generateMesh());
scanMeshView.setMaterial(scanMeshBuilder.generateMaterial());
scanMeshToRender.set(scanMeshView);
scanMeshBuilder.clear();
}
代码示例来源:origin: us.ihmc/IHMCRobotDataVisualizer
private void computeScanMesh()
{
LidarScanMessage message = newMessageToRender.getAndSet(null);
if (message == null)
return;
Point3f scanPoint = new Point3f();
scanMeshBuilder.clear();
for (int i = 0; i < message.getNumberOfScanPoints(); i++)
{
double alpha = i / (double) message.getNumberOfScanPoints();
Color color = Color.hsb(alpha * 240.0, 1.0, 1.0);
message.getScanPoint(i, scanPoint);
scanMeshBuilder.addMesh(MeshDataGenerator.Tetrahedron(SCAN_POINT_SIZE), scanPoint, color);
}
MeshView scanMeshView = new MeshView(scanMeshBuilder.generateMesh());
scanMeshView.setMaterial(scanMeshBuilder.generateMaterial());
scanMeshToRender.set(scanMeshView);
scanMeshBuilder.clear();
}
代码示例来源:origin: us.ihmc/robot-environment-awareness
private Pair<Mesh, Material> generateMeshAndMaterial(PlanarRegionsListMessage newMessage)
{
meshBuilder.clear();
double lineWidth = 0.01;
RigidBodyTransform transformToWorld = new RigidBodyTransform();
PlanarRegionsList planarRegionsList = PlanarRegionMessageConverter.convertToPlanarRegionsList(newMessage);
for (int regionIndex = 0; regionIndex < planarRegionsList.getNumberOfPlanarRegions(); regionIndex++)
{
PlanarRegion planarRegion = planarRegionsList.getPlanarRegion(regionIndex);
int regionId = planarRegion.getRegionId();
Color regionColor = getRegionColor(regionId);
planarRegion.getTransformToWorld(transformToWorld);
meshBuilder.addMultiLine(transformToWorld, planarRegion.getConcaveHull(), lineWidth, regionColor, true);
for (int polygonIndex = 0; polygonIndex < planarRegion.getNumberOfConvexPolygons(); polygonIndex++)
{
ConvexPolygon2D convexPolygon2d = planarRegion.getConvexPolygon(polygonIndex);
regionColor = Color.hsb(regionColor.getHue(), 0.9, 0.5 + 0.5 * ((double) polygonIndex / (double) planarRegion.getNumberOfConvexPolygons()));
meshBuilder.addPolygon(transformToWorld, convexPolygon2d, regionColor);
}
}
Material material = meshBuilder.generateMaterial();
Mesh mesh = meshBuilder.generateMesh();
return new Pair<>(mesh, material);
}
代码示例来源:origin: us.ihmc/robot-environment-awareness-visualizers
private Pair<Mesh, Material> generateMeshAndMaterial(PlanarRegionsListMessage newMessage)
{
meshBuilder.clear();
double lineWidth = 0.01;
RigidBodyTransform transformToWorld = new RigidBodyTransform();
PlanarRegionsList planarRegionsList = PlanarRegionMessageConverter.convertToPlanarRegionsList(newMessage);
for (int regionIndex = 0; regionIndex < planarRegionsList.getNumberOfPlanarRegions(); regionIndex++)
{
PlanarRegion planarRegion = planarRegionsList.getPlanarRegion(regionIndex);
int regionId = planarRegion.getRegionId();
Color regionColor = getRegionColor(regionId);
planarRegion.getTransformToWorld(transformToWorld);
meshBuilder.addMultiLine(transformToWorld, planarRegion.getConcaveHull(), lineWidth, regionColor, true);
for (int polygonIndex = 0; polygonIndex < planarRegion.getNumberOfConvexPolygons(); polygonIndex++)
{
ConvexPolygon2D convexPolygon2d = planarRegion.getConvexPolygon(polygonIndex);
regionColor = Color.hsb(regionColor.getHue(), 0.9, 0.5 + 0.5 * ((double) polygonIndex / (double) planarRegion.getNumberOfConvexPolygons()));
meshBuilder.addPolygon(transformToWorld, convexPolygon2d, regionColor);
}
}
Material material = meshBuilder.generateMaterial();
Mesh mesh = meshBuilder.generateMesh();
return new Pair<>(mesh, material);
}
代码示例来源:origin: us.ihmc/ihmc-footstep-planning-visualizers
private void processFootMesh(FootstepNode node, FootstepNodeSnapData snapData, boolean valid)
{
meshBuilder.clear();
RigidBodyTransform planarTransformToWorld = new RigidBodyTransform();
FootstepNodeTools.getNodeTransform(node, planarTransformToWorld);
RigidBodyTransform snappedTransformToWorld = new RigidBodyTransform();
ConvexPolygon2D foothold = snapData.getCroppedFoothold();
FootstepNodeTools.getSnappedNodeTransform(node, snapData.getSnapTransform(), snappedTransformToWorld);
snappedTransformToWorld.appendTranslation(0.0, 0.0, 0.01);
planarTransformToWorld.setTranslationZ(snappedTransformToWorld.getTranslationZ() + 0.1);
Color regionColor = valid ? Color.GREEN : Color.RED;
regionColor = Color.hsb(regionColor.getHue(), 0.9, 1.0);
Point2D[] vertices = new Point2D[foothold.getNumberOfVertices()];
for (int j = 0; j < vertices.length; j++)
{
vertices[j] = new Point2D(foothold.getVertex(j));
}
meshBuilder.addMultiLine(snappedTransformToWorld, vertices, 0.01, regionColor, true);
meshBuilder.addPolygon(snappedTransformToWorld, foothold, regionColor);
// TODO add mesh of planar footstep
meshView.setOpacity(0.9);
meshView.setMesh(meshBuilder.generateMesh());
meshView.setMaterial(meshBuilder.generateMaterial());
}
内容来源于网络,如有侵权,请联系作者删除!