【问题标题】:How to render a Libgdx Bitmapfont so that it's pixels color is the inverse of the background?如何渲染 Libgdx Bitmapfont 使其像素颜色与背景相反?
【发布时间】:2011-12-28 17:11:07
【问题描述】:

都没有

sb.setBlendFunction(GL10.GL_ONE_MINUS_DST_COLOR, GL10.GL_ZERO);
sb.begin();
font.setColor(1, 1, 1, 1);
for (LineRect s: vertices){
     font.draw(sb,""+ s.x+","+.y, s.x, s.y);
}
sb.end();
sb.setBlendFunction(GL10.GL_ONE, GL10.GL_ONE_MINUS_SRC_ALPHA);

也没有

Gdx.gl10.glEnable(GL10.GL_COLOR_LOGIC_OP);
Gdx.gl10.glLogicOp(GL10.GL_XOR);

    sb.begin();
    font.setColor(1, 1, 1, 1);
    for (LineRect s: vertices){
         font.draw(sb,""+ s.x+","+.y, s.x, s.y);
    }
    sb.end();


Gdx.gl10.glDisable(GL10.GL_COLOR_LOGIC_OP);

为我工作,我做错了什么? 我该如何解决?

这个想法是绘制字体,它由具有部分透明纹理的四边形组成,以某种方式始终可见,除非背景为 50% 灰色。 背景黑色 = 字体呈现白色,以此类推。

【问题讨论】:

    标签: java android opengl-es libgdx


    【解决方案1】:

    您需要测试背景颜色的亮度。这是我为AWT颜色做的一个方法,应该很容易适应libgdx颜色类:

    /**
     * Returns the brightness of the color, between 0 and 255.
     */
    public static int getBrightness(Color c) {
        if (c == null) return -1;
        return (int) Math.sqrt(
            c.getRed() * c.getRed() * .241 +
            c.getGreen() * c.getGreen() * .691 +
            c.getBlue() * c.getBlue() * .068);
    }
    

    如果亮度

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-05-28
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多