First Push, yay
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
package de.fullrisk.citrusDev;
|
||||
|
||||
import io.wispforest.owo.ui.component.LabelComponent;
|
||||
import io.wispforest.owo.ui.core.AnimatableProperty;
|
||||
import io.wispforest.owo.ui.core.OwoUIGraphics;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
||||
public class ScalableLabel extends LabelComponent {
|
||||
|
||||
protected final AnimatableProperty<ScaleValue> scale = AnimatableProperty.of(new ScaleValue(0f));
|
||||
|
||||
public ScalableLabel(Component text) {
|
||||
super(text);
|
||||
}
|
||||
|
||||
public AnimatableProperty<ScaleValue> scale() {
|
||||
return this.scale;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(float delta, int mouseX, int mouseY) {
|
||||
super.update(delta, mouseX, mouseY);
|
||||
this.scale.update(delta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(OwoUIGraphics graphics, int mouseX, int mouseY, float partialTicks, float delta) {
|
||||
float s = this.scale.get().value();
|
||||
|
||||
float centerX = this.x() + this.width() / 2f;
|
||||
float centerY = this.y() + this.height() / 2f;
|
||||
|
||||
graphics.pose().pushMatrix();
|
||||
graphics.pose().translate(centerX, centerY);
|
||||
graphics.pose().scale(s, s);
|
||||
graphics.pose().translate(-centerX, -centerY);
|
||||
|
||||
super.draw(graphics, mouseX, mouseY, partialTicks, delta);
|
||||
|
||||
graphics.pose().popMatrix();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user