當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。