home *** CD-ROM | disk | FTP | other *** search
- import java.awt.Color;
- import java.awt.Point;
- import java.awt.Rectangle;
- import java.util.StringTokenizer;
-
- public final class Misc {
- public static final Color InterpolateColour(Color start, Color end, long mul, long div) {
- if (mul < 0L) {
- return start;
- } else if (mul >= div) {
- return end;
- } else {
- int red = (int)((long)start.getRed() + (long)(end.getRed() - start.getRed()) * mul / div);
- int green = (int)((long)start.getGreen() + (long)(end.getGreen() - start.getGreen()) * mul / div);
- int blue = (int)((long)start.getBlue() + (long)(end.getBlue() - start.getBlue()) * mul / div);
- return new Color(red, green, blue);
- }
- }
-
- public static final int InterpolateInt(int start, int end, long mul, long div) {
- if (mul < 0L) {
- return start;
- } else {
- return mul >= div ? end : (int)((long)start + (long)(end - start) * mul / div);
- }
- }
-
- public static final Point InterpolatePoint(Point start, Point end, long mul, long div) {
- if (mul < 0L) {
- return start;
- } else if (mul >= div) {
- return end;
- } else {
- int x = (int)((long)start.x + (long)(end.x - start.x) * mul / div);
- int y = (int)((long)start.y + (long)(end.y - start.y) * mul / div);
- return new Point(x, y);
- }
- }
-
- public static final Color initColour(String param) {
- StringTokenizer st = new StringTokenizer(param, ",");
- int r = 0;
- int g = 0;
- int b = 0;
-
- try {
- r = Integer.valueOf(st.nextToken());
- g = Integer.valueOf(st.nextToken());
- b = Integer.valueOf(st.nextToken());
- } catch (Exception var7) {
- }
-
- return new Color(r, g, b);
- }
-
- public static final Rectangle InterpolateRectangle(Rectangle start, Rectangle end, long mul, long div) {
- if (mul < 0L) {
- return start;
- } else if (mul >= div) {
- return end;
- } else {
- int x = (int)((long)start.x + (long)(end.x - start.x) * mul / div);
- int y = (int)((long)start.y + (long)(end.y - start.y) * mul / div);
- int width = (int)((long)start.width + (long)(end.width - start.width) * mul / div);
- int height = (int)((long)start.height + (long)(end.height - start.height) * mul / div);
- return new Rectangle(x, y, width, height);
- }
- }
- }
-