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


Java ReadableColor类代码示例

本文整理汇总了Java中org.lwjgl.util.ReadableColor的典型用法代码示例。如果您正苦于以下问题:Java ReadableColor类的具体用法?Java ReadableColor怎么用?Java ReadableColor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: convertColor

import org.lwjgl.util.ReadableColor; //导入依赖的package包/类
/**
 * Примечание: по умолчанию метод возвращает белый цвет.
 *
 * @param color Цвет из нашего кастомного enum
 * @return Color, с которым работает LWJGL
 */
private Color convertColor(TpReadableColor color) {
    switch (color){
        case RED:
            return new Color(ReadableColor.RED);
        case GREEN:
            return new Color(ReadableColor.GREEN);
        case BLUE:
            return new Color(ReadableColor.BLUE);
        case AQUA:
            return new Color(ReadableColor.CYAN);
        case YELLOW:
            return new Color(ReadableColor.YELLOW);
        case ORANGE:
            return new Color(ReadableColor.ORANGE);
        case PURPLE:
            return new Color(ReadableColor.PURPLE);
        case BLACK:
            return new Color(ReadableColor.BLACK);
        default:
            return new Color(ReadableColor.WHITE);
    }
}
 
开发者ID:DoKel,项目名称:tprogersTetris,代码行数:29,代码来源:LwjglGraphicsModule.java

示例2: draw

import org.lwjgl.util.ReadableColor; //导入依赖的package包/类
@Override
public void draw(GuiRenderer renderer, ReadableDimension size, RenderInfo renderInfo) {
    super.draw(renderer, size, renderInfo);

    int color = 0xe0e0e0;
    if (!isEnabled()) {
        color = 0xa0a0a0;
    }

    int boxSize = size.getHeight();
    renderer.drawRect(0, 0, boxSize, boxSize, ReadableColor.BLACK);
    renderer.drawRect(1, 1, boxSize - 2, boxSize - 2, BOX_BACKGROUND_COLOR);

    if(isChecked()) {
        renderer.drawCenteredString(boxSize / 2 + 1, 1, color, "x", true);
    }

    renderer.drawString(boxSize + 2, 2, color, label);
}
 
开发者ID:ReplayMod,项目名称:jGui,代码行数:20,代码来源:AbstractGuiCheckbox.java

示例3: draw

import org.lwjgl.util.ReadableColor; //导入依赖的package包/类
@Override
public void draw(GuiRenderer renderer, ReadableDimension size, RenderInfo renderInfo) {
    super.draw(renderer, size, renderInfo);

    FontRenderer fontRenderer = getMinecraft().fontRendererObj;
    int width = size.getWidth();
    int height = size.getHeight();
    int barTotalWidth = width - 2 * BORDER;
    int barDoneWidth = (int) (barTotalWidth * progress);

    renderer.drawRect(0, 0, width, height, ReadableColor.BLACK); // Border
    renderer.drawRect(BORDER, BORDER, barTotalWidth, height - 2 * BORDER, ReadableColor.WHITE); // Background
    renderer.drawRect(BORDER, BORDER, barDoneWidth, height - 2 * BORDER, ReadableColor.GREY); // Progress

    String text = String.format(label, (int)(progress * 100));
    renderer.drawCenteredString(width / 2, size.getHeight() / 2 - fontRenderer.FONT_HEIGHT / 2, ReadableColor.BLACK, text);
}
 
开发者ID:ReplayMod,项目名称:jGui,代码行数:18,代码来源:AbstractGuiProgressBar.java

示例4: initColorMap

import org.lwjgl.util.ReadableColor; //导入依赖的package包/类
private static void initColorMap(IntBuffer colorMap, int stepSize, ReadableColor... colors) {
	for ( int n = 0; n < colors.length - 1; n++ ) {
		ReadableColor color = colors[n];
		int r0 = color.getRed();
		int g0 = color.getGreen();
		int b0 = color.getBlue();

		color = colors[n + 1];
		int r1 = color.getRed();
		int g1 = color.getGreen();
		int b1 = color.getBlue();

		int deltaR = r1 - r0;
		int deltaG = g1 - g0;
		int deltaB = b1 - b0;

		for ( int step = 0; step < stepSize; step++ ) {
			float alpha = (float)step / (stepSize - 1);
			int r = (int)(r0 + alpha * deltaR);
			int g = (int)(g0 + alpha * deltaG);
			int b = (int)(b0 + alpha * deltaB);
			colorMap.put((r << 0) | (g << 8) | (b << 16));
		}
	}
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:26,代码来源:DemoFractal.java

示例5: drawShape

import org.lwjgl.util.ReadableColor; //导入依赖的package包/类
@Override
protected void drawShape() {
    GL11.glBegin(GL11.GL_LINE_LOOP);
    GL11.glVertex2f(-width, -height);
    GL11.glVertex2f(+width, -height);
    GL11.glVertex2f(+width, +height);
    GL11.glVertex2f(-width, +height);
    GL11.glEnd();
    final ReadableColor color = getColor();
    if (nonNull(color)) {
        GL11.glColor4f(color.getRed(), color.getGreen(), color.getBlue(), HALF);
    }
    GL11.glBegin(GL11.GL_POLYGON);
    GL11.glVertex2f(-width, -height);
    GL11.glVertex2f(+width, -height);
    GL11.glVertex2f(+width, +height);
    GL11.glVertex2f(-width, +height);
    GL11.glEnd();
}
 
开发者ID:kjkrol,项目名称:bam,代码行数:20,代码来源:Rectangle.java

示例6: create

import org.lwjgl.util.ReadableColor; //导入依赖的package包/类
public void create(final float breadth, final float borderWidth, final float borderHeight) {
    final FixtureDef fixtureDef = new FixtureDef();
    fixtureDef.density = BORDER_WALL_DENSITY;
    fixtureDef.friction = BORDER_WALL_FRICTION;
    fixtureDef.restitution = BORDER_WALL_RESTITUTION;

    bamScene.getBamSceneCreator().addShape(
            new CreateNewRectangleRequest(fixtureDef, ReadableColor.YELLOW, borderWidth, breadth),
            new Vec2(0, borderHeight),
            BodyType.STATIC);
    bamScene.getBamSceneCreator().addShape(
            new CreateNewRectangleRequest(fixtureDef, ReadableColor.YELLOW, borderWidth, breadth),
            new Vec2(0, 0),
            BodyType.STATIC);
    bamScene.getBamSceneCreator().addShape(
            new CreateNewRectangleRequest(fixtureDef, ReadableColor.YELLOW, breadth, borderHeight),
            new Vec2(0, 0),
            BodyType.STATIC);
    bamScene.getBamSceneCreator().addShape(
            new CreateNewRectangleRequest(fixtureDef, ReadableColor.YELLOW, breadth, borderHeight),
            new Vec2(borderWidth, 0),
            BodyType.STATIC);
}
 
开发者ID:kjkrol,项目名称:bam,代码行数:24,代码来源:BorderWall.java

示例7: setVerticalGradient

import org.lwjgl.util.ReadableColor; //导入依赖的package包/类
public void setVerticalGradient(ReadableColor col1, ReadableColor col2) {
  ReadableColor[] cols = new ReadableColor[9];
  
  cols[0] = col1;
  cols[1] = col1;
  cols[2] = col1;
  
  cols[6] = col2;
  cols[7] = col2;
  cols[8] = col2;
  
  Color inter = ColorInterpolator.interpolate(col1, col2, .5f);
  cols[3] = inter;
  cols[4] = inter;
  cols[5] = inter;
  
  setColors(cols);
}
 
开发者ID:Arcbe,项目名称:GPVM,代码行数:19,代码来源:ColoredDrawable.java

示例8: setCentralGradient

import org.lwjgl.util.ReadableColor; //导入依赖的package包/类
public void setCentralGradient(ReadableColor col1, ReadableColor col2) {
  ReadableColor[] cols = new ReadableColor[9];
  
  cols[4] = col1;
  
  cols[0] = col2;
  cols[2] = col2;
  cols[6] = col2;
  cols[8] = col2;
  
  // ~1/sqrt(2), the factor to adjust the colors by to produce a circular pattern.
  Color temp = ColorInterpolator.interpolate(col1, col2, .707107f);
  
  cols[1] = temp;
  cols[3] = temp;
  cols[5] = temp;
  cols[7] = temp;
  
  setColors(cols);
}
 
开发者ID:Arcbe,项目名称:GPVM,代码行数:21,代码来源:ColoredDrawable.java

示例9: setHorizontalGradient

import org.lwjgl.util.ReadableColor; //导入依赖的package包/类
public void setHorizontalGradient(ReadableColor col1, ReadableColor col2) {
  ReadableColor[] cols = new ReadableColor[9];
  
  cols[0] = col1;
  cols[3] = col1;
  cols[6] = col1;
  
  cols[1] = col2;
  cols[4] = col2;
  cols[7] = col2;
  
  Color inter = ColorInterpolator.interpolate(col1, col2, .5f);
  cols[2] = inter;
  cols[5] = inter;
  cols[8] = inter;
  
  setColors(cols);
}
 
开发者ID:Arcbe,项目名称:GPVM,代码行数:19,代码来源:ColoredDrawable.java

示例10: interpolate

import org.lwjgl.util.ReadableColor; //导入依赖的package包/类
/**
 * Interpolates between the given {@link Color}s according to the given
 * amount.  The amount should be between 0 and 1, all other numbers are produce
 * undefined results.
 * 
 * @param col1 The first {@link Color} in the interpolation.
 * @param col2 The second {@link Color} in the interpolation.
 * @param amt The amount to interpolate.
 * @param out The {@link Color} to store the output in.
 * @return The interpolated {@link Color}.
 */
public static Color interpolate(ReadableColor col1, ReadableColor col2, float amt, Color out) {
  int num = (int) (col1.getAlpha() * (1 - amt) + col2.getAlpha() * amt);
  out.setAlpha(num);
  
  num = (int) (col1.getRed()* (1 - amt) + col2.getRed() * amt);
  out.setRed(num);
  
  num = (int) (col1.getGreen()* (1 - amt) + col2.getGreen() * amt);
  out.setGreen(num);
  
  num = (int) (col1.getBlue()* (1 - amt) + col2.getBlue() * amt);
  out.setBlue(num);
  
  return out;
}
 
开发者ID:Arcbe,项目名称:GPVM,代码行数:27,代码来源:ColorInterpolator.java

示例11: setValue

import org.lwjgl.util.ReadableColor; //导入依赖的package包/类
@Override
public void setValue(double value, ReadableColor color)
{
	if (color == null)
	{
		if (value < 50)
			if (value < 25)
				color = ReadableColor.RED;
			else
				color = ReadableColor.YELLOW;
		else
			color = ReadableColor.GREEN;
	}
	 
	super.setValue(value, color);
}
 
开发者ID:TheWhiteShadow3,项目名称:cuina,代码行数:17,代码来源:HealthBar.java

示例12: createCheckerTexture

import org.lwjgl.util.ReadableColor; //导入依赖的package包/类
private void createCheckerTexture(final ReadableColor a, final ReadableColor b, final int size) {
	int i = 0;
	for ( int y = 0; y < HEIGHT; y++ ) {
		for ( int x = 0; x < WIDTH; x++ ) {
			ReadableColor c = (x / size) % 2 == 0 ? ((y / size) % 2 == 0 ? a : b) : ((y / size) % 2 == 0 ? b : a);
			texture.put(i + 0, c.getRedByte());
			texture.put(i + 1, c.getGreenByte());
			texture.put(i + 2, c.getBlueByte());
			i += 3;
		}
	}
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:13,代码来源:BackgroundLoader.java

示例13: createGradientTexture

import org.lwjgl.util.ReadableColor; //导入依赖的package包/类
private void createGradientTexture(final ReadableColor a, final ReadableColor b) {
	float l = 0.0f;
	int i = 0;
	for ( int y = 0; y < HEIGHT; y++ ) {
		for ( int x = 0; x < WIDTH; x++ ) {
			texture.put(i + 0, lerp(a.getRed(), b.getRed(), l));
			texture.put(i + 1, lerp(a.getGreen(), b.getGreen(), l));
			texture.put(i + 2, lerp(a.getBlue(), b.getBlue(), l));
			i += 3;
		}
		l += (1.0f / (HEIGHT - 1));
	}
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:14,代码来源:BackgroundLoader.java

示例14: draw

import org.lwjgl.util.ReadableColor; //导入依赖的package包/类
public void draw() {
    GL11.glLoadIdentity();
    GL11.glTranslatef(getXPos(), getYPos(), 0);
    final float angle = body.getAngle() * ANGLE_TO_RAD_COEFFICIENT;
    GL11.glRotatef(angle, 0, 0, 1);
    ReadableColor color1 = nonNull(color) ? color : ReadableColor.WHITE;
    GL11.glColor3f(color1.getRed(), color1.getGreen(), color1.getBlue());
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    this.drawShape();
}
 
开发者ID:kjkrol,项目名称:bam,代码行数:11,代码来源:BaseShape.java

示例15: Circle

import org.lwjgl.util.ReadableColor; //导入依赖的package包/类
public Circle(Body body, FixtureDef fixtureDef, ReadableColor color, float radius) {
    super(body, fixtureDef, color);
    this.radius = radius;
    int initEdges = (int) (radius / FACTOR_FOUR);
    this.numberOfEdges = initEdges < MINIMUM_EDGES_NUMBER ? MINIMUM_EDGES_NUMBER : initEdges;
    this.x = new float[numberOfEdges];
    this.y = new float[numberOfEdges];
    this.tx = new float[numberOfEdges];
    this.ty = new float[numberOfEdges];
    this.init();
}
 
开发者ID:kjkrol,项目名称:bam,代码行数:12,代码来源:Circle.java


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