rl-client: add ColorUtil/OverlayUtil
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
package com.openosrs.client.ui.overlay;
|
||||
|
||||
import java.awt.BasicStroke;
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Polygon;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.Perspective;
|
||||
import net.runelite.api.coords.LocalPoint;
|
||||
import net.runelite.api.coords.WorldPoint;
|
||||
|
||||
public class OverlayUtil extends net.runelite.client.ui.overlay.OverlayUtil
|
||||
{
|
||||
public static void drawTiles(Graphics2D graphics, Client client, WorldPoint point, WorldPoint playerPoint, Color color, int strokeWidth, int outlineAlpha, int fillAlpha)
|
||||
{
|
||||
if (point.distanceTo(playerPoint) >= 32)
|
||||
{
|
||||
return;
|
||||
}
|
||||
LocalPoint lp = LocalPoint.fromWorld(client, point);
|
||||
if (lp == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Polygon poly = Perspective.getCanvasTilePoly(client, lp);
|
||||
if (poly == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
drawStrokeAndFillPoly(graphics, color, strokeWidth, outlineAlpha, fillAlpha, poly);
|
||||
}
|
||||
|
||||
public static void drawStrokeAndFillPoly(Graphics2D graphics, Color color, int strokeWidth, int outlineAlpha, int fillAlpha, Polygon poly)
|
||||
{
|
||||
graphics.setColor(new Color(color.getRed(), color.getGreen(), color.getBlue(), outlineAlpha));
|
||||
graphics.setStroke(new BasicStroke(strokeWidth));
|
||||
graphics.draw(poly);
|
||||
graphics.setColor(new Color(color.getRed(), color.getGreen(), color.getBlue(), fillAlpha));
|
||||
graphics.fill(poly);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.openosrs.client.util;
|
||||
|
||||
import java.awt.Color;
|
||||
|
||||
public class ColorUtil extends net.runelite.client.util.ColorUtil
|
||||
{
|
||||
/**
|
||||
* Modifies the alpha component on a Color
|
||||
*
|
||||
* @param color The color to set the alpha value on
|
||||
* @param alpha The alpha value to set on the color
|
||||
* @return color
|
||||
*/
|
||||
public static int setAlphaComponent(Color color, int alpha)
|
||||
{
|
||||
return setAlphaComponent(color.getRGB(), alpha);
|
||||
}
|
||||
|
||||
/**
|
||||
* Modifies the alpha component on a Color
|
||||
*
|
||||
* @param color The color to set the alpha value on
|
||||
* @param alpha The alpha value to set on the color
|
||||
* @return color
|
||||
*/
|
||||
public static int setAlphaComponent(int color, int alpha)
|
||||
{
|
||||
if (alpha < 0 || alpha > 255)
|
||||
{
|
||||
throw new IllegalArgumentException("alpha must be between 0 and 255.");
|
||||
}
|
||||
return (color & 0x00ffffff) | (alpha << 24);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user