basic visualizer with reverse function
This commit is contained in:
parent
fdafba2127
commit
411ac59f6f
@ -27,6 +27,7 @@ public class BasicVisualizer extends VisualizerCore {
|
||||
private Vector2 angleRot;
|
||||
private boolean flip;
|
||||
private Array<MirrorVisualizer> mirrors;
|
||||
private boolean reverse;
|
||||
|
||||
public BasicVisualizer() {
|
||||
super(Gdx.graphics.getWidth(), Gdx.graphics.getHeight()/2, 0, 0);
|
||||
@ -117,7 +118,11 @@ public class BasicVisualizer extends VisualizerCore {
|
||||
} else {
|
||||
bars[i].setRotation(rotation);
|
||||
}
|
||||
bars[i].setPosition(xPos + barSpace*angleRot.x, yPos + barSpace*angleRot.y);
|
||||
if (reverse) {
|
||||
bars[bars.length-i-1].setPosition(xPos + barSpace*angleRot.x, yPos + barSpace*angleRot.y);
|
||||
} else {
|
||||
bars[i].setPosition(xPos + barSpace*angleRot.x, yPos + barSpace*angleRot.y);
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < mirrors.size; i++) {
|
||||
mirrors.get(i).position(barWidth, spaceBetweenBars);
|
||||
@ -149,7 +154,7 @@ public class BasicVisualizer extends VisualizerCore {
|
||||
}
|
||||
|
||||
public void addMirrorVisualizer(MirrorVisualizer mirror) {
|
||||
mirror.setup(bars, barWidth, spaceBetweenBars, (int) width);
|
||||
mirror.setup(bars, xPos, yPos, rotation);
|
||||
mirrors.add(mirror);
|
||||
}
|
||||
|
||||
@ -160,4 +165,16 @@ public class BasicVisualizer extends VisualizerCore {
|
||||
public void setSpaceBetweenBars(int spaceBetweenBars) {
|
||||
this.spaceBetweenBars = spaceBetweenBars;
|
||||
}
|
||||
|
||||
public int getBarWidth() {
|
||||
return barWidth;
|
||||
}
|
||||
|
||||
public void reverse() {
|
||||
reverse = reverse ? false : true;
|
||||
}
|
||||
|
||||
public boolean isReversed() {
|
||||
return reverse;
|
||||
}
|
||||
}
|
||||
|
6
core/src/zero1hd/rhythmbullet/audio/visualizer/MirrorVisualizer.java
Normal file → Executable file
6
core/src/zero1hd/rhythmbullet/audio/visualizer/MirrorVisualizer.java
Normal file → Executable file
@ -16,10 +16,10 @@ public class MirrorVisualizer {
|
||||
rectCoordRot = new Vector2();
|
||||
}
|
||||
|
||||
protected void setup(Sprite[] bars, int xPos, int yPos, float rotation) {
|
||||
protected void setup(Sprite[] bars, float xPos, float yPos, float rotation) {
|
||||
this.bars = new Sprite[bars.length];
|
||||
this.xPos = xPos;
|
||||
this.yPos = yPos;
|
||||
this.xPos = (int) xPos;
|
||||
this.yPos = (int) yPos;
|
||||
this.rotation = rotation;
|
||||
rectCoordRot.set(MathUtils.cosDeg(rotation), MathUtils.sinDeg(rotation));
|
||||
|
||||
|
@ -13,28 +13,32 @@ import zero1hd.rhythmbullet.audio.visualizer.MirrorVisualizer;
|
||||
import zero1hd.rhythmbullet.graphics.meshes.TitleBarMesh;
|
||||
|
||||
public class TitleBarVisualizer extends Group implements Disposable {
|
||||
private Visualizer hvisual;
|
||||
private Visualizer visual;
|
||||
private MirrorVisualizer visual2;
|
||||
private TitleBarMesh background;
|
||||
|
||||
public TitleBarVisualizer(AssetManager assets, OrthographicCamera camera) {
|
||||
if (assets == null) throw new NullPointerException("TitleBarVisualizer requires assets manager... ITS NULL YOU FOOL");
|
||||
setSize((float) Math.sqrt(Gdx.graphics.getWidth()*Gdx.graphics.getWidth() + Gdx.graphics.getHeight()*Gdx.graphics.getHeight()), Gdx.graphics.getHeight()*0.3f);
|
||||
hvisual = new Visualizer();
|
||||
addActor(hvisual);
|
||||
visual = new Visualizer();
|
||||
visual.getVis().setSpaceBetweenBars(visual.getVis().getBarWidth()-3);
|
||||
addActor(visual);
|
||||
background = new TitleBarMesh();
|
||||
background.setHeight((int) MathUtils.round(Gdx.graphics.getHeight()*0.3f));
|
||||
background.setHeight(MathUtils.round(Gdx.graphics.getHeight()*0.3f));
|
||||
|
||||
setRotation((float) (MathUtils.radiansToDegrees*Math.atan2(Gdx.graphics.getHeight()-background.getHeight(), Gdx.graphics.getWidth())));
|
||||
setSize((float) Math.sqrt(Gdx.graphics.getWidth()*Gdx.graphics.getWidth() + Gdx.graphics.getHeight()*Gdx.graphics.getHeight()), ((float) background.getHeight())*MathUtils.sinDeg(90f-getRotation()));
|
||||
|
||||
background.setCam(camera);
|
||||
|
||||
hvisual.setWidth(getWidth());
|
||||
hvisual.setHeight(Gdx.graphics.getHeight()*0.3f);
|
||||
hvisual.getVis().flip();
|
||||
visual.setWidth(getWidth());
|
||||
visual.setHeight(background.getHeight());
|
||||
visual.getVis().flip();
|
||||
visual.getVis().reverse();
|
||||
visual2 = new MirrorVisualizer();
|
||||
hvisual.getVis().addMirrorVisualizer(visual2);
|
||||
visual2.setRotation(hvisual.getRotation());
|
||||
visual2.setyPos(background.getHeight()-10);
|
||||
|
||||
visual.getVis().addMirrorVisualizer(visual2);
|
||||
visual2.setRotation(visual.getRotation());
|
||||
visual2.setyPos(MathUtils.round(getHeight()));
|
||||
}
|
||||
@Override
|
||||
public void act(float delta) {
|
||||
super.act(delta);
|
||||
@ -42,16 +46,14 @@ public class TitleBarVisualizer extends Group implements Disposable {
|
||||
|
||||
@Override
|
||||
public void draw(Batch batch, float parentAlpha) {
|
||||
background.draw();
|
||||
batch.end();
|
||||
background.draw();
|
||||
batch.begin();
|
||||
super.draw(batch, parentAlpha);
|
||||
}
|
||||
|
||||
public Visualizer getHvisual() {
|
||||
System.out.println("Harrison is a weeb oh and delet system32");
|
||||
}
|
||||
return hvisual;
|
||||
return visual;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user