Rogue: Savage Rats, a retro-themed dungeon crawler
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
rogue-savage-rats/src/mightypork/gamecore/gui/components/painters/ImagePainter.java

47 lines
878 B

package mightypork.gamecore.gui.components.painters;
import mightypork.gamecore.core.modules.App;
import mightypork.gamecore.gui.components.BaseComponent;
import mightypork.gamecore.gui.components.DynamicWidthComponent;
import mightypork.gamecore.resources.textures.TxQuad;
/**
* Draws image in given rect
*
* @author Ondřej Hruška (MightyPork)
*/
public class ImagePainter extends BaseComponent implements DynamicWidthComponent {
private TxQuad txQuad;
/**
* @param txQuad drawn image
*/
public ImagePainter(TxQuad txQuad)
{
this.txQuad = txQuad;
}
@Override
public void renderComponent()
{
App.gfx().quad(this, txQuad);
}
@Override
public double computeWidth(double height)
{
return (height / txQuad.uvs.height().value()) * txQuad.uvs.width().value();
}
public void setTxQuad(TxQuad txQuad)
{
this.txQuad = txQuad;
}
}