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


Java Color.set方法代码示例

本文整理汇总了Java中com.badlogic.gdx.graphics.Color.set方法的典型用法代码示例。如果您正苦于以下问题:Java Color.set方法的具体用法?Java Color.set怎么用?Java Color.set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.badlogic.gdx.graphics.Color的用法示例。


在下文中一共展示了Color.set方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: fillFormWithConstantColor

import com.badlogic.gdx.graphics.Color; //导入方法依赖的package包/类
public static Pixmap fillFormWithConstantColor(Pixmap pixmap, Color fillColor) {
    // set fill color
    pixmap.setColor(fillColor);

    Color color = new Color();

    for (int x = 0; x < pixmap.getWidth(); x++) {
        for (int y = 0; y < pixmap.getHeight(); y++) {
            int colorInt = pixmap.getPixel(x, y);
            color.set(colorInt);

            // get color alpha value
            float alpha = color.a;

            if (alpha > 0) {
                pixmap.setColor(fillColor);
                pixmap.fillRectangle(x, y, 1, 1);
            } else {
                pixmap.setColor(new Color(0, 0, 0, 0));
                pixmap.fillRectangle(x, y, 1, 1);
            }
        }
    }

    return pixmap;
}
 
开发者ID:opensourcegamedev,项目名称:SpaceChaos,代码行数:27,代码来源:PixmapUtils.java

示例2: gaussianPixmap

import com.badlogic.gdx.graphics.Color; //导入方法依赖的package包/类
private static void gaussianPixmap(Pixmap in, Pixmap out, double[][] gwm, int gaussianRadius) {
	Color inColor = new Color();
	Color outColor = new Color();

	int offsetX = (in.getWidth() - out.getWidth()) / 2;
	int offsetY = (in.getHeight() - out.getHeight()) / 2;

	int width = out.getWidth();
	int height = out.height();
	for (int x = 0; x < width; x++, width = out.getWidth()) {
		for (int y = 0; y < height; y++, height = out.height()) {
			outColor.set(0, 0, 0, 0);

			for (int ox = -gaussianRadius; ox <= gaussianRadius; ox++) {
				for (int oy = -gaussianRadius; oy <= gaussianRadius; oy++) {
					int pixel = in.getPixel(x + ox + offsetX, y + oy + offsetY);
					inColor.set(pixel);
					double d = gwm[ox + gaussianRadius][oy + gaussianRadius];
					outColor.r += inColor.r * d;
					outColor.g += inColor.g * d;
					outColor.b += inColor.b * d;
					outColor.a += inColor.a * d;
				}
			}

			out.drawPixel(x, y, Color.rgba8888(outColor.clamp()));
		}
	}
}
 
开发者ID:RedTroop,项目名称:Cubes_2,代码行数:30,代码来源:AOTextureGenerator.java

示例3: gaussianPixmap

import com.badlogic.gdx.graphics.Color; //导入方法依赖的package包/类
private static void gaussianPixmap(Pixmap in, Pixmap out, double[][] gwm, int gaussianRadius) {
  Color inColor = new Color();
  Color outColor = new Color();

  int offsetX = (in.getWidth() - out.getWidth()) / 2;
  int offsetY = (in.getHeight() - out.getHeight()) / 2;

  for (int x = 0; x < out.getWidth(); x++) {
    for (int y = 0; y < out.getHeight(); y++) {
      outColor.set(0, 0, 0, 0);

      for (int ox = -gaussianRadius; ox <= gaussianRadius; ox++) {
        for (int oy = -gaussianRadius; oy <= gaussianRadius; oy++) {
          int pixel = in.getPixel(x + ox + offsetX, y + oy + offsetY);
          inColor.set(pixel);
          double d = gwm[ox + gaussianRadius][oy + gaussianRadius];
          outColor.r += inColor.r * d;
          outColor.g += inColor.g * d;
          outColor.b += inColor.b * d;
          outColor.a += inColor.a * d;
        }
      }

      out.drawPixel(x, y, Color.rgba8888(outColor.clamp()));
    }
  }
}
 
开发者ID:RedTroop,项目名称:Cubes,代码行数:28,代码来源:AOTextureGenerator.java


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