From 4f7a65a3bd2eaa0eeaaba15a0a795560095e108f Mon Sep 17 00:00:00 2001 From: Victor Date: Tue, 14 Jan 2014 22:02:11 +0200 Subject: [PATCH] Add drawPointer method --- src/com/annimon/influencexxii/DrawUtils.java | 22 ++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/com/annimon/influencexxii/DrawUtils.java b/src/com/annimon/influencexxii/DrawUtils.java index 2eb55d2..04238fc 100644 --- a/src/com/annimon/influencexxii/DrawUtils.java +++ b/src/com/annimon/influencexxii/DrawUtils.java @@ -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(); + } } \ No newline at end of file