Java Code Examples for org.newdawn.slick.Graphics#draw()

The following examples show how to use org.newdawn.slick.Graphics#draw() . 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 vote down vote up
/**
 * @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 vote down vote up
/**
 * @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: CurveTest.java    From slick2d-maven with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * @see org.newdawn.slick.Game#render(org.newdawn.slick.GameContainer, org.newdawn.slick.Graphics)
 */
public void render(GameContainer container, Graphics g) throws SlickException {
	g.setColor(Color.gray);
	drawMarker(g, p1);
	drawMarker(g, p2);
	g.setColor(Color.red);
	drawMarker(g, c1);
	drawMarker(g, c2);
	
	g.setColor(Color.black);
	g.draw(curve);
	g.fill(curve);
	
	g.draw(poly);
	g.fill(poly);
}
 
Example 4
Source File: LineRenderTest.java    From slick2d-maven with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
	 * @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 5
Source File: MorphShapeTest.java    From slick2d-maven with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * @see org.newdawn.slick.Game#render(GameContainer, Graphics)
 */
public void render(GameContainer container, Graphics g)
		throws SlickException {
	g.setColor(Color.green);
	g.draw(a);
	g.setColor(Color.red);
	g.draw(b);
	g.setColor(Color.blue);
	g.draw(c);
	g.setColor(Color.white);
	g.draw(morph);
}
 
Example 6
Source File: GeomAccuracyTest.java    From slick2d-maven with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Draws ovals
 * @param g
 */
void ovalTest(Graphics g) {

	g.setColor(geomColor);
	g.drawOval(100, 100, 99, 99);
	g.fillOval(100, 250, 99, 99);
	
	//Circle circ = new Circle(400, 100, 99);
	Ellipse elip = new Ellipse(449, 149, 49, 49);
	g.draw(elip);
	elip = new Ellipse(449, 299, 49, 49);
	g.fill(elip);
	
	if(hideOverlay == false) {
		g.setColor(overlayColor);
		g.drawLine(100, 149, 198, 149);
		g.drawLine(149, 100, 149, 198);
		
		g.drawLine(100, 149 + 150, 198, 149 + 150);
		g.drawLine(149, 100 + 150, 149, 198 + 150);
		
		g.drawLine(100 + 300, 149, 198 + 300, 149);
		g.drawLine(149 + 300, 100, 149 + 300, 198);			
		
		g.drawLine(100 + 300, 149 + 150, 198 + 300, 149 + 150);
		g.drawLine(149 + 300, 100 + 150, 149 + 300, 198 + 150);			
	}
	

}
 
Example 7
Source File: PolygonTest.java    From slick2d-maven with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * @see org.newdawn.slick.Game#render(org.newdawn.slick.GameContainer, org.newdawn.slick.Graphics)
 */
public void render(GameContainer container, Graphics g) throws SlickException {
	if (in) {
		g.setColor(Color.red);
		g.fill(poly);
	}
	g.setColor(Color.yellow);
	g.fillOval(poly.getCenterX()-3, poly.getCenterY()-3, 6, 6);
	g.setColor(Color.white);
	g.draw(poly);
}
 
Example 8
Source File: GeomTest.java    From slick2d-maven with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/**
 * @see org.newdawn.slick.BasicGame#render(org.newdawn.slick.GameContainer, org.newdawn.slick.Graphics)
 */
public void render(GameContainer container, Graphics g) {
	g.setColor(Color.white);
	g.drawString("Red indicates a collision, green indicates no collision", 50, 420);
       g.drawString("White are the targets", 50, 435);

       g.pushTransform();
       g.translate(100,100);
       g.pushTransform();
       g.translate(-50,-50);
       g.scale(10, 10);
       g.setColor(Color.red);
       g.fillRect(0,0,5,5);
       g.setColor(Color.white);
       g.drawRect(0,0,5,5);
       g.popTransform();
       g.setColor(Color.green);
       g.fillRect(20,20,50,50);
       g.popTransform();
       
	g.setColor(Color.white);
	g.draw(rect);
	g.draw(circle);
	
	g.setColor(rect1.intersects(rect) ? Color.red : Color.green);
	g.draw(rect1);
	g.setColor(rect2.intersects(rect) ? Color.red : Color.green);
	g.draw(rect2);
       g.setColor(roundRect.intersects(rect) ? Color.red : Color.green);
       g.draw(roundRect);
	g.setColor(circle1.intersects(rect) ? Color.red : Color.green);
	g.draw(circle1);
	g.setColor(circle2.intersects(rect) ? Color.red : Color.green);
	g.draw(circle2);
	g.setColor(circle3.intersects(circle) ? Color.red : Color.green);
	g.fill(circle3);
	g.setColor(circle4.intersects(circle) ? Color.red : Color.green);
	g.draw(circle4);

       g.fill(roundRect2);
	g.setColor(Color.blue);
       g.draw(roundRect2);
	g.setColor(Color.blue);
	g.draw(new Circle(100,100,50));
	g.drawRect(50,50,100,100);
       
}
 
Example 9
Source File: GraphicsTest.java    From slick2d-maven with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/**
 * @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();
	}
}