Add drawPointer method

This commit is contained in:
Victor 2014-01-14 22:02:11 +02:00
parent 7fcdcd086e
commit 4f7a65a3bd

View File

@ -1,6 +1,8 @@
package com.annimon.influencexxii;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType;
import com.badlogic.gdx.math.MathUtils;
/**
@ -9,6 +11,11 @@ import com.badlogic.gdx.math.MathUtils;
*
*/
public class DrawUtils {
private static final Color[][] pointerColorByMode = {
{ new Color(0f, 1f, 0f, 0f), Color.GREEN },
{ new Color(1f, 0f, 0f, 0f), Color.RED }
};
public static Color random2Color(int min, int max) {
float r = MathUtils.random(min, max) / 255f;;
@ -16,4 +23,19 @@ public class DrawUtils {
float b = MathUtils.random(min, max) / 255f;;
return new Color(r, g, b, 1f);
}
public static void drawPointer(ShapeRenderer renderer, int x, int y, int w, int h, int mode) {
renderer.begin(ShapeType.Line);
Color col1 = pointerColorByMode[mode][0];
Color col2 = pointerColorByMode[mode][1];
// Vertical
final int h2 = h / 2;
renderer.line(x, 0, x, h2, col1, col2);
renderer.line(x, h2, x, h, col2, col1);
// Horizontal
final int w2 = w / 2;
renderer.line(0, y, w2, y, col1, col2);
renderer.line(w2, y, w, y, col2, col1);
renderer.end();
}
}