optimizations by replacing nested loops to one main loop
This commit is contained in:
		| @@ -136,18 +136,16 @@ public class BasicVisualizer extends VisualizerCore { | ||||
| 			} else { | ||||
| 				bars[i].setRotation(rotation); | ||||
| 			} | ||||
| 			if (i == bars.length-1 && width <= getActualWidth()) { | ||||
| 				barSpace -= 2; | ||||
| 			} | ||||
| 			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 mirrorIndex = 0; mirrorIndex < mirrors.size; mirrorIndex++) { | ||||
| 				mirrors.get(mirrorIndex).position(i, barWidth, spaceBetweenBars); | ||||
| 			} | ||||
| 		for (int i = 0; i < mirrors.size; i++) { | ||||
| 			mirrors.get(i).position(barWidth, spaceBetweenBars, (width <= getActualWidth())); | ||||
| 		} | ||||
|  | ||||
| 	} | ||||
| 	 | ||||
| 	public float getActualWidth() { | ||||
|   | ||||
| @@ -29,26 +29,19 @@ public class MirrorVisualizer { | ||||
| 		} | ||||
| 	} | ||||
| 	 | ||||
| 	public void render(int renderID, Batch batch, float parentAlpha, Sprite[] bars) { | ||||
| 		this.bars[renderID].setSize(bars[renderID].getWidth(), bars[renderID].getHeight()); | ||||
| 		this.bars[renderID].draw(batch); | ||||
| 	public void render(int renderIndex, Batch batch, float parentAlpha, Sprite[] bars) { | ||||
| 		this.bars[renderIndex].setSize(bars[renderIndex].getWidth(), bars[renderIndex].getHeight()); | ||||
| 		this.bars[renderIndex].draw(batch); | ||||
| 	} | ||||
| 	 | ||||
| 	public void position(int barWidth, int spaceBetweenBars, boolean shrink) { | ||||
| 		int barSpaceMultiplier = barWidth + spaceBetweenBars; | ||||
|  | ||||
| 		for (int i = 0; i < bars.length; i ++) { | ||||
| 	public void position(int positionIndex, int barWidth, int spaceBetweenBars) { | ||||
| 		if (flip) { | ||||
| 				bars[i].setRotation(rotation+180); | ||||
| 			bars[positionIndex].setRotation(rotation+180); | ||||
| 		} else { | ||||
| 				bars[i].setRotation(rotation); | ||||
| 			} | ||||
| 			int barSpace = i*(barWidth+spaceBetweenBars); | ||||
| 			if (i == bars.length-1 && shrink) { | ||||
| 				barSpace -= 2; | ||||
| 			} | ||||
| 			bars[i].setPosition(xPos + barSpace*rectCoordRot.x, yPos + barSpace*rectCoordRot.y); | ||||
| 			bars[positionIndex].setRotation(rotation); | ||||
| 		} | ||||
| 		int barSpace = positionIndex*(barWidth+spaceBetweenBars); | ||||
| 		bars[positionIndex].setPosition(xPos + barSpace*rectCoordRot.x, yPos + barSpace*rectCoordRot.y); | ||||
| 	} | ||||
| 	 | ||||
| 	public void setColor(Color color) { | ||||
|   | ||||
| @@ -120,7 +120,7 @@ public class MusicSelectionPage extends Page implements Observer { | ||||
| 		musicInfoTable.setSize(getWidth()-musicTableScrollPane.getWidth(), getHeight()); | ||||
| 		addActor(musicInfoTable); | ||||
| 		 | ||||
| 		songTitle = new ScrollText("", null, skin, true, false); | ||||
| 		songTitle = new ScrollText("", null, skin, true, true); | ||||
| 		author = new Label(null, skin, "sub-font", skin.getColor("default")); | ||||
| 		songLength = new Label(null, skin, "sub-font", skin.getColor("default")); | ||||
| 		previousTop = new Label(null, skin, "sub-font", skin.getColor("default")); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user