This commit is contained in:
ThatGamerBlue
2021-02-04 06:13:57 +00:00
parent e2787027bd
commit df909d2a73
127 changed files with 649 additions and 2409 deletions

View File

@@ -1,34 +0,0 @@
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);
}
}

View File

@@ -1,58 +0,0 @@
package com.openosrs.client.util;
import java.util.ArrayList;
import java.util.List;
import javax.swing.Timer;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
public class DeferredDocumentChangedListener implements DocumentListener
{
private final Timer timer;
private final List<ChangeListener> listeners;
public DeferredDocumentChangedListener()
{
listeners = new ArrayList<>(25);
timer = new Timer(200, e -> fireStateChanged());
timer.setRepeats(false);
}
public void addChangeListener(ChangeListener listener)
{
listeners.add(listener);
}
private void fireStateChanged()
{
if (!listeners.isEmpty())
{
ChangeEvent evt = new ChangeEvent(this);
for (ChangeListener listener : listeners)
{
listener.stateChanged(evt);
}
}
}
@Override
public void insertUpdate(DocumentEvent e)
{
timer.restart();
}
@Override
public void removeUpdate(DocumentEvent e)
{
timer.restart();
}
@Override
public void changedUpdate(DocumentEvent e)
{
timer.restart();
}
}

View File

@@ -1,59 +0,0 @@
package com.openosrs.client.util;
import java.awt.Color;
import java.awt.image.BufferedImage;
import java.awt.image.WritableRaster;
import java.util.function.Predicate;
public class ImageUtil extends net.runelite.client.util.ImageUtil
{
/**
* Recolors pixels of the given image with the given color based on a given recolor condition
* predicate.
*
* @param image The image which should have its non-transparent pixels recolored.
* @param color The color with which to recolor pixels.
* @param recolorCondition The condition on which to recolor pixels with the given color.
* @return The given image with all pixels fulfilling the recolor condition predicate
* set to the given color.
*/
public static BufferedImage recolorImage(final BufferedImage image, final Color color, final Predicate<Color> recolorCondition)
{
final BufferedImage recoloredImage = new BufferedImage(image.getWidth(), image.getHeight(), BufferedImage.TYPE_INT_ARGB);
for (int x = 0; x < recoloredImage.getWidth(); x++)
{
for (int y = 0; y < recoloredImage.getHeight(); y++)
{
final Color pixelColor = new Color(image.getRGB(x, y), true);
if (!recolorCondition.test(pixelColor))
{
recoloredImage.setRGB(x, y, image.getRGB(x, y));
continue;
}
recoloredImage.setRGB(x, y, color.getRGB());
}
}
return recoloredImage;
}
public static BufferedImage recolorImage(BufferedImage image, final Color color)
{
int width = image.getWidth();
int height = image.getHeight();
WritableRaster raster = image.getRaster();
for (int xx = 0; xx < width; xx++)
{
for (int yy = 0; yy < height; yy++)
{
int[] pixels = raster.getPixel(xx, yy, (int[]) null);
pixels[0] = color.getRed();
pixels[1] = color.getGreen();
pixels[2] = color.getBlue();
raster.setPixel(xx, yy, pixels);
}
}
return image;
}
}