Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions src/libnoiseforjava/NoiseGen.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2003, 2004 Jason Bevins (original libnoise code)
* Copyright � 2010 Thomas J. Hodge (java port of libnoise)
* Copyright � 2010 Thomas J. Hodge (java port of libnoise)
*
* This file is part of libnoiseforjava.
*
Expand Down Expand Up @@ -60,6 +60,8 @@ public enum NoiseQuality
static final int SEED_NOISE_GEN = 1013;
static final int SHIFT_NOISE_GEN = 8;

private static final VectorTable vectorTable = new VectorTable();

public static double GradientCoherentNoise3D (double x, double y, double z, int seed,
NoiseQuality noiseQuality)
{
Expand Down Expand Up @@ -121,16 +123,13 @@ public static double GradientCoherentNoise3D (double x, double y, double z, int
public static double GradientNoise3D (double fx, double fy, double fz, int ix,
int iy, int iz, int seed)
{

VectorTable vectorTable = new VectorTable();
// Randomly generate a gradient vector given the integer coordinates of the
// input value. This implementation generates a random number and uses it
// as an index into a normalized-vector lookup table.
int vectorIndex = (X_NOISE_GEN * ix
+ Y_NOISE_GEN * iy
+ Z_NOISE_GEN * iz
+ SEED_NOISE_GEN * seed)
& 0xffffffff;
+ SEED_NOISE_GEN * seed);

vectorIndex ^= (vectorIndex >> SHIFT_NOISE_GEN);
vectorIndex &= 0xff;
Expand Down
105 changes: 0 additions & 105 deletions src/libnoiseforjava/util/ColorCafe.java

This file was deleted.

18 changes: 10 additions & 8 deletions src/libnoiseforjava/util/GradientColor.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2003, 2004 Jason Bevins (original libnoise code)
* Copyright � 2010 Thomas J. Hodge (java port of libnoise)
* Copyright � 2010 Thomas J. Hodge (java port of libnoise)
*
* This file is part of libnoiseforjava.
*
Expand Down Expand Up @@ -28,6 +28,8 @@
import libnoiseforjava.Misc;
import libnoiseforjava.exception.ExceptionInvalidParam;

import java.awt.*;

public class GradientColor
{
/// Defines a color gradient.
Expand Down Expand Up @@ -63,12 +65,12 @@ public class GradientColor

GradientPoint [] gradientPoints;
int gradientPointCount;
ColorCafe workingColor;
Color workingColor;

public GradientColor()
{
gradientPoints = new GradientPoint[1];
gradientPoints[0] = new GradientPoint(0.0, new ColorCafe(0, 0, 0, 0));
gradientPoints[0] = new GradientPoint(0.0, new Color(0, 0, 0, 0));
}

/// Adds a gradient point to this gradient object.
Expand All @@ -81,7 +83,7 @@ public GradientColor()
/// @throw noise::ExceptionInvalidParam See the precondition.
///
/// It does not matter which order these gradient points are added.
public void addGradientPoint (double gradientPos, ColorCafe gradientColor) throws ExceptionInvalidParam
public void addGradientPoint (double gradientPos, Color gradientColor) throws ExceptionInvalidParam
{
// Find the insertion point for the new gradient point and insert the new
// gradient point at that insertion point. The gradient point array will
Expand Down Expand Up @@ -137,7 +139,7 @@ public int findInsertionPos (double gradientPos) throws ExceptionInvalidParam
/// @param gradientPos The specified position.
///
/// @returns The color at that position.
public ColorCafe getColor (double gradientPos)
public Color getColor (double gradientPos)
{
assert (gradientPointCount >= 2);

Expand Down Expand Up @@ -172,8 +174,8 @@ public ColorCafe getColor (double gradientPos)
double alpha = (gradientPos - input0) / (input1 - input0);

// Now perform the linear interpolation given the alpha value.
ColorCafe color0 = gradientPoints[index0].color;
ColorCafe color1 = gradientPoints[index1].color;
Color color0 = gradientPoints[index0].color;
Color color1 = gradientPoints[index1].color;
workingColor = MiscUtilities.linearInterpColor (color0, color1, (float)alpha);
return workingColor;
}
Expand All @@ -194,7 +196,7 @@ public ColorCafe getColor (double gradientPos)
/// must be sorted by the position, the new gradient point should be
/// inserted at the position in which the order is still preserved.
public void insertAtPos (int insertionPos, double gradientPos,
ColorCafe gradientColor)
Color gradientColor)
{
// Make room for the new gradient point at the specified insertion position
// within the gradient point array. The insertion position is determined by
Expand Down
14 changes: 8 additions & 6 deletions src/libnoiseforjava/util/GradientPoint.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2003, 2004 Jason Bevins (original libnoise code)
* Copyright � 2010 Thomas J. Hodge (java port of libnoise)
* Copyright � 2010 Thomas J. Hodge (java port of libnoise)
*
* This file is part of libnoiseforjava.
*
Expand All @@ -25,6 +25,8 @@

package libnoiseforjava.util;

import java.awt.*;

public class GradientPoint
{
/// Defines a point used to build a color gradient.
Expand All @@ -38,15 +40,15 @@ public class GradientPoint
/// objects.

double position;
ColorCafe color;
Color color;

public GradientPoint()
{
position = 0.0;
color = new ColorCafe(0,0,0,0);
color = new Color(0,0,0,0);
}

public GradientPoint(double position, ColorCafe color)
public GradientPoint(double position, Color color)
{
this.position = position;
this.color = color;
Expand All @@ -57,7 +59,7 @@ public double getPosition()
return position;
}

public ColorCafe getColor()
public Color getColor()
{
return color;
}
Expand All @@ -67,7 +69,7 @@ public void setPosition(double position)
this.position = position;
}

public void setColor(ColorCafe color)
public void setColor(Color color)
{
this.color = color;
}
Expand Down
24 changes: 13 additions & 11 deletions src/libnoiseforjava/util/ImageCafe.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2003, 2004 Jason Bevins (original libnoise code)
* Copyright � 2010 Thomas J. Hodge (java port of libnoise)
* Copyright � 2010 Thomas J. Hodge (java port of libnoise)
*
* This file is part of libnoiseforjava.
*
Expand All @@ -27,14 +27,16 @@

import libnoiseforjava.exception.ExceptionInvalidParam;

import java.awt.*;

public class ImageCafe
{

/// Implements an image, a 2-dimensional array of color values.
///
/// An image can be used to store a color texture.
///
/// These color values are of type ColorCafe.
/// These color values are of type Color.
///
/// The size (width and height) of the image can be specified during
/// object construction.
Expand All @@ -55,22 +57,22 @@ public class ImageCafe
///

/// The Color value used for all positions outside of the image.
ColorCafe borderValue;
Color borderValue;

/// The current height of the image.
int height;

/// The current width of the image.
int width;

/// Array of ColorCafes holding the color values
ColorCafe [][] imageCafeColors;
/// Array of Colors holding the color values
Color [][] imageCafeColors;

public ImageCafe (int width, int height) throws ExceptionInvalidParam
{
setSize (width, height);
borderValue = new ColorCafe (0, 0, 0, 0);
imageCafeColors = new ColorCafe[width][height];
borderValue = new Color (0, 0, 0, 0);
imageCafeColors = new Color[width][height];
}

/// Returns a color value from the specified position in the image.
Expand All @@ -82,7 +84,7 @@ public ImageCafe (int width, int height) throws ExceptionInvalidParam
///
/// This method returns the border value if the coordinates exist
/// outside of the image.
public ColorCafe getValue (int x, int y)
public Color getValue (int x, int y)
{
if (x >= 0 && x < width && y >= 0 && y < height)
return imageCafeColors[x][y];
Expand Down Expand Up @@ -122,7 +124,7 @@ public void setSize (int width, int height) throws ExceptionInvalidParam
///
/// This method does nothing if the image is empty or the position is
/// outside the bounds of the image.
public void setValue (int x, int y, ColorCafe value)
public void setValue (int x, int y, Color value)
{
if (x >= 0 && x < width && y >= 0 && y < height)
this.imageCafeColors[x][y] = value;
Expand All @@ -137,7 +139,7 @@ public void setValue (int x, int y, ColorCafe value)
///
/// All positions outside of the image are assumed to have a common
/// color value known as the <i>border value</i>.
public ColorCafe getBorderValue ()
public Color getBorderValue ()
{
return borderValue;
}
Expand Down Expand Up @@ -166,7 +168,7 @@ public int getWidth ()
///
/// All positions outside of the image are assumed to have a common
/// color value known as the <i>border value</i>.
public void setBorderValue (ColorCafe borderValue)
public void setBorderValue (Color borderValue)
{
this.borderValue = borderValue;
}
Expand Down
16 changes: 9 additions & 7 deletions src/libnoiseforjava/util/MiscUtilities.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2003, 2004 Jason Bevins (original libnoise code)
* Copyright � 2010 Thomas J. Hodge (java port of libnoise)
* Copyright � 2010 Thomas J. Hodge (java port of libnoise)
*
* This file is part of libnoiseforjava.
*
Expand All @@ -25,6 +25,8 @@

package libnoiseforjava.util;

import java.awt.*;

public class MiscUtilities
{

Expand All @@ -37,14 +39,14 @@ public static short blendChannel (int red, int red2, float alpha)
}

// Performs linear interpolation between two colors
public static ColorCafe linearInterpColor (ColorCafe color0, ColorCafe color1,
public static Color linearInterpColor (Color color0, Color color1,
float alpha)
{
ColorCafe color = new ColorCafe(
blendChannel (color0.red, color1.red, alpha),
blendChannel (color0.green, color1.green, alpha),
blendChannel (color0.blue, color1.blue, alpha),
blendChannel (color0.alpha, color1.alpha, alpha)
Color color = new Color(
blendChannel (color0.getRed(), color1.getRed(), alpha),
blendChannel (color0.getGreen(), color1.getGreen(), alpha),
blendChannel (color0.getBlue(), color1.getBlue(), alpha),
blendChannel (color0.getAlpha(), color1.getAlpha(), alpha)
);
return color;
}
Expand Down
Loading