linked basic visualizer with mirror visualizer

This commit is contained in:
Harrison Deng 2017-09-22 15:28:59 -05:00
parent 4f58a43b79
commit b4e7f97f5b
2 changed files with 12 additions and 2 deletions

View File

@ -30,6 +30,7 @@ public class BasicVisualizer extends VisualizerCore {
public BasicVisualizer() { public BasicVisualizer() {
super(Gdx.graphics.getWidth(), Gdx.graphics.getHeight()/2, 0, 0); super(Gdx.graphics.getWidth(), Gdx.graphics.getHeight()/2, 0, 0);
mirrors = new Array<>();
barHeightMultiplier = Gdx.graphics.getHeight()*0.01f; barHeightMultiplier = Gdx.graphics.getHeight()*0.01f;
pixmap = new Pixmap(2, 2, Format.RGBA8888); pixmap = new Pixmap(2, 2, Format.RGBA8888);
pixmap.setColor(Color.WHITE); pixmap.setColor(Color.WHITE);
@ -79,6 +80,10 @@ public class BasicVisualizer extends VisualizerCore {
bars[i].setSize(barWidth, avg/(smoothRange*2)); bars[i].setSize(barWidth, avg/(smoothRange*2));
bars[i].draw(batch); bars[i].draw(batch);
} }
for (int i = 0; i < mirrors.size; i++) {
mirrors.get(i).render(bars, batch);
}
} }
super.render(batch, parentAlpha); super.render(batch, parentAlpha);
} }
@ -98,7 +103,7 @@ public class BasicVisualizer extends VisualizerCore {
} }
public void updatePositionInfo() { public void updatePositionInfo() {
int barSpace; int barSpace = 0;
angleRot.set(MathUtils.cosDeg(rotation), MathUtils.sinDeg(rotation)); angleRot.set(MathUtils.cosDeg(rotation), MathUtils.sinDeg(rotation));
barWidth = MathUtils.ceil((float) width/(float) barCount); barWidth = MathUtils.ceil((float) width/(float) barCount);
@ -114,6 +119,9 @@ public class BasicVisualizer extends VisualizerCore {
} }
bars[i].setPosition(xPos + barSpace*angleRot.x, yPos + barSpace*angleRot.y); bars[i].setPosition(xPos + barSpace*angleRot.x, yPos + barSpace*angleRot.y);
} }
for (int i = 0; i < mirrors.size; i++) {
mirrors.get(i).updatePositioning(bars, barSpace);
}
} }
public void setColor(Color color) { public void setColor(Color color) {

View File

@ -1,5 +1,6 @@
package zero1hd.rhythmbullet.audio.visualizer; package zero1hd.rhythmbullet.audio.visualizer;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.graphics.g2d.Sprite; import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.math.MathUtils; import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.math.Vector2;
@ -21,9 +22,10 @@ public class MirrorVisualizer {
} }
} }
protected void updateSpriteSize(Sprite[] sprites) { protected void render(Sprite[] sprites, Batch batch) {
for (int i = 0; i < sprites.length; i++) { for (int i = 0; i < sprites.length; i++) {
bars[i].setSize(bars[i].getWidth(), sprites[i].getHeight()); bars[i].setSize(bars[i].getWidth(), sprites[i].getHeight());
bars[i].draw(batch);
} }
} }