import polaris.sdk.ui.*; import polaris.sdk.ui.controls.*; import polaris.sdk.ui.samples.*; import polaris.sdk.ui.render.*; import java.awt.Canvas; import java.awt.Dimension; import java.awt.EventQueue; import java.awt.Frame; import java.awt.image.BufferedImage; import java.nio.ByteBuffer; import java.nio.charset.StandardCharsets; import java.nio.file.*; import java.security.MessageDigest; import java.util.*; import javax.imageio.ImageIO; /** Actual SDK OpenGL renders. No desktop capture, input injection or post-painted UI. */ public final class RenderShowcase { static final int PW=2160, PH=1350; static final float W=1440, H=900; static final int NAVY=0xff102137, INK=0xff172e46, BLUE=0xff345ede, MUTED=0xff647b92; static NativeBackend gpu; static Path output; static final List records=new ArrayList(); public static void main(String[] args) throws Exception { System.setProperty("sun.java2d.opengl","false");System.setProperty("sun.java2d.d3d","false"); System.setProperty("sun.java2d.uiScale","1"); output=Paths.get(args.length>0?args[0]:"cloudflare-site/media").toAbsolutePath();Files.createDirectories(output); Frame window=new Frame("PolarisUI offline render");Canvas canvas=new Canvas(); EventQueue.invokeAndWait(()->{window.setUndecorated(true);canvas.setPreferredSize(new Dimension(PW,PH));window.add(canvas);window.pack();window.setLocation(-5000,-3000);window.setVisible(true);}); try(NativeBackend backend=NativeBackend.open(canvas)){ gpu=backend; render("refraction-zero",0); render("material-settings",1); render("music-dark",2); render("settings-light",3); render("files-light",4); // Independent control capture proves that the zero-blur picture changes when refraction is disabled. BufferedImage reference=optics(false); BufferedImage actual=ImageIO.read(output.resolve("refraction-zero.png").toFile()); long changed=0;for(int y=0;y=3;Theme t=theme(light);if(scene==1)t.tint(0f).blur(0f).sigma(0f).refraction(30f).shine(1f).dispersion(1.2f); Ui ui=new Ui();ui.theme(t);ui.background().grid(scene==1).animated(false); if(scene==1)material(ui);else application(ui,scene); try(NativePainter p=new NativePainter(gpu)){ for(int frame=0;frame<3;frame++){ gpu.background(PW,PH,0,false,t);p.begin(W,H,PW,PH);p.configure(t); background(p,light,scene); topbar(p,light,scene==1?"MATERIAL / LIVE PARAMETERS":scene==2?"MUSIC / DARK THEME":scene==3?"SETTINGS / LIGHT THEME":"FILES / LIGHT THEME"); if(scene==1){ gridPanel(p,56,180,440,520);p.backdrop(); p.glass(88,226,376,410,42,t,0); p.textWeight("Pure refraction.",116,268,32,t.text,600); p.text("清晰背景,真实边缘弯折。",116,318,18,t.muted); p.text("tint 0.00",116,518,17,t.text);p.text("blur 0.00",116,551,17,t.text);p.text("refraction 30.0",116,584,17,t.text); p.text("0 染色 / 0 模糊 / 0 高斯处理",68,732,16,t.muted); // A quiet host backplate improves parameter legibility; the settings controls are unmodified SDK widgets. p.fill(536,152,848,654,28,0xe8102137);p.backdrop(); }else{ p.glass(48,122,1344,704,28,t,t.blur);p.backdrop(); sidebar(p,light,scene); } ui.render(p,W,H,10+frame); footer(p,light,scene==1?"Theme.tint(0f).blur(0f).sigma(0f).refraction(30f)":"SDK samples / local demonstration data / Java 8 + 21"); p.flushWindow(PW,PH,t.sigma,700,180);gpu.checkError(); } image=readback(); } } Path file=output.resolve(name+".png");ImageIO.write(image,"PNG",file.toFile()); String sha=hex(MessageDigest.getInstance("SHA-256").digest(Files.readAllBytes(file))); records.add("{\"name\":\""+name+".png\",\"sha256\":\""+sha+"\",\"bytes\":"+Files.size(file)+"}"); System.out.println(file.getFileName()+" "+Files.size(file)+" bytes "+sha); } static BufferedImage optics(boolean refracted) throws Exception { Theme t=theme(false).tint(0f).blur(0f).sigma(0f).refraction(refracted?30f:0f).shine(1f).dispersion(1.2f); if(t.tint!=0||t.blur!=0||t.sigma!=0)throw new AssertionError("Not a zero-blur render"); try(NativePainter p=new NativePainter(gpu)){ gpu.background(PW,PH,0,false,t);p.begin(960,600,PW,PH);p.configure(t); p.fill(0,0,960,600,0,0xff0d1d32); for(int y=0;y<600;y+=3)p.fill(0,y,960,3,0,Theme.mix(0xff102137,0xff213858,y/600f)); star(p,52,44,16,0xffa7c8ed);p.textWeight("PolarisUI",81,27,28,0xffeef5ff,600); p.text("MATERIAL STUDY / JAVA + OPENGL",567,38,12,0xffa7c8ed); p.textWeight("让边缘,透露光的路径。",48,108,36,0xffeef5ff,600); p.text("tint 0.00 blur 0.00 refraction 30.0",50,164,15,0xffb7cce4); // Draw the background using SDK primitives before freezing it for refraction. for(int i=0;i<19;i++){ int c=Theme.mix(0xff75bcd7,0xffbba2d6,i/18f); p.line(130+i*31,226,16+i*31,512,20,c); } p.fill(555,232,335,265,52,0xffd9b189); for(int x=52;x<=908;x+=26)p.line(x,221,x,528,1,0x78eef5ff); for(int y=226;y<=518;y+=26)p.line(48,y,910,y,1,0x78eef5ff); p.textWeight("POLARIS",240,315,91,0xff213957,600); p.text("0123456789 / ABCDEFGHIJKLMNOPQRSTUVWXYZ",88,462,17,0xff173450); p.backdrop(); p.glass(108,254,342,212,48,t,0); p.glass(544,260,290,208,62,t,0); p.text("NO TINT. NO BLUR.",50,553,14,0xffd4e4f6); p.text("SDK 2.4.5 / FRAMEBUFFER CAPTURE",597,553,11,0xffa8c1dd); p.flushWindow(PW,PH,0,400,160);gpu.checkError();return readback(); } } static void material(Ui ui){ GlassSettingsPanel settings=new GlassSettingsPanel(); settings.bounds(564,216,792,settings.preferredHeight(792));ui.root().add(settings);settings.syncFromModel(); Label title=new Label("材质配置").size(27).weight(600);title.bounds(564,165,400,36);ui.root().add(title); ui.resize(W,H); if(((Slider)ui.find("materialTint")).value()!=0 || ((Slider)ui.find("materialBlur")).value()!=0)throw new AssertionError("Settings are not displaying zero values"); } static void application(Ui ui,int scene){ Widget app=scene==2?new MusicScene():scene==3?new SettingsScene():new FilesScene(); app.bounds(304,158,1040,626);ui.root().add(app); if(scene==2){((ListBox)ui.find("music.tracks")).select(1);((MusicScene)app).selectTrack(1);((Slider)ui.find("music.progress")).value(72).changed();} if(scene==3){((TextField)ui.find("settings.nickname")).value("Polaris Studio").changed();ui.find("settings.apply").activate();} ui.resize(W,H); } static void background(NativePainter p,boolean light,int scene){ int a=light?0xffe4eef8:0xff102137,b=light?0xfff5f8fc:0xff253f60; for(int y=0;y