當前位置: 首頁>>代碼示例>>Java>>正文


Java Color類代碼示例

本文整理匯總了Java中org.newdawn.slick.Color的典型用法代碼示例。如果您正苦於以下問題:Java Color類的具體用法?Java Color怎麽用?Java Color使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Color類屬於org.newdawn.slick包,在下文中一共展示了Color類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: render

import org.newdawn.slick.Color; //導入依賴的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

示例2: render

import org.newdawn.slick.Color; //導入依賴的package包/類
/**
 * Game loop render
 */
public void render() {
	Color.white.bind();
	texture.bind(); // or GL11.glBind(texture.getTextureID());
	
	GL11.glBegin(GL11.GL_QUADS);
		GL11.glTexCoord2f(0,0);
		GL11.glVertex2f(100,100);
		GL11.glTexCoord2f(1,0);
		GL11.glVertex2f(100+texture.getTextureWidth(),100);
		GL11.glTexCoord2f(1,1);
		GL11.glVertex2f(100+texture.getTextureWidth(),100+texture.getTextureHeight());
		GL11.glTexCoord2f(0,1);
		GL11.glVertex2f(100,100+texture.getTextureHeight());
	GL11.glEnd();
	
	font.drawString(150, 300, "HELLO LWJGL WORLD", Color.yellow);
}
 
開發者ID:IngSW-unipv,項目名稱:Progetto-C,代碼行數:21,代碼來源:TestUtils.java

示例3: preRender

import org.newdawn.slick.Color; //導入依賴的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 {
	prev.render(container, game, g);
	
	MaskUtil.defineMask();
	for (int i=0;i<blobs.size();i++) {
		((Blob) blobs.get(i)).render(g);
	}
	MaskUtil.finishDefineMask();

	MaskUtil.drawOnMask();
	if (background != null) {
		Color c = g.getColor();
		g.setColor(background);
		g.fillRect(0,0,container.getWidth(),container.getHeight());
		g.setColor(c);
	}
}
 
開發者ID:j-dong,項目名稱:trashjam2017,代碼行數:22,代碼來源:BlobbyTransition.java

示例4: init

import org.newdawn.slick.Color; //導入依賴的package包/類
/**
 * @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer)
 */
public void init(GameContainer container) throws SlickException {
	this.container = container;
	
	SpriteSheet sheet = new SpriteSheet("testdata/homeranim.png", 36, 65);
	animation = new Animation();
	for (int i=0;i<8;i++) {
		animation.addFrame(sheet.getSprite(i,0), 150);
	}
	limited = new Animation();
	for (int i=0;i<8;i++) {
		limited.addFrame(sheet.getSprite(i,0), 150);
	}
	limited.stopAt(7);
	manual = new Animation(false);
	for (int i=0;i<8;i++) {
		manual.addFrame(sheet.getSprite(i,0), 150);
	}
	pingPong = new Animation(sheet, 0,0,7,0,true,150,true);
	pingPong.setPingPong(true);
	container.getGraphics().setBackground(new Color(0.4f,0.6f,0.6f));
}
 
開發者ID:IngSW-unipv,項目名稱:Progetto-C,代碼行數:25,代碼來源:AnimationTest.java

示例5: fire

import org.newdawn.slick.Color; //導入依賴的package包/類
@Override
public void fire(Player player, Pair<Float> position, float theta, long cTime) {
	Color color = getProjectile().getColor();
	float velocity = getProjectile().getVelocity();
	float width = getProjectile().getWidth();
	float height = getProjectile().getHeight();
	long lifespan = getProjectile().getLifespan();
	Particle particle = new Particle(color, position, velocity, theta,
									 0.0f, new Pair<Float>(width, height), 
									 lifespan, cTime);
	Turret turret = new Turret(particle);
	projectiles.add(turret);
	
	ammoInClip--;
	lastFired = cTime;
	
	fireSound.play();
}
 
開發者ID:packetpirate,項目名稱:Generic-Zombie-Shooter-Redux,代碼行數:19,代碼來源:SentryWeapon.java

示例6: drawInUse

import org.newdawn.slick.Color; //導入依賴的package包/類
public final void drawInUse(int DrawX, int DrawY, int DrawX2, int DrawY2,
		int SrcX, int SrcY, int SrcX2, int SrcY2)
{
	if (CurrentTexture > 0)
	{
		if (slickGame.g != null)
		{
			if (Blending == false)
			{
				slickResources.images[CurrentTexture].drawEmbedded(DrawX,
						DrawY, DrawX2, DrawY2, SrcX, SrcY, SrcX2, SrcY2,
						Color.white);
			}
			else
			{
				slickResources.images[CurrentTexture].drawEmbedded(DrawX,
						DrawY, DrawX2, DrawY2, SrcX, SrcY, SrcX2, SrcY2,
						slickGame.g.getColor());
			}
		}
	}
}
 
開發者ID:TheRemote,項目名稱:Spark,代碼行數:23,代碼來源:SlickEngine.java

示例7: showPauseButton

import org.newdawn.slick.Color; //導入依賴的package包/類
/**
 * Draw Pause button
 * @param gc	GameContainer
 * @param g	Graphics
 * @throws SlickException
 */
public static void showPauseButton(GameContainer gc, Graphics g) throws SlickException {
	pauseButton.draw(pauseButtonPosX, pauseButtonPosY, pauseButtonWidth, pauseButtonHeight);

	if (Controller.mouseInArea(pauseButtonPosX, pauseButtonPosY, pauseButtonPosX + pauseButtonHeight,
								pauseButtonPosY + pauseButtonHeight)) {
		pauseButton.draw(pauseButtonPosX, pauseButtonPosY, pauseButtonWidth, pauseButtonHeight, new Color(0, 0, 0, 50));

		if (Mouse.getEventButtonState() && Mouse.getEventButton() == 0) {
			gc.setPaused(!gc.isPaused());
			try {
				TimeUnit.MILLISECONDS.sleep(100);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
	}
}
 
開發者ID:hungthuanmk,項目名稱:HCMIU_PlantsAndZombies,代碼行數:24,代碼來源:PlayUI.java

示例8: renderGlyph

import org.newdawn.slick.Color; //導入依賴的package包/類
/**
 * Loads a single glyph to the backing texture, if it fits.
 * 
 * @param glyph The glyph to be rendered
 * @param width The expected width of the glyph
 * @param height The expected height of the glyph
 * @throws SlickException if the glyph could not be rendered.
 */
private void renderGlyph(Glyph glyph, int width, int height) throws SlickException {
	// Draw the glyph to the scratch image using Java2D.
	scratchGraphics.setComposite(AlphaComposite.Clear);
	scratchGraphics.fillRect(0, 0, MAX_GLYPH_SIZE, MAX_GLYPH_SIZE);
	scratchGraphics.setComposite(AlphaComposite.SrcOver);
	scratchGraphics.setColor(java.awt.Color.white);
	for (Iterator iter = unicodeFont.getEffects().iterator(); iter.hasNext();)
		((Effect)iter.next()).draw(scratchImage, scratchGraphics, unicodeFont, glyph);
	glyph.setShape(null); // The shape will never be needed again.

	WritableRaster raster = scratchImage.getRaster();
	int[] row = new int[width];
	for (int y = 0; y < height; y++) {
		raster.getDataElements(0, y, width, 1, row);
		scratchIntBuffer.put(row);
	}
	GL.glTexSubImage2D(SGL.GL_TEXTURE_2D, 0, pageX, pageY, width, height, SGL.GL_BGRA, SGL.GL_UNSIGNED_BYTE,
		scratchByteBuffer);
	scratchIntBuffer.clear();

	glyph.setImage(pageImage.getSubImage(pageX, pageY, width, height));
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:31,代碼來源:GlyphPage.java

示例9: render

import org.newdawn.slick.Color; //導入依賴的package包/類
/**
 * @see org.newdawn.slick.BasicGame#render(org.newdawn.slick.GameContainer, org.newdawn.slick.Graphics)
 */
public void render(GameContainer container, Graphics g) {
	
	g.rotate(400, 300, ang);
	g.fill(rect, gradient);
	g.fill(round, gradient);
	g.fill(poly, gradient2);
	g.fill(center, gradient4);

	g.setAntiAlias(true);
	g.setLineWidth(10);
	g.draw(round2, gradient2);
	g.setLineWidth(2);
	g.draw(poly, gradient);
	g.setAntiAlias(false);
	
	g.fill(center, gradient4);
	g.setAntiAlias(true);
	g.setColor(Color.black);
	g.draw(center);
	g.setAntiAlias(false);
}
 
開發者ID:j-dong,項目名稱:trashjam2017,代碼行數:25,代碼來源:GradientTest.java

示例10: update

import org.newdawn.slick.Color; //導入依賴的package包/類
@Override
public void update(GameContainer gc, StateBasedGame sbg, int i) throws SlickException {
    if (shouldToggleFullscreen) {
        shouldToggleFullscreen = false;
        boolean fs = !gc.isFullscreen();
        AppGameContainer agc = (AppGameContainer)gc;
        agc.setDisplayMode(fs ? agc.getScreenWidth() : Application.DISPLAY_WIDTH,
                           fs ? agc.getScreenHeight() : Application.DISPLAY_HEIGHT, fs);
    }
    if (gc.getInput().isKeyPressed(Input.KEY_ENTER)) {
        click.play(1.0f, CLICK_VOLUME);
        mainMenu.fade(1000, 0.0f, true);
        sbg.enterState(Application.GAME, new FadeOutTransition(Color.black, 1000), new EmptyTransition());
    }
    if (gc.getInput().isKeyPressed(Input.KEY_C)) {
        sbg.enterState(Application.CREDITS);
    }
}
 
開發者ID:j-dong,項目名稱:trashjam2017,代碼行數:19,代碼來源:MainMenu.java

示例11: render

import org.newdawn.slick.Color; //導入依賴的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("The OGG loop is now streaming from the file, woot.",100,60);
	g.drawString("Press space for sound effect (OGG)",100,100);
	g.drawString("Press P to pause/resume music (XM)",100,130);
	g.drawString("Press E to pause/resume engine sound (WAV)",100,190);
	g.drawString("Press enter for charlie (WAV)",100,160);
	g.drawString("Press C to change music",100,210);
	g.drawString("Press B to burp (AIF)",100,240);
	g.drawString("Press + or - to change global volume of music", 100, 270);
	g.drawString("Press Y or X to change individual volume of music", 100, 300);
	g.drawString("Press N or M to change global volume of sound fx", 100, 330);
	g.setColor(Color.blue);
	g.drawString("Global Sound Volume Level: " + container.getSoundVolume(), 150, 390);
	g.drawString("Global Music Volume Level: " + container.getMusicVolume(), 150, 420);
	g.drawString("Current Music Volume Level: " + music.getVolume(), 150, 450);
}
 
開發者ID:j-dong,項目名稱:trashjam2017,代碼行數:21,代碼來源:SoundTest.java

示例12: render

import org.newdawn.slick.Color; //導入依賴的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.setAntiAlias(antialias);
		g.setLineWidth(50);
		g.setColor(Color.red);
		g.draw(path);
		
//		g.setColor(Color.red);
//		TextureImpl.bindNone();
//		g.setLineWidth(width);
//		g.setAntiAlias(true);
//		for (int i=0;i<10;i++) {
//			g.translate(35,35);
//			g.draw(polygon);
//		}
//		g.translate(-350,-350);
//		
//		g.setColor(Color.white);
//		g.setLineWidth(1);
//		g.setAntiAlias(false);
//		g.draw(polygon);
	}
 
開發者ID:IngSW-unipv,項目名稱:Progetto-C,代碼行數:25,代碼來源:LineRenderTest.java

示例13: render

import org.newdawn.slick.Color; //導入依賴的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:IngSW-unipv,項目名稱:Progetto-C,代碼行數:24,代碼來源:InputTest.java

示例14: render

import org.newdawn.slick.Color; //導入依賴的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.green);
    
    for(int i=0;i<shapes.size();i++) {
        g.fill((Shape)shapes.get(i));
    }
    g.fill(randomShape);
    g.setColor(Color.black);
    g.setAntiAlias(true);
    g.draw(randomShape);
    g.setAntiAlias(false);
    
    g.setColor(Color.white);
    g.drawString("keys", 10, 300);
    g.drawString("wasd - move rectangle", 10, 315);
    g.drawString("WASD - resize rectangle", 10, 330);
    g.drawString("tgfh - move rounded rectangle", 10, 345);
    g.drawString("TGFH - resize rounded rectangle", 10, 360);
    g.drawString("ry - resize corner radius on rounded rectangle", 10, 375);
    g.drawString("ikjl - move ellipse", 10, 390);
    g.drawString("IKJL - resize ellipse", 10, 405);
    g.drawString("Arrows - move circle", 10, 420);
    g.drawString("Page Up/Page Down - resize circle", 10, 435);
    g.drawString("numpad 8546 - move polygon", 10, 450);
}
 
開發者ID:j-dong,項目名稱:trashjam2017,代碼行數:29,代碼來源:ShapeTest.java

示例15: render

import org.newdawn.slick.Color; //導入依賴的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.gray);
	drawMarker(g, p1);
	drawMarker(g, p2);
	g.setColor(Color.red);
	drawMarker(g, c1);
	drawMarker(g, c2);
	
	g.setColor(Color.black);
	g.draw(curve);
	g.fill(curve);
	
	g.draw(poly);
	g.fill(poly);
}
 
開發者ID:j-dong,項目名稱:trashjam2017,代碼行數:19,代碼來源:CurveTest.java


注:本文中的org.newdawn.slick.Color類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。