001package polaris.sdk.ui; 002 003/** Mutable standalone-background settings, separate from the UI's material/palette. 004 * Host integrations may read these settings, but remain responsible for their own scene. 005 * Mutate on the Ui/render thread, or through Ui.post(). 006 */ 007public final class BackgroundSettings { 008 private boolean grid,animated=true; 009 private double elapsed,previous=Double.NaN; 010 public boolean grid(){return grid;} 011 public BackgroundSettings grid(boolean enabled){grid=enabled;return this;} 012 public boolean animated(){return animated;} 013 public BackgroundSettings animated(boolean enabled){animated=enabled;return this;} 014 /** Advance the background clock; pausing freezes the current frame instead of resetting to zero. */ 015 public float time(double now){ 016 if(!Double.isFinite(now))throw new IllegalArgumentException("Background time must be finite"); 017 if(!Double.isNaN(previous)&&animated)elapsed+=Math.max(0,Math.min(.25,now-previous)); 018 previous=now;return (float)elapsed; 019 } 020 /** Explicitly restart the background animation. Does not change grid or pause settings. */ 021 public void resetTime(){elapsed=0;previous=Double.NaN;} 022}