package gui.widget;

import gui.constants.Images;
import gui.constants.Options;
import imgui.ImGui;
import imgui.ImVec2;
import imgui.flag.ImGuiWindowFlags;

public class AnimatedBackground {

	private float backgroundOffset = 0;

	private static final float defaultSpeed = 0.05f;

	public AnimatedBackground() {

	}

	public void render() {
		backgroundOffset += ImGui.getIO().getDeltaTime() * defaultSpeed * Options.BackgroundSpeed;
		var displaySize = ImGui.getIO().getDisplaySize();
		ImGui.setNextWindowPos(new ImVec2(0.0f, 0.0f));
		ImGui.setNextWindowSize(displaySize);
		ImGui.begin("Background", null, ImGuiWindowFlags.NoDecoration | ImGuiWindowFlags.NoMove
				| ImGuiWindowFlags.NoSavedSettings | ImGuiWindowFlags.NoBackground
				| ImGuiWindowFlags.NoBringToFrontOnFocus | ImGuiWindowFlags.NoInputs);
		ImGui.image(Images.BACKGROUND, displaySize, new ImVec2(backgroundOffset, backgroundOffset),
				new ImVec2(1.0f + backgroundOffset, 1.0f + backgroundOffset));
		ImGui.end();
	}

}
