本文整理汇总了Java中com.jme3.math.ColorRGBA.clamp方法的典型用法代码示例。如果您正苦于以下问题:Java ColorRGBA.clamp方法的具体用法?Java ColorRGBA.clamp怎么用?Java ColorRGBA.clamp使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.jme3.math.ColorRGBA
的用法示例。
在下文中一共展示了ColorRGBA.clamp方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateBrightnessPalette
import com.jme3.math.ColorRGBA; //导入方法依赖的package包/类
private void updateBrightnessPalette() {
float startingInitialBrightness = restrictionType.getValueBar();
for (BaseElement el : barPalette.getElements()) {
ColorRGBA rgba = ExtrasUtil.toRGBA(mHue, mSaturation, startingInitialBrightness / (MAX_BRIGHTNESS_BAR - 1.0f));
rgba.clamp();
el.setDefaultColor(rgba);
startingInitialBrightness++;
}
}
示例2: updateHuePalette
import com.jme3.math.ColorRGBA; //导入方法依赖的package包/类
private void updateHuePalette() {
Vector2f offset = ((HueLayout) huePicker.getLayoutManager()).getOffset(huePicker);
for (BaseElement el : huePicker.getElements()) {
ColorCell splotch = (ColorCell) el;
Vector2f cellSize = splotch.getDimensions();
float cx = 6 * cellSize.x - 6 * (cellSize.x / 2);
float cy = 6 * getIndent();
Vector2f pos = splotch.getPosition();
float[] polar = getPolar(pos.x - cx - offset.x, pos.y - cy - offset.y);
ColorRGBA rgba = ExtrasUtil.toRGBA(polar[1] / (FastMath.PI * 2f), polar[0] / (cellSize.x * 5.5f), mBrightness);
rgba.clamp();
splotch.setDefaultColor(rgba);
}
}
示例3: doClearAlphaMap
import com.jme3.math.ColorRGBA; //导入方法依赖的package包/类
private void doClearAlphaMap(int selectedTextureIndex) {
Terrain terrain = (Terrain) getTerrain(null);
if (terrain == null)
return;
int alphaIdx = selectedTextureIndex/4; // 4 = rgba = 4 textures
int texIndex = selectedTextureIndex - ((selectedTextureIndex/4)*4); // selectedTextureIndex/4 is an int floor
//selectedTextureIndex - (alphaIdx * 4)
Texture tex = doGetAlphaTexture(terrain, alphaIdx);
Image image = tex.getImage();
PaintTerrainToolAction paint = new PaintTerrainToolAction();
ColorRGBA color = ColorRGBA.Black;
for (int y=0; y<image.getHeight(); y++) {
for (int x=0; x<image.getWidth(); x++) {
paint.manipulatePixel(image, x, y, color, false); // gets the color at that location (false means don't write to the buffer)
switch (texIndex) {
case 0:
color.r = 0; break;
case 1:
color.g = 0; break;
case 2:
color.b = 0; break;
case 3:
color.a = 0; break;
default:
throw new IllegalArgumentException("Invalid texIndex " + texIndex);
}
color.clamp();
paint.manipulatePixel(image, x, y, color, true); // set the new color
}
}
image.getData(0).rewind();
tex.getImage().setUpdateNeeded();
setNeedsSave(true);
alphaLayersChanged();
}
示例4: doClearAlphaMap
import com.jme3.math.ColorRGBA; //导入方法依赖的package包/类
public final static void doClearAlphaMap(Terrain terrain, int selectedTextureIndex) {
int alphaIdx = selectedTextureIndex / 4; // 4 = rgba = 4 textures
int texIndex = selectedTextureIndex - ((selectedTextureIndex/4)*4); // selectedTextureIndex/4 is an int floor
//selectedTextureIndex - (alphaIdx * 4)
Texture tex = doGetAlphaTexture(terrain, alphaIdx);
Image image = tex.getImage();
PaintTerrainToolAction paint = new PaintTerrainToolAction();
ColorRGBA color = ColorRGBA.Black;
for (int y=0; y<image.getHeight(); y++) {
for (int x=0; x<image.getWidth(); x++) {
paint.manipulatePixel(image, x, y, color, false); // gets the color at that location (false means don't write to the buffer)
switch (texIndex) {
case 0:
color.r = 0; break;
case 1:
color.g = 0; break;
case 2:
color.b = 0; break;
case 3:
color.a = 0; break;
}
color.clamp();
paint.manipulatePixel(image, x, y, color, true); // set the new color
}
}
image.getData(0).rewind();
tex.getImage().setUpdateNeeded();
}
示例5: doPaintAction
import com.jme3.math.ColorRGBA; //导入方法依赖的package包/类
/**
* Goes through each pixel in the image. At each pixel it looks to see if the UV mouse coordinate is within the
* of the brush. If it is in the brush radius, it gets the existing color from that pixel so it can add/subtract to/from it.
* Essentially it does a radius check and adds in a fade value. It does this to the color value returned by the
* first pixel color query.
* Next it sets the color of that pixel. If it was within the radius, the color will change. If it was outside
* the radius, then nothing will change, the color will be the same; but it will set it nonetheless. Not efficient.
* <p>
* If the mouse is being dragged with the button down, then the dragged value should be set to true. This will reduce
* the intensity of the brush to 10% of what it should be per spray. Otherwise it goes to 100% opacity within a few pixels.
* This makes it work a little more realistically.
*
* @param colorFunction the color function.
* @param image to manipulate
* @param uv the world x,z coordinate
* @param radius in percentage so it can be translated to the image dimensions
* @param erase true if the tool should remove the paint instead of add it
* @param fadeFalloff the percentage of the radius when the paint begins to start fading
*/
private void doPaintAction(@NotNull final ObjectFloatObjectConsumer<ColorRGBA, Boolean> colorFunction,
@NotNull final Image image, @NotNull final Vector2f uv, @NotNull final Vector2f temp,
@NotNull final ColorRGBA color, final float radius, final boolean erase,
final float fadeFalloff) {
final ByteBuffer buffer = image.getData(0);
final int width = image.getWidth();
final float height = image.getHeight();
// convert percents to pixels to limit how much we iterate
final int minX = (int) Math.max(0, (uv.getX() * width - radius * width));
final int maxX = (int) Math.min(width, (uv.getX() * width + radius * width));
final int minY = (int) Math.max(0, (uv.getY() * height - radius * height));
final int maxY = (int) Math.min(height, (uv.getY() * height + radius * height));
final float radiusSquared = radius * radius;
// go through each pixel, in the radius of the tool, in the image
for (int y = minY; y < maxY; y++) {
for (int x = minX; x < maxX; x++) {
// gets the position in percentage so it can compare with the mouse UV coordinate
temp.set((float) x / width, (float) y / height);
float dist = temp.distanceSquared(uv);
// if the pixel is within the distance of the radius, set a color (distance times intensity)
if (dist < radiusSquared) {
final int position = (y * width + x) * 4;
if (position > buffer.capacity() - 1 || position < 0) {
continue;
}
// gets the color at that location (false means don't write to the buffer)
manipulatePixel(image, buffer, color, position, false);
// calculate the fade falloff intensity
final float intensity = (1.0f - (dist / radiusSquared)) * fadeFalloff;
colorFunction.accept(color, intensity, erase);
color.clamp();
change(position, color);
// set the new color
manipulatePixel(image, buffer, color, position, true);
}
}
}
image.getData(0).rewind();
}
示例6: updateControls
import com.jme3.math.ColorRGBA; //导入方法依赖的package包/类
private void updateControls() {
ColorRGBA clone = value.clone();
clone.clamp();
getButtonIcon().setDefaultColor(clone);
}