本文整理汇总了Java中org.newdawn.slick.Graphics.setClip方法的典型用法代码示例。如果您正苦于以下问题:Java Graphics.setClip方法的具体用法?Java Graphics.setClip怎么用?Java Graphics.setClip使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.newdawn.slick.Graphics
的用法示例。
在下文中一共展示了Graphics.setClip方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: preRender
import org.newdawn.slick.Graphics; //导入方法依赖的package包/类
/**
* @see org.newdawn.slick.state.transition.Transition#preRender(org.newdawn.slick.state.StateBasedGame, org.newdawn.slick.GameContainer, org.newdawn.slick.Graphics)
*/
public void preRender(StateBasedGame game, GameContainer container,
Graphics g) throws SlickException {
if (moveBackDone) {
g.translate(xp1,yp1);
g.scale(scale1, scale1);
g.setClip((int) xp1,(int) yp1,(int) (scale1*container.getWidth()),(int) (scale1*container.getHeight()));
prev.render(container, game, g);
g.resetTransform();
g.clearClip();
}
g.translate(xp2,yp2);
g.scale(scale2, scale2);
g.setClip((int) xp2,(int) yp2,(int) (scale2*container.getWidth()),(int) (scale2*container.getHeight()));
}
示例2: postRender
import org.newdawn.slick.Graphics; //导入方法依赖的package包/类
/**
* @see org.newdawn.slick.state.transition.Transition#postRender(org.newdawn.slick.state.StateBasedGame, org.newdawn.slick.GameContainer, org.newdawn.slick.Graphics)
*/
public void postRender(StateBasedGame game, GameContainer container, Graphics g) throws SlickException {
g.resetTransform();
if (!moveBackDone) {
g.translate(xp1,yp1);
g.scale(scale1, scale1);
g.setClip((int) xp1,(int) yp1,(int) (scale1*container.getWidth()),(int) (scale1*container.getHeight()));
prev.render(container, game, g);
g.resetTransform();
g.clearClip();
}
}
示例3: 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.setColor(Color.white);
g.drawString("1 - No Clipping", 100, 10);
g.drawString("2 - Screen Clipping", 100, 30);
g.drawString("3 - World Clipping", 100, 50);
if (world) {
g.drawString("WORLD CLIPPING ENABLED", 200, 80);
}
if (clip) {
g.drawString("SCREEN CLIPPING ENABLED", 200, 80);
}
g.rotate(400, 400, ang);
if (world) {
g.setWorldClip(350,302,100,196);
}
if (clip) {
g.setClip(350,302,100,196);
}
g.setColor(Color.red);
g.fillOval(300,300,200,200);
g.setColor(Color.blue);
g.fillRect(390,200,20,400);
g.clearClip();
g.clearWorldClip();
}
示例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) 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();
}
}
示例5: 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);
}