Skip to content

Commit

Permalink
Merge pull request #10 from irisu/master
Browse files Browse the repository at this point in the history
Removed interpolator and changed colours
  • Loading branch information
broady committed Jan 31, 2014
2 parents 7637340 + fe6da54 commit e30409d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,12 @@ public class HeatmapsDemoActivity extends BaseDemoActivity {
Color.argb(0, 0, 255, 255),// transparent
Color.argb(255 / 3 * 2, 0, 255, 255),
Color.rgb(0, 191, 255),
Color.rgb(0, 127, 255),
Color.rgb(0, 63, 255),
Color.rgb(0, 0, 255),
Color.rgb(0, 0, 223),
Color.rgb(0, 0, 191),
Color.rgb(0, 0, 159),
Color.rgb(0, 0, 127),
Color.rgb(63, 0, 91),
Color.rgb(127, 0, 63),
Color.rgb(191, 0, 31),
Color.rgb(255, 0, 0)
};

public static final float[] ALT_HEATMAP_GRADIENT_START_POINTS = {
0.0f, 0.05f, 0.1f, 0.2f, 0.25f, 0.3f, 0.35f, 0.4f, 0.5f, 0.6f, 0.7f, 0.8f, 0.9f, 1.0f
0.0f, 0.10f, 0.20f, 0.60f, 1.0f
};

public static final Gradient ALT_HEATMAP_GRADIENT = new Gradient(ALT_HEATMAP_GRADIENT_COLORS, ALT_HEATMAP_GRADIENT_START_POINTS);
Expand Down
25 changes: 2 additions & 23 deletions library/src/com/google/maps/android/heatmaps/Gradient.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,13 @@ public ColorInterval(int color1, int color2, float duration) {
}
}

private static final int DEFAULT_COLOR_MAP_SIZE = 1000;
public static final int DEFAULT_COLOR_MAP_SIZE = 1000;

/**
* Size of a color map for the heatmap
*/
public final int mColorMapSize;

/**
* An interpolator to define the rate of change between defined mColors.
*/
public Interpolator mInterpolator;

/**
* The mColors to be used in the gradient
*/
Expand Down Expand Up @@ -73,21 +68,6 @@ public Gradient(int[] colors, float[] startPoints) {
* @param colorMapSize The size of the colorMap to be generated by the Gradient
*/
public Gradient(int[] colors, float[] startPoints, int colorMapSize) {
this(colors, startPoints, colorMapSize, new LinearInterpolator());
}

/**
* Creates a Gradient with the given mColors and starting points which creates a colorMap of given size,
* and interpolates between them with the given interpolator
* The mColors and starting points are given as parallel arrays.
* @param colors The mColors to be used in the gradient
* @param startPoints The starting point for each color, given as a percentage of the maximum intensity
* This is given as an array of floats with values in the interval [0,1]
* @param colorMapSize The size of the colorMap to be generated by the Gradient
* @param interpolator An interpolator to adjust the rate of change between defined mColors
* E.g. new DecelerateInterpolator(2.0f);
*/
public Gradient(int[] colors, float[] startPoints, int colorMapSize, Interpolator interpolator) {
if (colors.length != startPoints.length) {
throw new IllegalArgumentException("colors and startPoints should be same length");
} else if (colors.length == 0) {
Expand All @@ -98,7 +78,6 @@ public Gradient(int[] colors, float[] startPoints, int colorMapSize, Interpolato
throw new IllegalArgumentException("startPoints should be in increasing order");
}
}
mInterpolator = interpolator;
mColorMapSize = colorMapSize;
mColors = new int[colors.length];
mStartPoints = new float[startPoints.length];
Expand Down Expand Up @@ -146,7 +125,7 @@ public int[] generateColorMap(double opacity) {
start = i;
}
float ratio = (i - start) / interval.duration;
colorMap[i] = interpolateColor(interval.color1, interval.color2, mInterpolator.getInterpolation(ratio));
colorMap[i] = interpolateColor(interval.color1, interval.color2, ratio);
}
if (opacity != 1) {
for (int i = 0; i < mColorMapSize; i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public class HeatmapTileProvider implements TileProvider {
* These should be a sorted array of floats in the interval [0, 1].
*/
public static final float[] DEFAULT_GRADIENT_START_POINTS = {
0.1f, 1f
0.2f, 1f
};

/**
Expand Down

0 comments on commit e30409d

Please sign in to comment.