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


Java Graphics.copyArea方法代码示例

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


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

示例1: 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)
		throws SlickException {
	g.clearAlphaMap();
	g.setDrawMode(Graphics.MODE_NORMAL);
	g.setColor(Color.white);
	g.fillOval(100,100,150,150);
	textureMap.draw(10,50);
	
	g.copyArea(copy, 100,100);
	g.setColor(Color.red);
	g.fillRect(300,100,200,200);
	copy.draw(350,150);
}
 
开发者ID:j-dong,项目名称:trashjam2017,代码行数:17,代码来源:CopyAreaAlphaTest.java

示例2: 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

示例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) 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:j-dong,项目名称:trashjam2017,代码行数:68,代码来源:ImageGraphicsTest.java


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