Java Code Examples for org.newdawn.slick.Color#black()

The following examples show how to use org.newdawn.slick.Color#black() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UI.java    From opsu with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Draws a tab image and text centered at a location.
 * @param x the center x coordinate
 * @param y the center y coordinate
 * @param text the text to draw inside the tab
 * @param selected whether the tab is selected (white) or not (red)
 * @param isHover whether to include a hover effect (unselected only)
 */
public static void drawTab(float x, float y, String text, boolean selected, boolean isHover) {
	Image tabImage = GameImage.MENU_TAB.getImage();
	float tabTextX = x - (Fonts.MEDIUM.getWidth(text) / 2);
	float tabTextY = y - (tabImage.getHeight() / 2);
	Color filter, textColor;
	if (selected) {
		filter = Color.white;
		textColor = Color.black;
	} else {
		filter = (isHover) ? Colors.RED_HOVER : Color.red;
		textColor = Color.white;
	}
	tabImage.drawCentered(x, y, filter);
	Fonts.MEDIUM.drawString(tabTextX, tabTextY, text, textColor);
}
 
Example 2
Source File: BubNotifState.java    From opsu-dance with GNU General Public License v3.0 5 votes vote down vote up
private Notification(String message, Color borderColor) {
	this.message = message;
	recalculateDimensions();
	this.targetBorderColor = borderColor;
	this.borderColor = new Color(borderColor);
	this.textColor = new Color(Color.white);
	this.bgcol = new Color(Color.black);
	this.y = baseLine - height;
	this.baseY = this.y;
}
 
Example 3
Source File: RendererSlick.java    From nullpomino with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Block colorIDDepending onSlickUseColorObjects created or received
 * @param colorID Block colorID
 * @return SlickUseColorObject
 */
public static Color getColorByID(int colorID) {
	switch(colorID) {
	case Block.BLOCK_COLOR_GRAY:   return new Color(Color.gray);
	case Block.BLOCK_COLOR_RED:    return new Color(Color.red);
	case Block.BLOCK_COLOR_ORANGE: return new Color(255,128,0);
	case Block.BLOCK_COLOR_YELLOW: return new Color(Color.yellow);
	case Block.BLOCK_COLOR_GREEN:  return new Color(Color.green);
	case Block.BLOCK_COLOR_CYAN:   return new Color(Color.cyan);
	case Block.BLOCK_COLOR_BLUE:   return new Color(Color.blue);
	case Block.BLOCK_COLOR_PURPLE: return new Color(Color.magenta);
	}
	return new Color(Color.black);
}
 
Example 4
Source File: Gradient.java    From slick2d-maven with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Get the intepolated colour at the given location on the gradient
 * 
 * @param p The point of the gradient (0 >= n >= 1)
 * @return The interpolated colour at the given location
 */
public Color getColorAt(float p) {
	if (p <= 0) {
		return ((Step) steps.get(0)).col;
	}
	if (p > 1) {
		return ((Step) steps.get(steps.size()-1)).col;
	}
	
	for (int i=1;i<steps.size();i++) {
		Step prev = ((Step) steps.get(i-1));
		Step current = ((Step) steps.get(i));
		
		if (p <= current.location) {
			float dis = current.location - prev.location;
			p -= prev.location;
			float v = p / dis;
			
			Color c = new Color(1,1,1,1);
			c.a = (prev.col.a * (1 - v)) + (current.col.a * (v));
			c.r = (prev.col.r * (1 - v)) + (current.col.r * (v));
			c.g = (prev.col.g * (1 - v)) + (current.col.g * (v));
			c.b = (prev.col.b * (1 - v)) + (current.col.b * (v));
			
			return c;
		}
	}

	// shouldn't ever happen
	return Color.black;
}
 
Example 5
Source File: GradientFill.java    From slick2d-maven with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Get the colour that should be applied at the specified location
 * 
 * @param x The x coordinate of the point being coloured 
 * @param y The y coordinate of the point being coloured
 * @return The colour that should be applied based on the control points of this gradient
 */
public Color colorAt(float x, float y) {
	float dx1 = end.getX() - start.getX();
	float dy1 = end.getY() - start.getY();
	
	float dx2 = -dy1;
	float dy2 = dx1;
	float denom = (dy2 * dx1) - (dx2 * dy1);
	
	if (denom == 0) {
		return Color.black;
	}
	
	float ua = (dx2 * (start.getY() - y)) - (dy2 * (start.getX() - x));
	ua /= denom;
	float ub = (dx1 * (start.getY() - y)) - (dy1 * (start.getX() - x));
	ub /= denom;
	float u = ua;
	if (u < 0) {
		u = 0;
	} 
	if (u > 1) {
		u = 1;
	}
	float v = 1 - u;

	// u is the proportion down the line we are
	Color col = new Color(1,1,1,1);
	col.r = (u * endCol.r) + (v * startCol.r);
	col.b = (u * endCol.b) + (v * startCol.b);
	col.g = (u * endCol.g) + (v * startCol.g);
	col.a = (u * endCol.a) + (v * startCol.a);
	
	return col;
}
 
Example 6
Source File: ImageReadTest.java    From slick2d-maven with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * @see org.newdawn.slick.BasicGame#update(org.newdawn.slick.GameContainer, int)
 */
public void update(GameContainer container, int delta) {
	int mx = container.getInput().getMouseX();
	int my = container.getInput().getMouseY();
	
	if ((mx >= 100) && (my >= 100) && (mx < 200) && (my < 200)) {
		read[4] = image.getColor(mx-100,my-100);
	} else {
		read[4] = Color.black;
	}
	
	read[5] = g.getPixel(mx, my);
}
 
Example 7
Source File: BarNotificationState.java    From opsu-dance with GNU General Public License v3.0 4 votes vote down vote up
public BarNotificationState() {
	this.bgcol = new Color(Color.black);
	this.textCol = new Color(Color.white);
	this.timeShown = TOTAL_TIME;
}
 
Example 8
Source File: RendererSlick.java    From nullpomino with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/**
 * Each frame Drawing process of the first
 * @param engine GameEngine
 * @param playerID Player ID
 */
@Override
public void renderFirst(GameEngine engine, int playerID) {
	if(graphics == null) return;

	if(engine.playerID == 0) {
		// Background
		if(engine.owner.menuOnly) {
			graphics.setColor(Color.white);
			graphics.drawImage(ResourceHolderSlick.imgMenu, 0, 0);
		} else {
			int bg = engine.owner.backgroundStatus.bg;
			if(engine.owner.backgroundStatus.fadesw && !heavyeffect) {
				bg = engine.owner.backgroundStatus.fadebg;
			}

			if((ResourceHolderSlick.imgPlayBG != null) && (bg >= 0) && (bg < ResourceHolderSlick.imgPlayBG.length) && (showbg == true)) {
				graphics.setColor(Color.white);
				graphics.drawImage(ResourceHolderSlick.imgPlayBG[bg], 0, 0);

				if(engine.owner.backgroundStatus.fadesw && heavyeffect) {
					Color filter = new Color(Color.black);
					if(engine.owner.backgroundStatus.fadestat == false) {
						filter.a = (float) engine.owner.backgroundStatus.fadecount / 100;
					} else {
						filter.a = (float) (100 - engine.owner.backgroundStatus.fadecount) / 100;
					}
					graphics.setColor(filter);
					graphics.fillRect(0, 0, 640, 480);
				}
			} else {
				//graphics.setColor(Color.black);
				//graphics.fillRect(0, 0, 640, 480);
			}
		}
	}

	// NEXTなど
	if(!engine.owner.menuOnly && engine.isVisible) {
		int offsetX = getFieldDisplayPositionX(engine, playerID);
		int offsetY = getFieldDisplayPositionY(engine, playerID);

		if((engine.displaysize != -1)) {
			drawNext(offsetX, offsetY, engine);
			drawFrame(offsetX, offsetY + 48, engine, engine.displaysize);
			drawField(offsetX + 4, offsetY + 52, engine, engine.displaysize);
		} else {
			drawFrame(offsetX, offsetY, engine, -1);
			drawField(offsetX + 4, offsetY + 4, engine, -1);
		}
	}
}
 
Example 9
Source File: FadeOutTransition.java    From slick2d-maven with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/**
 * Create a new fade out transition
 */
public FadeOutTransition() {
	this(Color.black, 500);
}
 
Example 10
Source File: FadeInTransition.java    From slick2d-maven with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/**
 * Create a new fade in transition
 */
public FadeInTransition() {
	this(Color.black, 500);
}
 
Example 11
Source File: EasedFadeOutTransition.java    From opsu with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Create a new eased fade out transition.
 */
public EasedFadeOutTransition() { this(Color.black, 500, AnimationEquation.OUT_QUART); }
 
Example 12
Source File: DelayedFadeOutTransition.java    From opsu with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Create a new delayed fade out transition.
 */
public DelayedFadeOutTransition() { this(Color.black, 500, 0); }