SpecialGlyphs.java
net.minecraft.client.gui.font.glyphs.SpecialGlyphs
信息
- 全限定名:net.minecraft.client.gui.font.glyphs.SpecialGlyphs
- 类型:public enum
- 包:net.minecraft.client.gui.font.glyphs
- 源码路径:src/main/java/net/minecraft/client/gui/font/glyphs/SpecialGlyphs.java
- 起始行号:L16
- 实现:GlyphInfo
- 职责:
TODO
字段/常量
-
y, edge- 类型:
WHITE(() -> generate(,,(x, - 修饰符:
package-private - 源码定位:
L17 - 说明:
TODO
- 类型:
-
image- 类型:
NativeImage - 修饰符:
private final - 源码定位:
L27 - 说明:
TODO
- 类型:
内部类/嵌套类型
net.minecraft.client.gui.font.glyphs.SpecialGlyphs.PixelProvider- 类型:
interface - 修饰符:
private - 源码定位:
L93 - 说明:
TODO
- 类型:
构造器
private SpecialGlyphs(Supplier<NativeImage> image) @ L42
- 构造器名:SpecialGlyphs
- 源码定位:L42
- 修饰符:private
参数:
- image: Supplier
说明:
TODO
方法
下面的方法块按源码顺序生成。
private static NativeImage generate(int width, int height, SpecialGlyphs.PixelProvider pixelProvider) @ L29
- 方法名:generate
- 源码定位:L29
- 返回类型:NativeImage
- 修饰符:private static
参数:
- width: int
- height: int
- pixelProvider: SpecialGlyphs.PixelProvider
说明:
TODO
public float getAdvance() @ L46
- 方法名:getAdvance
- 源码定位:L46
- 返回类型:float
- 修饰符:public
参数:
- 无
说明:
TODO
public BakedSheetGlyph bake(GlyphStitcher stitcher) @ L51
- 方法名:bake
- 源码定位:L51
- 返回类型:BakedSheetGlyph
- 修饰符:public
参数:
- stitcher: GlyphStitcher
说明:
TODO
代码
@OnlyIn(Dist.CLIENT)
public enum SpecialGlyphs implements GlyphInfo {
WHITE(() -> generate(5, 8, (x, y) -> -1)),
MISSING(() -> {
int width = 5;
int height = 8;
return generate(5, 8, (x, y) -> {
boolean edge = x == 0 || x + 1 == 5 || y == 0 || y + 1 == 8;
return edge ? -1 : 0;
});
});
private final NativeImage image;
private static NativeImage generate(int width, int height, SpecialGlyphs.PixelProvider pixelProvider) {
NativeImage result = new NativeImage(NativeImage.Format.RGBA, width, height, false);
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
result.setPixel(x, y, pixelProvider.getColor(x, y));
}
}
result.untrack();
return result;
}
private SpecialGlyphs(Supplier<NativeImage> image) {
this.image = image.get();
}
@Override
public float getAdvance() {
return this.image.getWidth() + 1;
}
public @Nullable BakedSheetGlyph bake(GlyphStitcher stitcher) {
return stitcher.stitch(
this,
new GlyphBitmap() {
{
Objects.requireNonNull(SpecialGlyphs.this);
}
@Override
public int getPixelWidth() {
return SpecialGlyphs.this.image.getWidth();
}
@Override
public int getPixelHeight() {
return SpecialGlyphs.this.image.getHeight();
}
@Override
public float getOversample() {
return 1.0F;
}
@Override
public void upload(int x, int y, GpuTexture texture) {
RenderSystem.getDevice()
.createCommandEncoder()
.writeToTexture(
texture, SpecialGlyphs.this.image, 0, 0, x, y, SpecialGlyphs.this.image.getWidth(), SpecialGlyphs.this.image.getHeight(), 0, 0
);
}
@Override
public boolean isColored() {
return true;
}
}
);
}
@FunctionalInterface
@OnlyIn(Dist.CLIENT)
private interface PixelProvider {
int getColor(int x, int y);
}
}引用的其他类
-
- 引用位置:
构造调用 - 关联成员:
GlyphBitmap()
- 引用位置:
-
- 引用位置:
实现
- 引用位置:
-
- 引用位置:
参数/字段/构造调用/返回值 - 关联成员:
NativeImage()
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
RenderSystem.getDevice()
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
返回值
- 引用位置: