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.
52 lines
944 B
52 lines
944 B
package mightypork.gamecore.gui.components.painters;
|
|
|
|
|
|
import mightypork.gamecore.core.App;
|
|
import mightypork.gamecore.graphics.textures.TxQuad;
|
|
import mightypork.gamecore.gui.components.BaseComponent;
|
|
import mightypork.gamecore.gui.components.DynamicWidthComponent;
|
|
|
|
|
|
/**
|
|
* 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();
|
|
}
|
|
|
|
|
|
/**
|
|
* Set drawn {@link TxQuad}
|
|
*
|
|
* @param txQuad the drawn quad
|
|
*/
|
|
public void setTxQuad(TxQuad txQuad)
|
|
{
|
|
this.txQuad = txQuad;
|
|
}
|
|
}
|
|
|