当前位置: 首页>>代码示例>>Java>>正文


Java Graphics.drawRect方法代码示例

本文整理汇总了Java中org.newdawn.slick.Graphics.drawRect方法的典型用法代码示例。如果您正苦于以下问题:Java Graphics.drawRect方法的具体用法?Java Graphics.drawRect怎么用?Java Graphics.drawRect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.newdawn.slick.Graphics的用法示例。


在下文中一共展示了Graphics.drawRect方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: render

import org.newdawn.slick.Graphics; //导入方法依赖的package包/类
/**
 * @see org.newdawn.slick.BasicGame#render(org.newdawn.slick.GameContainer, org.newdawn.slick.Graphics)
 */
public void render(GameContainer contiainer, Graphics g) {
   g.translate(320,240);
   
   g.translate( -camX * scale, -camY * scale);
   
         
   g.scale(scale, scale);

   g.setColor(Color.red);
   for (int x=0;x<10;x++) {
      for (int y=0;y<10;y++) {
         g.fillRect(-500+(x*100), -500+(y*100), 80, 80);
      }
   }
   
   g.setColor(new Color(1,1,1,0.5f));
   g.fillRect(-320,-240,640,480);
   g.setColor(Color.white);
   g.drawRect(-320,-240,640,480);
}
 
开发者ID:j-dong,项目名称:trashjam2017,代码行数:24,代码来源:TransformTest2.java

示例2: render

import org.newdawn.slick.Graphics; //导入方法依赖的package包/类
/**
 * @see org.newdawn.slick.Game#render(org.newdawn.slick.GameContainer, org.newdawn.slick.Graphics)
 */
public void render(GameContainer container, Graphics g) {
	g.setColor(Color.white);

	String text = "This is UnicodeFont!\nIt rockz. Kerning: T,";
	unicodeFont.drawString(10, 33, text);
	// unicodeFont.drawString(10, 33, text, Color.red, 8, 19);
	g.setColor(Color.red);
	g.drawRect(10, 33, unicodeFont.getWidth(text), unicodeFont.getLineHeight());
	g.setColor(Color.blue);
	int yOffset = unicodeFont.getYOffset(text);
	g.drawRect(10, 33 + yOffset, unicodeFont.getWidth(text), unicodeFont.getHeight(text) - yOffset);

	// font.drawString(10, 73, "\u6880\u6881\u6882 (...) \u6883\u6884\u6885\u6886\u6887 hi?");

	unicodeFont.addGlyphs("[email protected]!#!#$%___--");
	// Cypriot Syllabary glyphs (Everson Mono font): \uD802\uDC02\uD802\uDC03\uD802\uDC12 == 0x10802, 0x10803, s0x10812
	// g.drawLine(0, container.getHeight() - 512, container.getWidth(), container.getHeight() - 512);
}
 
开发者ID:IngSW-unipv,项目名称:Progetto-C,代码行数:22,代码来源:UnicodeFontTest.java

示例3: render

import org.newdawn.slick.Graphics; //导入方法依赖的package包/类
/**
 * @see org.newdawn.slick.BasicGame#render(org.newdawn.slick.GameContainer, org.newdawn.slick.Graphics)
 */
public void render(GameContainer container, Graphics g) {
	g.drawString("T - TGA Snapshot", 10,50);
	g.drawString("J - JPG Snapshot", 10,70);
	g.drawString("P - PNG Snapshot", 10,90);

	g.setDrawMode(Graphics.MODE_ADD);
	g.drawImage(copy, 200, 300);
	g.setDrawMode(Graphics.MODE_NORMAL);
	
	g.drawString(message, 10,400);
	g.drawRect(200,0,400,300);
	g.translate(400, 250);
	fire.render();
	this.g = g;
}
 
开发者ID:IngSW-unipv,项目名称:Progetto-C,代码行数:19,代码来源:ImageOutTest.java

示例4: render

import org.newdawn.slick.Graphics; //导入方法依赖的package包/类
/**
 * @see org.newdawn.slick.BasicGame#render(org.newdawn.slick.GameContainer, org.newdawn.slick.Graphics)
 */
public void render(GameContainer container, Graphics g) {
	original.draw(0,0,new Color(1,1,1,0.4f));
	
	image.draw(x,y);
	imageX.draw(x+400,y);
	imageY.draw(x,y+300);
	scaledSub.draw(x+300,y+300);
	
	bigSheet.getSprite(7, 5).draw(50,10);
	g.setColor(Color.white);
	g.drawRect(50,10,64,64);
	g.rotate(x+400, y+165, ang);
	g.drawImage(sub, x+300, y+100);
}
 
开发者ID:IngSW-unipv,项目名称:Progetto-C,代码行数:18,代码来源:BigImageTest.java

示例5: showSunCollectedGrid

import org.newdawn.slick.Graphics; //导入方法依赖的package包/类
/**
 * Draw SunCollected grid
 * @param gc GameContainer
 * @param sbg	StateBasedGame
 * @param g	Graphics
 * @throws SlickException
 */
public static void showSunCollectedGrid(GameContainer gc, StateBasedGame sbg, Graphics g) throws SlickException {
	float posX = 10 * PZGUI.getResolutionRateWidth();
	float posY = 20 * PZGUI.getResolutionRateHeight();
	float W = 200 * PZGUI.getResolutionRateWidth();
	float H = 45  * PZGUI.getResolutionRateHeight();
	g.drawRect(posX, posY, W, H);
}
 
开发者ID:hungthuanmk,项目名称:HCMIU_PlantsAndZombies,代码行数:15,代码来源:PlayUI.java

示例6: render

import org.newdawn.slick.Graphics; //导入方法依赖的package包/类
/**
 * @see org.newdawn.slick.Game#render(org.newdawn.slick.GameContainer, org.newdawn.slick.Graphics)
 */
public void render(GameContainer container, Graphics g) {
	g.setColor(Color.white);

	String text = "This is UnicodeFont!\nIt rockz. Kerning: T,";
	unicodeFont.drawString(10, 33, text);
	// unicodeFont.drawString(10, 33, text, Color.red, 8, 19);
	g.setColor(Color.red);
	g.drawRect(10, 33, unicodeFont.getWidth(text), unicodeFont.getLineHeight());
	g.setColor(Color.blue);
	int yOffset = unicodeFont.getYOffset(text);
	g.drawRect(10, 33 + yOffset, unicodeFont.getWidth(text), unicodeFont.getHeight(text) - yOffset);


       String tst = "width comparison, ,";
       g.setFont(unicodeFont);
       g.setColor(Color.green);
       g.drawString(tst,10,300);
       g.drawString(tst,10,350);
       g.drawRect(10, 300, unicodeFont.getLogicalWidth(tst), unicodeFont.getLineHeight());
       g.setColor(Color.red);
       g.drawRect(10, 350, unicodeFont.getWidth(tst), unicodeFont.getLineHeight());

       // font.drawString(10, 73, "\u6880\u6881\u6882 (...) \u6883\u6884\u6885\u6886\u6887 hi?");

	unicodeFont.addGlyphs("[email protected]!#!#$%___--");
	// Cypriot Syllabary glyphs (Everson Mono font): \uD802\uDC02\uD802\uDC03\uD802\uDC12 == 0x10802, 0x10803, s0x10812
	// g.drawLine(0, container.getHeight() - 512, container.getWidth(), container.getHeight() - 512);
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:32,代码来源:UnicodeFontTest.java

示例7: render

import org.newdawn.slick.Graphics; //导入方法依赖的package包/类
/**
 * @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();
	}
}
 
开发者ID:IngSW-unipv,项目名称:Progetto-C,代码行数:64,代码来源:GraphicsTest.java

示例8: render

import org.newdawn.slick.Graphics; //导入方法依赖的package包/类
/**
 * @see org.newdawn.slick.BasicGame#render(org.newdawn.slick.GameContainer, org.newdawn.slick.Graphics)
 */
public void render(GameContainer container, Graphics g) {
	
	String text = new String();
	
	switch(curTest) {
	
	case 0:
			text = "Rectangles";
			rectTest(g);
			break;
			
	case 1:
			text = "Ovals";
			ovalTest(g);
			break;
			
	case 2:
			text ="Arcs";
			arcTest(g);
			break;
	}
	
	g.setColor(Color.white);
	g.drawString("Press T to toggle overlay", 200, 55);
	g.drawString("Press N to switch tests", 200, 35);
	g.drawString("Press C to cycle drawing colors", 200, 15);
	g.drawString("Current Test:", 400, 35);
	g.setColor(Color.blue);
	g.drawString(text, 485, 35);
	
	g.setColor(Color.white);
	g.drawString("Normal:", 10, 150);
	g.drawString("Filled:", 10, 300);
	
	g.drawString("Drawn with Graphics context", 125, 400);
	g.drawString("Drawn using Shapes", 450, 400);
	
	// Grab our mouse position and copy the screen to our magnified image
	g.copyArea(magImage, container.getInput().getMouseX() - 10, container.getInput().getMouseY() - 10);
	magImage.draw(351, 451, 5);
	g.drawString("Mag Area -", 250, 475);
	g.setColor(Color.darkGray);
	g.drawRect(350, 450, 106, 106);
	
	g.setColor(Color.white);
	g.drawString("NOTE:", 500, 450);
	g.drawString("lines should be flush with edges", 525, 470);
	g.drawString("corners should be symetric", 525, 490);
	
}
 
开发者ID:j-dong,项目名称:trashjam2017,代码行数:54,代码来源:GeomAccuracyTest.java

示例9: render

import org.newdawn.slick.Graphics; //导入方法依赖的package包/类
/**
 * @see org.newdawn.slick.gui.AbstractComponent#render(org.newdawn.slick.gui.GUIContext,
 *      org.newdawn.slick.Graphics)
 */
public void render(GUIContext container, Graphics g) {
	if (lastKey != -1) {
		if (input.isKeyDown(lastKey)) {
			if (repeatTimer < System.currentTimeMillis()) {
				repeatTimer = System.currentTimeMillis() + KEY_REPEAT_INTERVAL;
				keyPressed(lastKey, lastChar);
			}
		} else {
			lastKey = -1;
		}
	}
	Rectangle oldClip = g.getClip();
	g.setWorldClip(x,y,width, height);
	
	// Someone could have set a color for me to blend...
	Color clr = g.getColor();

	if (background != null) {
		g.setColor(background.multiply(clr));
		g.fillRect(x, y, width, height);
	}
	g.setColor(text.multiply(clr));
	Font temp = g.getFont();

	int cpos = font.getWidth(value.substring(0, cursorPos));
	int tx = 0;
	if (cpos > width) {
		tx = width - cpos - font.getWidth("_");
	}

	g.translate(tx + 2, 0);
	g.setFont(font);
	g.drawString(value, x + 1, y + 1);

	if (hasFocus() && visibleCursor) {
		g.drawString("_", x + 1 + cpos + 2, y + 1);
	}

	g.translate(-tx - 2, 0);

	if (border != null) {
		g.setColor(border.multiply(clr));
		g.drawRect(x, y, width, height);
	}
	g.setColor(clr);
	g.setFont(temp);
	g.clearWorldClip();
	g.setClip(oldClip);
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:54,代码来源:TextField.java

示例10: render

import org.newdawn.slick.Graphics; //导入方法依赖的package包/类
/**
 * @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);
       
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:50,代码来源:GeomTest.java

示例11: render

import org.newdawn.slick.Graphics; //导入方法依赖的package包/类
/**
 * Render the game - in this case render the map and diagnostic data
 * 
 * @param container The container we're running the game in
 * @param g The graphics context on which to render
 */
public void render(GameContainer container, Graphics g)
		throws SlickException {
	g.translate(50,50);
	for (int x=0;x<50;x++) {
		for (int y=0;y<50;y++) {
			if (dataMap.blocked(this, x, y)) {
				g.setColor(Color.gray);
				g.fillRect((x*10)+1,(y*10)+1,8,8);
			}
		}
	}
	
	if (showSpaces) {
		for (int i=0;i<navMesh.getSpaceCount();i++) {
			Space space = navMesh.getSpace(i);
			if (builder.clear(dataMap, space)) {
				g.setColor(new Color(1,1,0,0.5f));
				g.fillRect(space.getX()*10, space.getY()*10, space.getWidth()*10, space.getHeight()*10);
			}
			g.setColor(Color.yellow);
			g.drawRect(space.getX()*10, space.getY()*10, space.getWidth()*10, space.getHeight()*10);

			if (showLinks) {
				int links = space.getLinkCount();
				for (int j=0;j<links;j++) {
					Link link = space.getLink(j);
					g.setColor(Color.red);
					g.fillRect((link.getX()*10)-2, (link.getY()*10)-2,5,5);
				}
			}
		}
	}
	
	if (path != null) {
		g.setColor(Color.white);
		for (int i=0;i<path.length()-1;i++) {
			g.drawLine(path.getX(i)*10, path.getY(i)*10, path.getX(i+1)*10, path.getY(i+1)*10);
		}
	}
}
 
开发者ID:IngSW-unipv,项目名称:Progetto-C,代码行数:47,代码来源:NavMeshTest.java

示例12: render

import org.newdawn.slick.Graphics; //导入方法依赖的package包/类
/**
 * @see org.newdawn.slick.BasicGame#render(org.newdawn.slick.GameContainer, org.newdawn.slick.Graphics)
 */
public void render(GameContainer container, Graphics g) throws SlickException {

	// RENDERING TO AN IMAGE AND THEN DRAWING IT TO THE DISPLAY
	// Draw graphics and text onto our graphics context from the Image target
	gTarget.setBackground(new Color(0,0,0,0));
	gTarget.clear();
	gTarget.rotate(200,160,ang);
	gTarget.setFont(testFont);
	gTarget.fillRect(10, 10, 50, 50);
	gTarget.drawString("HELLO WORLD",10,10);

	gTarget.drawImage(testImage,100,150);
	gTarget.drawImage(testImage,100,50);
	gTarget.drawImage(testImage,50,75);
	
	// Note we started by clearing the offscreen graphics area and then end
	// by calling flush
	gTarget.flush(); 

	g.setColor(Color.red);
	g.fillRect(250, 50, 200, 200);
	// The image has been updated using its graphics context, so now draw the image
	// to the screen a few times
	target.draw(300,100);
	target.draw(300,410,200,150);
	target.draw(505,410,100,75);
	
	// Draw some text on the screen to indicate what we did and put some
	// nice boxes around the three areas
	g.setColor(Color.white);
	g.drawString("Testing On Offscreen Buffer", 300, 80);
	g.setColor(Color.green);
	g.drawRect(300, 100, target.getWidth(), target.getHeight());
	g.drawRect(300, 410, target.getWidth()/2, target.getHeight()/2);
	g.drawRect(505, 410, target.getWidth()/4, target.getHeight()/4);
	
	// SCREEN COPY EXAMPLE
	// Put some text and simple graphics on the screen to test copying
	// from the screen to a target image
	g.setColor(Color.white);
	g.drawString("Testing Font On Back Buffer", 10, 100);
	g.drawString("Using: "+using, 10, 580);
	g.setColor(Color.red);
	g.fillRect(10,120,200,5);
	
	// Copy the screen area into a destination image
	int xp = (int) (60 + (Math.sin(ang / 60) * 50));
	g.copyArea(cut,xp,50);
	
	// Draw the copied image to the screen and put some nice
	// boxes around the source and the destination
	cut.draw(30,250);
	g.setColor(Color.white);
	g.drawRect(30, 250, cut.getWidth(), cut.getHeight());
	g.setColor(Color.gray);
	g.drawRect(xp, 50, cut.getWidth(), cut.getHeight());
	
	// ALTERING A LOADED IMAGE EXAMPLE
	// Draw the image we loaded in the init method and then modified
	// by drawing some text and simple geometry on it
	preloaded.draw(2,400);
	g.setColor(Color.blue);
	g.drawRect(2,400,preloaded.getWidth(),preloaded.getHeight());
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:68,代码来源:ImageGraphicsTest.java

示例13: drawMarker

import org.newdawn.slick.Graphics; //导入方法依赖的package包/类
/**
 * Draw a marker for a given point
 * 
 * @param g The graphics context on which to draw
 * @param p The point to draw
 */
private void drawMarker(Graphics g, Vector2f p) {
	g.drawRect(p.x-5, p.y-5,10,10);
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:10,代码来源:CurveTest.java


注:本文中的org.newdawn.slick.Graphics.drawRect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。