public static int getRGB(float r, float g, float b) { return getRGB((int) (r * 255), (int) (g * 255), (int) (b * 255)); }
public static int getARGB(float r, float g, float b, float a) { return getARGB((int) (a * 255), (int) (r * 255), (int) (g * 255), (int) (b * 255)); }
@Override protected void addConduitQuads(@Nonnull IConduitBundle bundle, @Nonnull IClientConduit conduit, @Nonnull IConduitTexture tex, @Nonnull CollidableComponent component, float selfIllum, BlockRenderLayer layer, @Nonnull List<BakedQuad> quads) { if (IOCConduit.COLOR_CONTROLLER_ID.equals(component.data)) { if (conduit.containsExternalConnection(component.getDirection())) { int c = ((IOCConduit) conduit).getSignalColor(component.getDirection()).getColor(); BakedQuadBuilder.addBakedQuads(quads, component.bound, White.INSTANCE, ColorUtil.toFloat4(c)); } } else { super.addConduitQuads(bundle, conduit, tex, component, selfIllum, layer, quads); } }
@Override public void drawGuiContainerBackgroundLayer(float f, int mx, int my) { GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); bindGuiTexture(); int sx = (width - xSize) / 2; int sy = (height - ySize) / 2; drawTexturedModalRect(sx, sy, 0, 0, this.xSize, this.ySize); int sw = getFontRenderer().getStringWidth(title); getFontRenderer().drawString(title, width / 2 - sw / 2, sy + 12, ColorUtil.getRGB(Color.red)); ContainerTravelAuth poo = (ContainerTravelAuth) inventorySlots; if (poo.dirty) { poo.dirty = false; failed = false; } if (failed) { drawRect(sx + 43, sy + 27, sx + 43 + 90, sy + 27 + 18, ColorUtil.getARGB(new Color(1f, 0f, 0f, 0.5f))); } super.drawGuiContainerBackgroundLayer(f, mx, my); }
public static int getRGBA(float r, float g, float b, float a) { return getRGBA((int) (r * 255), (int) (g * 255), (int) (b * 255), (int) (a * 255)); }
protected void drawContainerBackground(@Nonnull BufferBuilder renderer) { Vector3f col = ColorUtil.toFloat(2105376); GlStateManager.color(col.x, col.y, col.z, 1.0F); GlStateManager.disableTexture2D(); renderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION); renderer.pos(minX, maxY + margin + 10, 0.0D).endVertex(); renderer.pos(maxX, maxY + margin + 10, 0.0D).endVertex(); renderer.pos(maxX, minY, 0.0D).endVertex(); renderer.pos(minX, minY, 0.0D).endVertex(); Tessellator.getInstance().draw(); GlStateManager.enableTexture2D(); }
public static int getRGBA(@Nonnull Vector4f col) { return getRGBA(col.x, col.y, col.z, col.w); }
public static void renderQuad2D(double x, double y, double z, double width, double height, int colorRGB) { GlStateManager.disableTexture2D(); Vector3f col = ColorUtil.toFloat(colorRGB); GlStateManager.color(col.x, col.y, col.z); Tessellator tessellator = Tessellator.getInstance(); BufferBuilder tes = tessellator.getBuffer(); tes.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION); tes.pos(x, y + height, z).endVertex(); tes.pos(x + width, y + height, z).endVertex(); tes.pos(x + width, y, z).endVertex(); tes.pos(x, y, z).endVertex(); tessellator.draw(); GlStateManager.enableTexture2D(); }
public static int getRGB(@Nonnull Vector3f rgb) { return getRGB(rgb.x, rgb.y, rgb.z); }
private static void addColorBand(@Nonnull IClientConduit conduit, @Nonnull CollidableComponent component, @Nonnull List<BakedQuad> quads, @Nonnull EnumFacing dir, @Nonnull ConnectionMode mode) { if (IPowerConduit.COLOR_CONTROLLER_ID.equals(component.data) && (conduit instanceof IExtractor)) { IExtractor pc = (IExtractor) conduit; final RedstoneControlMode extractionRedstoneMode = pc.getExtractionRedstoneMode(dir); if (extractionRedstoneMode != RedstoneControlMode.IGNORE && extractionRedstoneMode != RedstoneControlMode.NEVER && mode.acceptsInput()) { int cInt = pc.getExtractionSignalColor(dir).getColor(); BoundingBox bound = component.bound; if (mode != ConnectionMode.NOT_SET) { Vector3d trans = ForgeDirectionOffsets.offsetScaled(dir, -0.12); bound = trans != null ? bound.translate(trans) : bound; } for (EnumFacing face : EnumFacing.VALUES) { if (face != null && face != dir) { BakedQuadBuilder.addBakedQuadForFace(quads, bound, White.INSTANCE, face, ConduitTexture.FULL, false, false, ColorUtil.toFloat4(cInt)); } } } } }
@Override protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) { GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); bindGuiTexture(); int sx = (width - xSize) / 2; int sy = (height - ySize) / 2; GlStateManager.enableAlpha(); drawTexturedModalRect(sx, sy, 0, 0, this.xSize, this.ySize); bindGuiTexture(); super.drawGuiContainerBackgroundLayer(par1, par2, par3); FontRenderer fr = Minecraft.getMinecraft().fontRenderer; GlStateManager.disableDepth(); GlStateManager.enableBlend(); fr.drawString("SW", sx + 55, sy + 48, ColorUtil.getARGB(1f, 1f, 0.35f, 1f), true); fr.drawString("NW", sx + 55, sy + 66, ColorUtil.getARGB(1f, 1f, 0.35f, 1f), true); fr.drawString("SE", sx + 73, sy + 48, ColorUtil.getARGB(1f, 1f, 0.35f, 1f), true); fr.drawString("NE", sx + 73, sy + 66, ColorUtil.getARGB(1f, 1f, 0.35f, 1f), true); GlStateManager.disableBlend(); GlStateManager.enableDepth(); }
public static int getRGBA(@Nullable Color color) { return color == null ? 0 : getRGBA(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha()); }
@Override public void drawButton(@Nonnull Minecraft mc, int mouseX, int mouseY, float partialTicks) { super.drawButton(mc, mouseX, mouseY, partialTicks); if (visible) { BufferBuilder tes = Tessellator.getInstance().getBuffer(); tes.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR); int xAdj = this.x + 2; int yAdj = this.y + 2; GlStateManager.disableTexture2D(); int col = ItemDye.DYE_COLORS[colorIndex]; Vector3f c = ColorUtil.toFloat(col); GlStateManager.color(c.x, c.y, c.z); tes.pos(xAdj, yAdj + height - 4, zLevel).color(c.x, c.y, c.z, 1).endVertex(); tes.pos(xAdj + width - 4, yAdj + height - 4, zLevel).color(c.x, c.y, c.z, 1).endVertex(); tes.pos(xAdj + width - 4, yAdj + 0, zLevel).color(c.x, c.y, c.z, 1).endVertex(); tes.pos(xAdj, yAdj + 0, zLevel).color(c.x, c.y, c.z, 1).endVertex(); Tessellator.getInstance().draw(); GlStateManager.enableTexture2D(); } } }
public static int getRGB(@Nullable Color color) { // Note: Constants in java.awt.Color are not @Nonnull-annotated return color == null ? 0 : getRGB(color.getRed(), color.getGreen(), color.getBlue()); }
if (mode.acceptsOutput()) { geometry.addModeConnectorQuads(dir, offset, ICON_INOUT_IN.get(TextureAtlasSprite.class), ColorUtil.toFloat4(inChannel.getColor()), quads); geometry.addModeConnectorQuads(dir, offset, ICON_INOUT_OUT.get(TextureAtlasSprite.class), ColorUtil.toFloat4(outChannel.getColor()), quads); } else { geometry.addModeConnectorQuads(dir, offset, ICON_IN.get(TextureAtlasSprite.class), ColorUtil.toFloat4(inChannel.getColor()), quads); geometry.addModeConnectorQuads(dir, offset, ICON_OUT.get(TextureAtlasSprite.class), ColorUtil.toFloat4(outChannel.getColor()), quads);
drawString(fontRenderer, blockName, scale * (p.x + BUTTON_WIDTH / 2 - textWidth / 2), scale * p.y, ColorUtil.getARGB(Color.gray)); GL11.glPopMatrix(); int y = height / 2 - BUTTON_HEIGHT * 3 - 5; drawString(fontRenderer, txt, x, y, ColorUtil.getARGB(Color.white)); x = width / 2 - (fontRenderer.getStringWidth(txt) / 2); y = height / 2 + BUTTON_HEIGHT * 3 - 5; drawString(fontRenderer, txt, x, y, ColorUtil.getARGB(Color.white));
public static int getARGB(@Nullable Color color) { return color == null ? 0 : getRGBA(color.getAlpha(), color.getRed(), color.getGreen(), color.getBlue()); }
@Override protected void renderCustomOptions(int topIn, float par1, int par2, int par3) { gui.getFontRenderer().drawString(signalColorStr, left + 31, topIn + 6, ColorUtil.getRGB(Color.darkGray)); gui.getFontRenderer().drawString(signalColorStr, left + 121, topIn + 6, ColorUtil.getRGB(Color.darkGray)); gui.getFontRenderer().drawString(signalStrengthStr, left + 121, topIn + 26, ColorUtil.getRGB(Color.darkGray)); }
final int drawHeight = this.slotHeight - margin; final Vector4f col = ColorUtil.toFloat4(8421504); final Vector4f colBlack = ColorUtil.toFloat4(0); final Vector4f colBorder = ColorUtil.toFloat4(0xFF000000); renderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR); renderer.pos(this.minX, this.minY + margin, 0.0D).color(colBlack.x, colBlack.y, colBlack.z, colBlack.w).tex(0.0D, 1.0D).endVertex();
public static void drawBillboardedText(@Nonnull Vector3f pos, @Nonnull String text, float size, @Nonnull Vector4f txtCol, boolean drawShadow, @Nullable Vector4f shadowCol, boolean drawBackground, @Nullable Vector4f bgCol) { GlStateManager.pushMatrix(); GlStateManager.translate(pos.x, pos.y, pos.z); GlStateManager.rotate(180, 1, 0, 0); Minecraft mc = Minecraft.getMinecraft(); FontRenderer fnt = mc.fontRenderer; float scale = size / fnt.FONT_HEIGHT; GlStateManager.scale(scale, scale, scale); GlStateManager.rotate(mc.getRenderManager().playerViewY + 180, 0.0F, 1.0F, 0.0F); GlStateManager.rotate(-mc.getRenderManager().playerViewX, 1.0F, 0.0F, 0.0F); GlStateManager.translate(-fnt.getStringWidth(text) / 2, 0, 0); if (drawBackground && bgCol != null) { renderBackground(fnt, text, bgCol); } fnt.drawString(text, 0, 0, ColorUtil.getRGBA(txtCol)); if (drawShadow && shadowCol != null) { GlStateManager.translate(0.5f, 0.5f, 0.1f); fnt.drawString(text, 0, 0, ColorUtil.getRGBA(shadowCol)); } GlStateManager.enableAlpha(); GlStateManager.popMatrix(); RenderUtil.bindBlockTexture(); }