当前位置: 首页>>代码示例>>Java>>正文


Java ColorRGBA.clamp方法代码示例

本文整理汇总了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++;
	}
}
 
开发者ID:rockfireredmoon,项目名称:icetone,代码行数:10,代码来源:ColorPaletteTab.java

示例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);
	}

}
 
开发者ID:rockfireredmoon,项目名称:icetone,代码行数:16,代码来源:ColorPaletteTab.java

示例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();
}
 
开发者ID:jMonkeyEngine,项目名称:sdk,代码行数:40,代码来源:TerrainEditorController.java

示例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();
}
 
开发者ID:huliqing,项目名称:LuoYing,代码行数:32,代码来源:TerrainUtils.java

示例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();
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:74,代码来源:PaintTerrainToolControl.java

示例6: updateControls

import com.jme3.math.ColorRGBA; //导入方法依赖的package包/类
private void updateControls() {
	ColorRGBA clone = value.clone();
	clone.clamp();
	getButtonIcon().setDefaultColor(clone);
}
 
开发者ID:rockfireredmoon,项目名称:icetone,代码行数:6,代码来源:ColorButton.java


注:本文中的com.jme3.math.ColorRGBA.clamp方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。