本文整理匯總了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);
}
示例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);
}
示例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());
}