Java Code Examples for org.newdawn.slick.Graphics#setAntiAlias()
The following examples show how to use
org.newdawn.slick.Graphics#setAntiAlias() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GradientTest.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * @see org.newdawn.slick.BasicGame#render(org.newdawn.slick.GameContainer, org.newdawn.slick.Graphics) */ public void render(GameContainer container, Graphics g) { g.rotate(400, 300, ang); g.fill(rect, gradient); g.fill(round, gradient); g.fill(poly, gradient2); g.fill(center, gradient4); g.setAntiAlias(true); g.setLineWidth(10); g.draw(round2, gradient2); g.setLineWidth(2); g.draw(poly, gradient); g.setAntiAlias(false); g.fill(center, gradient4); g.setAntiAlias(true); g.setColor(Color.black); g.draw(center); g.setAntiAlias(false); }
Example 2
Source File: ShapeTest.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * @see org.newdawn.slick.BasicGame#render(org.newdawn.slick.GameContainer, org.newdawn.slick.Graphics) */ public void render(GameContainer container, Graphics g) { g.setColor(Color.green); for(int i=0;i<shapes.size();i++) { g.fill((Shape)shapes.get(i)); } g.fill(randomShape); g.setColor(Color.black); g.setAntiAlias(true); g.draw(randomShape); g.setAntiAlias(false); g.setColor(Color.white); g.drawString("keys", 10, 300); g.drawString("wasd - move rectangle", 10, 315); g.drawString("WASD - resize rectangle", 10, 330); g.drawString("tgfh - move rounded rectangle", 10, 345); g.drawString("TGFH - resize rounded rectangle", 10, 360); g.drawString("ry - resize corner radius on rounded rectangle", 10, 375); g.drawString("ikjl - move ellipse", 10, 390); g.drawString("IKJL - resize ellipse", 10, 405); g.drawString("Arrows - move circle", 10, 420); g.drawString("Page Up/Page Down - resize circle", 10, 435); g.drawString("numpad 8546 - move polygon", 10, 450); }
Example 3
Source File: LineRenderTest.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * @see org.newdawn.slick.Game#render(org.newdawn.slick.GameContainer, org.newdawn.slick.Graphics) */ public void render(GameContainer container, Graphics g) throws SlickException { g.setAntiAlias(antialias); g.setLineWidth(50); g.setColor(Color.red); g.draw(path); // g.setColor(Color.red); // TextureImpl.bindNone(); // g.setLineWidth(width); // g.setAntiAlias(true); // for (int i=0;i<10;i++) { // g.translate(35,35); // g.draw(polygon); // } // g.translate(-350,-350); // // g.setColor(Color.white); // g.setLineWidth(1); // g.setAntiAlias(false); // g.draw(polygon); }
Example 4
Source File: AntiAliasTest.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * @see org.newdawn.slick.Game#render(org.newdawn.slick.GameContainer, org.newdawn.slick.Graphics) */ public void render(GameContainer container, Graphics g) throws SlickException { g.setAntiAlias(true); g.setColor(Color.red); g.drawOval(100,100,100,100); g.fillOval(300,100,100,100); g.setAntiAlias(false); g.setColor(Color.red); g.drawOval(100,300,100,100); g.fillOval(300,300,100,100); }
Example 5
Source File: UserButton.java From opsu with GNU General Public License v3.0 | 4 votes |
/** * Draws a user button. * @param g the graphics context * @param alpha the alpha multiplier */ public void draw(Graphics g, float alpha) { int padding = 4; int cx = x + padding, cy = y + padding; float t = bgAlpha.getValue(); float oldWhiteAlpha = Colors.WHITE_FADE.a; Colors.WHITE_FADE.a = alpha; // rectangle Color bg; if (flashing) { bg = flashColor; bg.a = t * alpha; } else { bg = bgColor; bg.a = (0.5f * t) * alpha; } g.setColor(bg); g.fillRoundRect(cx, cy, buttonWidth - padding * 2, buttonHeight - padding * 2, 4); // no user? if (user == null && placeholderText != null) { Fonts.LARGE.drawString( x + (buttonWidth - Fonts.LARGE.getWidth(placeholderText)) / 2, y + (buttonHeight - Fonts.LARGE.getLineHeight()) / 2, placeholderText, Colors.WHITE_FADE ); Colors.WHITE_FADE.a = oldWhiteAlpha; return; } // icon int iconSize = buttonHeight - padding * 4; Image img = getIconImage(user.getIconId()); img.setAlpha(alpha); img.draw(cx + padding, cy + padding); // text int textX = cx + iconSize + padding * 3; int textY = cy + padding / 2; Fonts.MEDIUM.drawString(textX, textY, user.getName(), Colors.WHITE_FADE); textY += Fonts.MEDIUM.getLineHeight() - 3; Fonts.SMALL.drawString(textX, textY, String.format("Score: %,d", user.getScore()), Colors.WHITE_FADE); textY += Fonts.SMALL.getLineHeight() - 2; Fonts.SMALL.drawString(textX, textY, String.format("Accuracy: %.2f%%", user.getAccuracy()), Colors.WHITE_FADE); textY += Fonts.SMALL.getLineHeight() - 2; Fonts.SMALL.drawString(textX, textY, String.format("Lv%d", user.getLevel()), Colors.WHITE_FADE); // progress bar int barX = textX + Fonts.SMALL.getWidth("Lv#####"); int barWidth = x + buttonWidth - padding - barX - 1; int barHeight = buttonHeight / 7; int barY = y + buttonHeight - padding - barHeight - 1; int barRadius = 8; float barAlpha = (0.75f + 0.25f * t) * alpha; barBgColor.a = barBorderColor.a = barFillColor.a = barAlpha; g.setColor(barBgColor); g.fillRoundRect(barX, barY, barWidth, barHeight, barRadius); g.setClip(barX, barY, (int) (barWidth * user.getNextLevelProgress()), barHeight); g.setColor(barFillColor); g.fillRoundRect(barX, barY, barWidth, barHeight, barRadius); g.clearClip(); g.setAntiAlias(true); g.setColor(barBorderColor); g.setLineWidth(2f); g.drawRoundRect(barX, barY, barWidth, barHeight, barRadius); g.resetLineWidth(); g.setAntiAlias(false); Colors.WHITE_FADE.a = oldWhiteAlpha; }
Example 6
Source File: GraphicsTest.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 4 votes |
/** * @see org.newdawn.slick.BasicGame#render(org.newdawn.slick.GameContainer, org.newdawn.slick.Graphics) */ public void render(GameContainer container, Graphics g) throws SlickException { g.setColor(Color.white); g.setAntiAlias(true); for (int x=0;x<360;x+=10) { g.drawLine(700,100,(int) (700+(Math.cos(Math.toRadians(x))*100)), (int) (100+(Math.sin(Math.toRadians(x))*100))); } g.setAntiAlias(false); g.setColor(Color.yellow); g.drawString("The Graphics Test!", 300, 50); g.setColor(Color.white); g.drawString("Space - Toggles clipping", 400, 80); g.drawString("Frame rate capped to 100", 400, 120); if (clip) { g.setColor(Color.gray); g.drawRect(100,260,400,100); g.setClip(100,260,400,100); } g.setColor(Color.yellow); g.translate(100, 120); g.fill(poly); g.setColor(Color.blue); g.setLineWidth(3); g.draw(poly); g.setLineWidth(1); g.translate(0, 230); g.draw(poly); g.resetTransform(); g.setColor(Color.magenta); g.drawRoundRect(10, 10, 100, 100, 10); g.fillRoundRect(10, 210, 100, 100, 10); g.rotate(400, 300, ang); g.setColor(Color.green); g.drawRect(200,200,200,200); g.setColor(Color.blue); g.fillRect(250,250,100,100); g.drawImage(image, 300,270); g.setColor(Color.red); g.drawOval(100,100,200,200); g.setColor(Color.red.darker()); g.fillOval(300,300,150,100); g.setAntiAlias(true); g.setColor(Color.white); g.setLineWidth(5.0f); g.drawOval(300,300,150,100); g.setAntiAlias(true); g.resetTransform(); if (clip) { g.clearClip(); } }