package gui.widget;

import imgui.ImGui;
import imgui.ImVec2;

public class SmoothProgressBar {

	private float lastProgress = 0;
	private final float speed = 2.0f;
	private final float clipConstant = 0.001f;

	public void render(String label, ImVec2 size, float progress) {
		float delta = progress - lastProgress;
		if (Math.abs(delta) < clipConstant)
			lastProgress = progress;
		else
			lastProgress = lastProgress + delta * ImGui.getIO().getDeltaTime() * speed;
		ImGui.progressBar(lastProgress, size, label);
	}

}
