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


Java Graphics.fillRect方法代码示例

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


在下文中一共展示了Graphics.fillRect方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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 container, Graphics g) {
       g.drawString("left shift down: "+lshift, 100, 240);
       g.drawString("right shift down: "+rshift, 100, 260);
       g.drawString("space down: "+space, 100, 280); 
       
	g.setColor(Color.white);
	g.drawString(message, 10, 50);
	g.drawString(""+container.getInput().getMouseY(), 10, 400);
	g.drawString("Use the primary gamepad to control the blob, and hit a gamepad button to change the color", 10, 90);

	for (int i=0;i<lines.size();i++) {
		Line line = (Line) lines.get(i);
		line.draw(g);
	}
	
	g.setColor(cols[index]);
	g.fillOval((int) x, (int) y, 50, 50);
	g.setColor(Color.yellow);
	g.fillRect(50,200+ypos,40,40);
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:24,代码来源:InputTest.java

示例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.translate(container.getWidth()/2, container.getHeight()/2);
	g.scale(scale,scale);
	g.rotate(0, 0, ang);
	g.translate(-container.getWidth()/2, -container.getHeight()/2);
	if (background != null) {
		Color c = g.getColor();
		g.setColor(background);
		g.fillRect(0,0,container.getWidth(),container.getHeight());
		g.setColor(c);
	}
	prev.render(container, game, g);
	g.translate(container.getWidth()/2, container.getHeight()/2);
	g.rotate(0, 0, -ang);
	g.scale(1/scale,1/scale);
	g.translate(-container.getWidth()/2, -container.getHeight()/2);
}
 
开发者ID:j-dong,项目名称:trashjam2017,代码行数:21,代码来源:RotateTransition.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 contiainer, Graphics g) {
	g.translate(320,240);
	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,代码行数:20,代码来源:TransformTest.java

示例4: render

import org.newdawn.slick.Graphics; //导入方法依赖的package包/类
@Override
public void render(Graphics g, long cTime) {
	// Draw the text as normal.
	g.setColor(color);
	g.setFont(ttf);
	g.drawString(text, pos.x, pos.y);
	
	// If the mouse cursor is hovering over the text, display the tooltip.
	if(isMouseInside()) {
		float mx = Globals.mouse.getPosition().x;
		float my = Globals.mouse.getPosition().y;
		float txtWidth = ttf.getWidth(tooltip);
		
		g.setColor(Color.gray);
		g.fillRect(mx, my, (txtWidth + 10.0f), (ttf.getHeight() + 10.0f));
		g.setColor(Color.white);
		g.drawRect(mx, my, (txtWidth + 10.0f), (ttf.getHeight() + 10.0f));
		g.setColor(Color.black);
		g.drawString(tooltip, (mx + 5.0f), (my + 5.0f));
	}
}
 
开发者ID:packetpirate,项目名称:Generic-Zombie-Shooter-Redux,代码行数:22,代码来源:TooltipText.java

示例5: 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) {
	if (nextResource != null) {
		g.drawString("Loading: "+nextResource.getDescription(), 100, 100);
	}
	
	int total = LoadingList.get().getTotalResources();
	int loaded = LoadingList.get().getTotalResources() - LoadingList.get().getRemainingResources();
	
	float bar = loaded / (float) total;
	g.fillRect(100,150,loaded*40,20);
	g.drawRect(100,150,total*40,20);
	
	if (started) {
		image.draw(100,200);
		font.drawString(100,500,"LOADING COMPLETE");
	}
}
 
开发者ID:IngSW-unipv,项目名称:Progetto-C,代码行数:21,代码来源:DeferredLoadingTest.java

示例6: 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.scale(2,2);
	g.fillRect(0, 0, 800, 600, back, 0, 0);
	g.resetTransform();
	
	g.drawImage(image,100,100);
	image.draw(100,200,80,200);
	
	font.drawString(100,200,"Text Drawn before the callable");
	
	SlickCallable callable = new SlickCallable() {
		protected void performGLOperations() throws SlickException {
			renderGL();
		}
	};
	callable.call();
	
	homer.draw(450,250,80,200);
	font.drawString(150,300,"Text Drawn after the callable");
}
 
开发者ID:j-dong,项目名称:trashjam2017,代码行数:24,代码来源:SlickCallableTest.java

示例7: 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);
	textureMap.draw(10,50);
	g.setColor(Color.red);
	g.fillRect(290,40,200,200);
	g.setColor(Color.white);
	// write only alpha
	g.setDrawMode(Graphics.MODE_ALPHA_MAP);
	alphaMap.draw(300,50);
	g.setDrawMode(Graphics.MODE_ALPHA_BLEND);
	textureMap.draw(300,50);
	g.setDrawMode(Graphics.MODE_NORMAL);
}
 
开发者ID:IngSW-unipv,项目名称:Progetto-C,代码行数:19,代码来源:AlphaMapTest.java

示例8: 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) {
	Color old = g.getColor();
	g.setColor(color);
	
	g.fillRect(0, 0, container.getWidth()*2, container.getHeight()*2);
	g.setColor(old);
}
 
开发者ID:j-dong,项目名称:trashjam2017,代码行数:11,代码来源:FadeInTransition.java

示例9: 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) {
	Color old = g.getColor();
	g.setColor(color);
	g.fillRect(0, 0, container.getWidth() * 2, container.getHeight() * 2);
	g.setColor(old);
}
 
开发者ID:IngSW-unipv,项目名称:Progetto-C,代码行数:10,代码来源:FadeOutTransition.java

示例10: 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();
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:33,代码来源:ClipTest.java

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

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

示例13: 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:IngSW-unipv,项目名称:Progetto-C,代码行数:54,代码来源:TextField.java

示例14: 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:IngSW-unipv,项目名称:Progetto-C,代码行数:50,代码来源:GeomTest.java


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