Permalink
Browse files

Merge branch 'master' into production

Conflicts:
	AndroidManifest.xml
	src/com/mattfeury/saucillator/android/visuals/DrawableParameter.java
  • Loading branch information...
2 parents 05ae250 + 4d088ef commit 04bbb92cb8efa70be9264948ce34e8653dd5809e @mattfeury committed Mar 13, 2012
View
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
android:installLocation="auto"
- android:versionName="1.0.2 Alfredo" android:versionCode="6"
+ android:versionName="1.0.3 Alfredo" android:versionCode="7"
package="com.mattfeury.saucillator.android">
<uses-sdk android:targetSdkVersion="10" android:minSdkVersion="8"></uses-sdk><supports-screens
@@ -1,7 +1,8 @@
package com.mattfeury.saucillator.android.sound;
import java.io.Serializable;
-import java.text.DecimalFormat;
+
+import com.mattfeury.saucillator.android.utilities.Utilities;
/**
* Output approaches Input exponentially by rate.
@@ -11,10 +12,6 @@
*/
public class Lagger implements Serializable {
protected float in, out, rate = .025f;
-
- // When approaching 0, the lagger will never reach it as it will keep constantly dividing.
- // To fix this, we round to 5 decimal places so we can achieve a "zero" inevitably.
- protected static final DecimalFormat df = new DecimalFormat("#.00000");
public Lagger(float f, float approaches, float rate) {
this.in = approaches;
@@ -27,7 +24,7 @@ public float update() {
// Internally, in = out when rate is 1. This doesn't make sense logically though,
// so we expose the inverse to functionality.
out += (1f - rate) * (in - out);
- out = Float.valueOf(df.format(out));
+ out = Utilities.roundFloat(out, 5);
return out;
}
public void setRate(float rate) {
@@ -37,7 +37,16 @@ public static int unscale(float scaled, int lower, int higher) {
public static int unscale(float scaled, int higher) {
return (int)unscale(scaled, (float)higher);
}
-
+
+ public static float roundFloat(float f, int numDecimalPoints) {
+ for(int i=0; i < numDecimalPoints; i++) f *= 10f;
+ int rounded = Math.round(f);
+ float truncated = rounded;
+ for(int i=0; i < numDecimalPoints; i++) truncated /= 10f;
+
+ return f;
+ }
+
/**
* Returns a deep copy of the object, or null if the object cannot
* be serialized.
@@ -1,7 +1,5 @@
package com.mattfeury.saucillator.android.visuals;
-import java.text.DecimalFormat;
-
import com.mattfeury.saucillator.android.utilities.Utilities;
import android.graphics.*;
@@ -65,12 +63,6 @@ public String getFullName() {
return fullName;
}
- private float formatFloat(float f) {
- f = f * 100;
- int rounded = Math.round(f);
- return rounded / 100f;
- }
-
public void draw(Canvas canvas) {
if (enabled) {
lastX = (int) (this.x * canvas.getWidth());
@@ -79,8 +71,8 @@ public void draw(Canvas canvas) {
canvas.drawText(smallName, lastX, lastY + (radius / 4f), textPaint);
if (showCoords) {
- float xVal = formatFloat(Utilities.unscale(x, SauceView.controllerWidth, 1) * maxX);
- float yVal = formatFloat(Utilities.unscale(y, 1f - SauceView.padHeight, 1) * maxY);
+ float xVal = Utilities.roundFloat(Utilities.unscale(x, SauceView.controllerWidth, 1) * maxX, 2);
+ float yVal = Utilities.roundFloat(Utilities.unscale(y, 1f - SauceView.padHeight, 1) * maxY, 2);
String text = "(" + xParam + ": " + xVal + ", " + yParam + ": " + yVal + ")";
int textWidth = text.length() * (characterWidth+1),

0 comments on commit 04bbb92

Please sign in to comment.