512 lines
26 KiB
HTML
512 lines
26 KiB
HTML
<!doctype html>
|
||
<html lang="en">
|
||
<head>
|
||
<meta charset="UTF-8" />
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||
<title>Haulick 32T — Startup screen asset generator</title>
|
||
<style>
|
||
:root { font-family: "Segoe UI", Arial, system-ui, sans-serif; background:#0b1117; color:#dfe9ef; }
|
||
body { margin:0; padding:24px; }
|
||
h1 { font-size:20px; margin:0 0 4px; color:#fff; letter-spacing:.5px; }
|
||
h1 span { color:#00CCFF; }
|
||
.sub { font-size:12px; color:#7d919e; margin:0 0 20px; }
|
||
.wrap { display:flex; gap:24px; flex-wrap:wrap; align-items:flex-start; }
|
||
.preview { flex:1 1 720px; min-width:320px; }
|
||
.preview canvas { width:100%; height:auto; display:block; border:1px solid #1d2c38; box-shadow:0 8px 40px rgba(0,0,0,.6); }
|
||
.panel { flex:0 1 320px; min-width:280px; background:#101923; border:1px solid #1d2c38; padding:16px; }
|
||
.panel h2 { font-size:13px; text-transform:uppercase; letter-spacing:1.5px; color:#00CCFF; margin:0 0 12px; }
|
||
.row { display:flex; align-items:center; gap:8px; margin:8px 0; font-size:13px; }
|
||
.row label { flex:1; color:#b7c6d0; }
|
||
select, input[type=number] { background:#0b1117; color:#dfe9ef; border:1px solid #2a3d4c; padding:4px 8px; font-size:13px; }
|
||
button { display:block; width:100%; margin:8px 0; padding:10px 12px; font-size:13px; font-weight:600; text-align:left;
|
||
background:#132430; color:#eaf6fb; border:1px solid #23506b; cursor:pointer; border-radius:2px; }
|
||
button:hover { background:#1740; background:#17384a; border-color:#00CCFF; }
|
||
button.primary { background:#083a52; border-color:#00CCFF; color:#9deeff; }
|
||
a.dlink { display:block; margin:10px 0; padding:12px; font-size:14px; font-weight:700; text-align:center;
|
||
background:#0a4d2f; color:#c8ffe0; border:1px solid #2BEE70; border-radius:2px; text-decoration:none; cursor:pointer; }
|
||
a.dlink:hover { background:#0d5c39; border-color:#2BEE70; }
|
||
#status { font-size:12px; color:#7d919e; margin-top:10px; min-height:16px; white-space:pre-wrap; }
|
||
.info { font-size:11px; color:#66798a; line-height:1.6; margin-top:16px; border-top:1px solid #1d2c38; padding-top:12px; }
|
||
.info b { color:#9db2c1; }
|
||
.dot { display:inline-block; width:10px; height:10px; border-radius:1px; margin-right:6px; vertical-align:middle; }
|
||
</style>
|
||
</head>
|
||
<body>
|
||
<h1>HAULICK 32T <span>— startup screen asset generator</span></h1>
|
||
<p class="sub">TP1200 Comfort · 1280 × 800 · 32-frame cyan breathing border (3.2 s cycle) · foreground with 20 px alpha fade · exact palette from the design spec</p>
|
||
|
||
<div class="wrap">
|
||
<div class="preview"><canvas id="pv" width="1280" height="800"></canvas></div>
|
||
|
||
<div class="panel">
|
||
<h2>Preview</h2>
|
||
<div class="row"><label>Animation</label><select id="run"><option value="1" selected>Play (100 ms)</option><option value="2">Play (200 ms)</option><option value="0">Paused</option></select></div>
|
||
<div class="row"><label>Frame</label><input type="number" id="frame" min="0" max="31" value="0" style="width:70px" /></div>
|
||
<div class="row"><label>Show foreground layer</label><input type="checkbox" id="showFg" checked /></div>
|
||
<div class="row"><label>Show text layer (native WinCC objects)</label><input type="checkbox" id="showText" checked /></div>
|
||
<div class="row"><label>Simulate SYSTEM READY state</label><input type="checkbox" id="showReady" /></div>
|
||
<div class="row"><label>Controller panel state</label><select id="diagState"><option value="allok" selected>All OK (RUN, V4.3)</option><option value="et200">ET200 FAULT</option><option value="offline">PLC OFFLINE</option></select></div>
|
||
|
||
<h2 style="margin-top:18px">Export</h2>
|
||
<button class="primary" id="btnPackage">⬇ Complete package (.zip)</button>
|
||
<button id="btnBg">Background frames 00–31 (.zip)</button>
|
||
<button id="btnFg">Foreground PNG</button>
|
||
<button id="btnIcon">SYSTEM READY icon PNG</button>
|
||
<a id="dlLink" class="dlink" style="display:none"></a>
|
||
<div id="status">Ready. PNGs are rendered in your browser — exact 1280 × 800, RGBA.</div>
|
||
|
||
<div class="info">
|
||
<b>Package contents</b><br>
|
||
background/BG_Breath_00…31.png · foreground/Startup_Foreground.png · icon/SystemReady_Icon.png · previews/Composite_*.png · README.txt<br><br>
|
||
<b>Palette</b><br>
|
||
<span class="dot" style="background:#121B22"></span>#121B22 main background<br>
|
||
<span class="dot" style="background:#00CCFF"></span>#00CCFF cyan highlight<br>
|
||
<span class="dot" style="background:#B0C4CC"></span>#B0C4CC secondary text<br>
|
||
<span class="dot" style="background:#2BEE70"></span>#2BEE70 ready green (text)<br>
|
||
<span class="dot" style="background:#00F573"></span>#00F573 ready green (icon)<br><br>
|
||
The ZIP is written with stored (uncompressed) entries and self-verified (entry count + CRC per file) before download — any unzip tool including 7-Zip opens it. A native .7z export is not possible on this page: the 7z format needs the LZMA codec and external libraries are blocked.<br>
|
||
If nothing downloads inside this preview, download the HTML file itself and open it in a local browser — the green SAVE link then always works.
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<script>
|
||
"use strict";
|
||
var W = 1280, H = 800, FRAMES = 32, BORDER = 20;
|
||
|
||
/* ---------- deterministic RNG for brushed metal ---------- */
|
||
function mulberry32(a){return function(){a|=0;a=a+0x6D2B79F5|0;var t=Math.imul(a^a>>>15,1|a);t=t+Math.imul(t^t>>>7,61|t)^t;return((t^t>>>14)>>>0)/4294967296;};}
|
||
|
||
/* ---------- static interior of the breathing background ---------- */
|
||
var bgInterior = new Uint8ClampedArray(W*H*4);
|
||
(function(){ for(var i=0;i<W*H;i++){ var o=i*4; bgInterior[o]=18; bgInterior[o+1]=27; bgInterior[o+2]=34; bgInterior[o+3]=255; } })();
|
||
|
||
/* Breathing level: 0 at frame 0, 1 at frame 16, smooth cosine ramp */
|
||
function breathLevel(f){ return 0.5 - 0.5*Math.cos(2*Math.PI*f/FRAMES); }
|
||
|
||
function renderBgFrame(id, f){
|
||
var d = id.data; d.set(bgInterior);
|
||
var L = breathLevel(f);
|
||
for(var y=0;y<H;y++){
|
||
var yEdge = (y<BORDER) || (y>=H-BORDER);
|
||
for(var x=0;x<W;x++){
|
||
if(!yEdge && x>=BORDER && x<W-BORDER) continue;
|
||
var de = Math.min(x, y, W-1-x, H-1-y);
|
||
if(de>=BORDER) continue;
|
||
var t = 1 - de/BORDER;
|
||
var glow = L * Math.pow(t, 1.7);
|
||
var i = (y*W+x)*4;
|
||
d[i] = 18 + 55 *glow;
|
||
d[i+1] = 27 + 220*glow;
|
||
d[i+2] = 34 + 255*glow;
|
||
}
|
||
}
|
||
}
|
||
|
||
function newCanvas(w,h){ var c=document.createElement('canvas'); c.width=w; c.height=h; return c; }
|
||
|
||
/* ---------- Layer 2: foreground, 1280x800 RGBA, 20 px alpha fade ---------- */
|
||
function renderForeground(){
|
||
var c = newCanvas(W,H), x = c.getContext('2d');
|
||
var g = x.createLinearGradient(0,0,0,H);
|
||
g.addColorStop(0,'#15202B'); g.addColorStop(0.5,'#111A23'); g.addColorStop(1,'#0D151C');
|
||
x.fillStyle=g; x.fillRect(0,0,W,H);
|
||
|
||
g = x.createRadialGradient(W*0.5,-H*0.2,60, W*0.5,-H*0.2,H*1.1);
|
||
g.addColorStop(0,'rgba(120,160,190,0.10)'); g.addColorStop(1,'rgba(0,0,0,0)');
|
||
x.fillStyle=g; x.fillRect(0,0,W,H);
|
||
|
||
/* brushed-metal streaks */
|
||
var rnd = mulberry32(42);
|
||
for(var i=0;i<1500;i++){
|
||
var y=(rnd()*H)|0, w=180+rnd()*1100, x0=rnd()*(W+300)-300, bright=rnd()<0.55;
|
||
x.fillStyle = bright ? 'rgba(255,255,255,'+(0.012+rnd()*0.030).toFixed(4)+')'
|
||
: 'rgba(0,0,0,' +(0.020+rnd()*0.045).toFixed(4)+')';
|
||
x.fillRect(x0,y,w,1);
|
||
}
|
||
|
||
/* cyan diagonal accents (subtle, no outer glow) */
|
||
x.save(); x.translate(W*0.74, 90); x.rotate(-Math.PI/6);
|
||
g = x.createLinearGradient(0,0,300,0);
|
||
g.addColorStop(0,'rgba(0,204,255,0)'); g.addColorStop(0.5,'rgba(0,204,255,0.13)'); g.addColorStop(1,'rgba(0,204,255,0)');
|
||
x.fillStyle=g; x.fillRect(0,-16,300,32);
|
||
x.fillStyle='rgba(0,204,255,0.55)'; x.fillRect(150,-1,120,2);
|
||
x.restore();
|
||
|
||
x.save(); x.translate(120, H*0.84); x.rotate(-Math.PI/6);
|
||
g = x.createLinearGradient(0,0,200,0);
|
||
g.addColorStop(0,'rgba(0,204,255,0)'); g.addColorStop(0.5,'rgba(0,204,255,0.09)'); g.addColorStop(1,'rgba(0,204,255,0)');
|
||
x.fillStyle=g; x.fillRect(0,-8,200,16);
|
||
x.fillStyle='rgba(0,204,255,0.35)'; x.fillRect(90,-1,80,2);
|
||
x.restore();
|
||
|
||
/* faint inner hairline */
|
||
x.strokeStyle='rgba(0,204,255,0.08)'; x.lineWidth=1;
|
||
x.strokeRect(30.5,30.5,W-61,H-61);
|
||
|
||
/* vignette for depth */
|
||
g = x.createRadialGradient(W/2,H/2,H*0.34, W/2,H/2,W*0.72);
|
||
g.addColorStop(0,'rgba(0,0,0,0)'); g.addColorStop(1,'rgba(0,0,0,0.28)');
|
||
x.fillStyle=g; x.fillRect(0,0,W,H);
|
||
|
||
/* mathematically controlled 20 px alpha fade, all four edges incl. corners */
|
||
var id = x.getImageData(0,0,W,H), d = id.data;
|
||
for(var yy=0; yy<H; yy++){
|
||
for(var xx=0; xx<W; xx++){
|
||
var de = Math.min(xx, yy, W-1-xx, H-1-yy);
|
||
if(de<BORDER){
|
||
var t = de/BORDER, s = t*t*(3-2*t); /* smoothstep */
|
||
d[(yy*W+xx)*4+3] = (255*s)|0; /* 255 at 20 px inward → 0 at edge */
|
||
}
|
||
}
|
||
}
|
||
x.putImageData(id,0,0);
|
||
return c;
|
||
}
|
||
|
||
/* ---------- SYSTEM READY icon, 256x256 RGBA ---------- */
|
||
function renderReadyIcon(){
|
||
var S=256, c=newCanvas(S,S), x=c.getContext('2d'), cxp=S/2;
|
||
var g = x.createRadialGradient(cxp,cxp,20, cxp,cxp,118);
|
||
g.addColorStop(0,'rgba(0,245,115,0.45)'); g.addColorStop(0.55,'rgba(0,245,115,0.16)'); g.addColorStop(1,'rgba(0,245,115,0)');
|
||
x.fillStyle=g; x.fillRect(0,0,S,S);
|
||
x.beginPath(); x.arc(cxp,cxp,66,0,7); x.fillStyle='rgba(0,245,115,0.10)'; x.fill();
|
||
x.beginPath(); x.arc(cxp,cxp,66,0,7); x.lineWidth=8; x.strokeStyle='#00F573'; x.stroke();
|
||
x.beginPath(); x.arc(cxp,cxp,76,0,7); x.lineWidth=2; x.strokeStyle='rgba(0,245,115,0.35)'; x.stroke();
|
||
x.beginPath(); x.moveTo(cxp-30,cxp+2); x.lineTo(cxp-6,cxp+26); x.lineTo(cxp+32,cxp-22);
|
||
x.lineWidth=13; x.lineCap='round'; x.lineJoin='round'; x.strokeStyle='#B8FFD6'; x.stroke();
|
||
return c;
|
||
}
|
||
|
||
/* ---------- controller / PLC info panel (native WinCC objects) ---------- */
|
||
var DIAG_COLORS = { 0:'#E74C3C', 1:'#00F573', 2:'#FFA500', 3:'#E74C3C' };
|
||
function drawControllerPanel(x, diag){
|
||
var px=48, py=H-236, pw=400, ph=190;
|
||
x.fillStyle='rgba(9,15,22,0.84)'; x.fillRect(px,py,pw,ph);
|
||
x.strokeStyle='rgba(0,204,255,0.28)'; x.lineWidth=1; x.strokeRect(px+0.5,py+0.5,pw-1,ph-1);
|
||
x.fillStyle='rgba(0,204,255,0.65)'; x.fillRect(px,py,3,ph);
|
||
|
||
x.textAlign='left'; x.textBaseline='alphabetic';
|
||
try{ x.letterSpacing='2px'; }catch(e){}
|
||
x.font='bold 13px Arial, sans-serif'; x.fillStyle='#00CCFF';
|
||
x.fillText('CONTROLLER', px+18, py+24);
|
||
try{ x.letterSpacing='0px'; }catch(e){}
|
||
x.font='11px Arial, sans-serif'; x.fillStyle='rgba(125,145,158,0.9)'; x.textAlign='right';
|
||
x.fillText('PLC INFO', px+pw-14, py+24);
|
||
|
||
var rows;
|
||
if(diag==='et200'){
|
||
rows=[
|
||
{l:'CPU S7-1200', v:'RUN', s:1},
|
||
{l:'CPU FIRMWARE', v:'V4.3', s:1},
|
||
{l:'ET200SP IM 155-6', v:'FAULT', s:3},
|
||
{l:'PROFINET', v:'FAULT', s:3},
|
||
{l:'HMI LINK', v:'ONLINE', s:1},
|
||
{l:'CYCLE TIME', v:'3.2 ms', s:1}
|
||
];
|
||
} else if(diag==='offline'){
|
||
rows=[
|
||
{l:'CPU S7-1200', v:'OFFLINE', s:0},
|
||
{l:'CPU FIRMWARE', v:'\u2014', s:0},
|
||
{l:'ET200SP IM 155-6', v:'OFFLINE', s:0},
|
||
{l:'PROFINET', v:'OFFLINE', s:0},
|
||
{l:'HMI LINK', v:'OFFLINE', s:0},
|
||
{l:'CYCLE TIME', v:'\u2014', s:0}
|
||
];
|
||
} else {
|
||
rows=[
|
||
{l:'CPU S7-1200', v:'RUN', s:1},
|
||
{l:'CPU FIRMWARE', v:'V4.3', s:1},
|
||
{l:'ET200SP IM 155-6', v:'RUN', s:1},
|
||
{l:'PROFINET', v:'OK', s:1},
|
||
{l:'HMI LINK', v:'ONLINE', s:1},
|
||
{l:'CYCLE TIME', v:'3.2 ms', s:1}
|
||
];
|
||
}
|
||
|
||
for(var i=0;i<rows.length;i++){
|
||
var r=rows[i], ry=py+50+i*22;
|
||
x.save();
|
||
x.shadowColor=DIAG_COLORS[r.s]; x.shadowBlur=(r.s===1?7:9);
|
||
x.fillStyle=DIAG_COLORS[r.s];
|
||
x.beginPath(); x.arc(px+26, ry-5, 5, 0, 7); x.fill();
|
||
x.restore();
|
||
x.textAlign='left'; x.font='14px Arial, sans-serif'; x.fillStyle='#B0C4CC';
|
||
x.fillText(r.l, px+44, ry);
|
||
x.textAlign='right'; x.font='bold 14px Arial, sans-serif';
|
||
x.fillStyle = (r.s===1) ? '#FFFFFF' : (r.v==='\u2014' ? '#7d919e' : (r.s===2 ? '#FFA500' : '#E74C3C'));
|
||
x.fillText(r.v, px+pw-16, ry);
|
||
}
|
||
}
|
||
|
||
/* ---------- native text layer (preview of WinCC objects) ---------- */
|
||
function drawTexts(x, ready, icon, diag){
|
||
x.textAlign='center'; x.textBaseline='alphabetic';
|
||
try{ x.letterSpacing='0px'; }catch(e){}
|
||
|
||
x.font='bold 26px Arial, sans-serif'; x.fillStyle='#00CCFF';
|
||
x.fillText('SYSTEM STARTUP', W/2, 148);
|
||
x.fillStyle='rgba(0,204,255,0.55)';
|
||
x.fillRect(W/2-330, 138, 130, 2); x.fillRect(W/2+200, 138, 130, 2);
|
||
|
||
x.font='bold 52px Arial, sans-serif'; x.fillStyle='#FFFFFF';
|
||
x.fillText('HAULICK 32T', W/2, 330);
|
||
|
||
try{ x.letterSpacing='7px'; }catch(e){}
|
||
x.font='20px Arial, sans-serif'; x.fillStyle='#B0C4CC';
|
||
x.fillText('STAMPING PRESS CONTROL SYSTEM', W/2, 364);
|
||
try{ x.letterSpacing='0px'; }catch(e){}
|
||
|
||
var g = x.createLinearGradient(W/2-240,0,W/2+240,0);
|
||
g.addColorStop(0,'rgba(0,204,255,0)'); g.addColorStop(0.5,'rgba(0,204,255,0.8)'); g.addColorStop(1,'rgba(0,204,255,0)');
|
||
x.fillStyle=g; x.fillRect(W/2-240, 388, 480, 2);
|
||
|
||
if(!ready){
|
||
x.font='23px Arial, sans-serif'; x.fillStyle='#B0C4CC';
|
||
x.fillText('Waiting for PLC to enter RUN mode...', W/2, 470);
|
||
x.font='17px Arial, sans-serif'; x.fillStyle='rgba(176,196,204,0.65)';
|
||
x.fillText('Main screen will open automatically when controller is ready.', W/2, 502);
|
||
} else {
|
||
if(icon) x.drawImage(icon, W/2-52, 418, 104, 104);
|
||
x.font='bold 30px Arial, sans-serif'; x.fillStyle='#2BEE70';
|
||
x.fillText('SYSTEM READY', W/2, 566);
|
||
}
|
||
|
||
x.font='13px Arial, sans-serif'; x.fillStyle='rgba(176,196,204,0.45)';
|
||
x.fillText('Haulick 32T · Stamping press control system', W/2, H-36);
|
||
|
||
drawControllerPanel(x, diag || 'allok');
|
||
}
|
||
|
||
/* ---------- live preview ---------- */
|
||
var pv = document.getElementById('pv'), pvx = pv.getContext('2d');
|
||
var fgCanvas = renderForeground();
|
||
var iconCanvas = renderReadyIcon();
|
||
var pvId = pvx.createImageData(W,H);
|
||
var curFrame = 0, timer = null;
|
||
|
||
function drawPreview(){
|
||
var f = Math.max(0, Math.min(31, parseInt(document.getElementById('frame').value,10) || 0));
|
||
curFrame = f;
|
||
renderBgFrame(pvId, f);
|
||
pvx.putImageData(pvId, 0, 0);
|
||
if(document.getElementById('showFg').checked) pvx.drawImage(fgCanvas, 0, 0);
|
||
if(document.getElementById('showText').checked) drawTexts(pvx, document.getElementById('showReady').checked, iconCanvas, document.getElementById('diagState').value);
|
||
}
|
||
function startAnimation(){
|
||
if(timer) clearInterval(timer);
|
||
var mode = document.getElementById('run').value;
|
||
if(mode === '0') { drawPreview(); return; }
|
||
var ms = (mode === '2') ? 200 : 100;
|
||
timer = setInterval(function(){
|
||
curFrame = (curFrame + 1) % FRAMES;
|
||
document.getElementById('frame').value = curFrame;
|
||
drawPreview();
|
||
}, ms);
|
||
}
|
||
['run','frame','showFg','showText','showReady','diagState'].forEach(function(id){
|
||
document.getElementById(id).addEventListener('change', function(){
|
||
if(id==='run') startAnimation();
|
||
else drawPreview();
|
||
});
|
||
});
|
||
document.getElementById('frame').addEventListener('input', drawPreview);
|
||
startAnimation();
|
||
|
||
/* ---------- ZIP writer (stored entries, pure JS) ---------- */
|
||
var CRC_TABLE = (function(){ var t=new Uint32Array(256); for(var n=0;n<256;n++){var c=n; for(var k=0;k<8;k++) c = (c&1) ? (0xEDB88320 ^ (c>>>1)) : (c>>>1); t[n]=c;} return t; })();
|
||
function crc32(u8){ var c=0xFFFFFFFF; for(var i=0;i<u8.length;i++){ c = CRC_TABLE[(c^u8[i])&0xFF] ^ (c>>>8); } return (c^0xFFFFFFFF)>>>0; }
|
||
function makeZip(files){
|
||
var enc = new TextEncoder();
|
||
var parts=[], central=[], offset=0;
|
||
var dosTime = (12<<11)|(0<<5)|0, dosDate = ((2026-1980)<<9)|(11<<5)|6;
|
||
for(var fi=0; fi<files.length; fi++){
|
||
var f = files[fi];
|
||
var name = enc.encode(f.name);
|
||
var crc = crc32(f.data);
|
||
var lh = new DataView(new ArrayBuffer(30));
|
||
lh.setUint32(0,0x04034b50,true); lh.setUint16(4,20,true); lh.setUint16(6,0,true); lh.setUint16(8,0,true);
|
||
lh.setUint16(10,dosTime,true); lh.setUint16(12,dosDate,true);
|
||
lh.setUint32(14,crc,true); lh.setUint32(18,f.data.length,true); lh.setUint32(22,f.data.length,true);
|
||
lh.setUint16(26,name.length,true); lh.setUint16(28,0,true);
|
||
parts.push(new Uint8Array(lh.buffer), name, f.data);
|
||
var ch = new DataView(new ArrayBuffer(46));
|
||
ch.setUint32(0,0x02014b50,true); ch.setUint16(4,20,true); ch.setUint16(6,20,true);
|
||
ch.setUint16(8,0,true); ch.setUint16(10,0,true); ch.setUint16(12,dosTime,true); ch.setUint16(14,dosDate,true);
|
||
ch.setUint32(16,crc,true); ch.setUint32(20,f.data.length,true); ch.setUint32(24,f.data.length,true);
|
||
ch.setUint16(28,name.length,true); ch.setUint16(30,0,true); ch.setUint16(32,0,true);
|
||
ch.setUint16(34,0,true); ch.setUint16(36,0,true); ch.setUint32(38,0,true); ch.setUint32(42,offset,true);
|
||
central.push(new Uint8Array(ch.buffer), name);
|
||
offset += 30 + name.length + f.data.length;
|
||
}
|
||
var cdSize = 0; central.forEach(function(p){ cdSize += p.length; });
|
||
var eocd = new DataView(new ArrayBuffer(22));
|
||
eocd.setUint32(0,0x06054b50,true); eocd.setUint16(4,0,true); eocd.setUint16(6,0,true);
|
||
eocd.setUint16(8,files.length,true); eocd.setUint16(10,files.length,true);
|
||
eocd.setUint32(12,cdSize,true); eocd.setUint32(16,offset,true); eocd.setUint16(20,0,true);
|
||
return new Blob(parts.concat(central, [new Uint8Array(eocd.buffer)]), {type:'application/zip'});
|
||
}
|
||
var lastUrl = null;
|
||
function deliver(blob, name){
|
||
var mb = blob.size/1048576;
|
||
var sizeStr = (mb >= 1) ? mb.toFixed(2)+' MB' : (blob.size/1024).toFixed(0)+' KB';
|
||
if(lastUrl){ try{ URL.revokeObjectURL(lastUrl); }catch(e){} }
|
||
lastUrl = URL.createObjectURL(blob);
|
||
var link = document.getElementById('dlLink');
|
||
link.href = lastUrl; link.download = name;
|
||
link.textContent = '\u2b07 SAVE ' + name + ' (' + sizeStr + ')';
|
||
link.style.display = 'block';
|
||
/* also attempt the automatic download; the persistent link is the fallback */
|
||
try{
|
||
var a = document.createElement('a');
|
||
a.href = lastUrl; a.download = name;
|
||
document.body.appendChild(a); a.click();
|
||
setTimeout(function(){ a.remove(); }, 1500);
|
||
}catch(e){}
|
||
}
|
||
/* ZIP self-check, strict: EOCD from end + central directory + per-entry local header,
|
||
size and CRC — exactly the way Windows Compressed Folders reads a ZIP */
|
||
function verifyZip(blob){
|
||
return blob.arrayBuffer().then(function(buf){
|
||
var u8 = new Uint8Array(buf), dv = new DataView(buf), n = u8.length;
|
||
var eocd = -1;
|
||
for(var i = n - 22; i >= 0 && i >= n - 22 - 65536; i--){
|
||
if(dv.getUint32(i, true) === 0x06054b50){ eocd = i; break; }
|
||
}
|
||
if(eocd < 0) return { ok:false, err:'EOCD record missing' };
|
||
if(eocd + 22 !== n) return { ok:false, err:'EOCD not at end of file' };
|
||
var count = dv.getUint16(eocd + 10, true);
|
||
var cdSize = dv.getUint32(eocd + 12, true);
|
||
var cdOff = dv.getUint32(eocd + 16, true);
|
||
if(cdOff + cdSize !== eocd) return { ok:false, err:'central directory position mismatch' };
|
||
var p = cdOff, checked = 0;
|
||
for(var e = 0; e < count; e++){
|
||
if(dv.getUint32(p, true) !== 0x02014b50) return { ok:false, err:'bad central entry at ' + p };
|
||
var nameLen = dv.getUint16(p + 28, true);
|
||
var crc = dv.getUint32(p + 16, true);
|
||
var csize = dv.getUint32(p + 20, true);
|
||
var lho = dv.getUint32(p + 42, true);
|
||
if(dv.getUint32(lho, true) !== 0x04034b50) return { ok:false, err:'bad local header in entry ' + e };
|
||
var ds = lho + 30 + dv.getUint16(lho + 26, true) + dv.getUint16(lho + 28, true);
|
||
var data = u8.subarray(ds, ds + csize);
|
||
if(data.length !== csize) return { ok:false, err:'truncated data in entry ' + e };
|
||
if(crc32(data) !== crc) return { ok:false, err:'CRC mismatch in entry ' + e };
|
||
p += 46 + nameLen; checked++;
|
||
}
|
||
if(p !== eocd) return { ok:false, err:'central directory size mismatch' };
|
||
return { ok:true, count:checked };
|
||
});
|
||
}
|
||
function canvasBytes(cv){
|
||
return new Promise(function(res, rej){
|
||
cv.toBlob(function(b){ if(!b){rej(new Error('toBlob failed'));return;} b.arrayBuffer().then(function(ab){res(new Uint8Array(ab));}); }, 'image/png');
|
||
});
|
||
}
|
||
function bgFrameCanvas(f){
|
||
var c = newCanvas(W,H), cx = c.getContext('2d');
|
||
var id = cx.createImageData(W,H);
|
||
renderBgFrame(id, f); cx.putImageData(id,0,0);
|
||
return c;
|
||
}
|
||
function compositeCanvas(f, ready, diag){
|
||
var c = newCanvas(W,H), x = c.getContext('2d');
|
||
x.drawImage(bgFrameCanvas(f), 0, 0);
|
||
x.drawImage(fgCanvas, 0, 0);
|
||
drawTexts(x, ready, iconCanvas, diag || 'allok');
|
||
return c;
|
||
}
|
||
function pad2(n){ return (n<10?'0':'')+n; }
|
||
|
||
var statusEl = document.getElementById('status');
|
||
function setStatus(msg){ statusEl.textContent = msg; }
|
||
|
||
var README =
|
||
"HAULICK 32T - STARTUP SCREEN GRAPHICS PACKAGE\r\n"+
|
||
"=============================================\r\n\r\n"+
|
||
"Contents\r\n"+
|
||
" background/BG_Breath_00..31.png : 32 breathing frames, 1280x800, 100 ms each (3.2 s cycle)\r\n"+
|
||
" foreground/Startup_Foreground.png : 1280x800 RGBA, opaque center, 20 px alpha fade to all four edges\r\n"+
|
||
" icon/SystemReady_Icon.png : 256x256 RGBA, green glowing checkmark (no text)\r\n"+
|
||
" previews/Composite_*.png : background + foreground + text as the HMI will show them\r\n\r\n"+
|
||
"TIA Portal V15.1 mapping\r\n"+
|
||
" 1. Import PNGs under HMI > Graphics.\r\n"+
|
||
" 2. Graphics list 'Breathing': entries 0..31 = BG_Breath_00..31.png.\r\n"+
|
||
" 3. Graphic I/O field 1280x800 at (0,0), tag Startup_Frame (internal Int, 0..31).\r\n"+
|
||
" 4. Foreground PNG as Graphics view on top; texts as native WinCC objects.\r\n"+
|
||
" 5. Frame cycling: script self-oscillator on hidden I/O field (PLC-independent)\r\n"+
|
||
" or PLC cyclic-interrupt counter (deterministic 100 ms).\r\n\r\n"+
|
||
"Colors\r\n"+
|
||
" Main background #121B22 | Cyan #00CCFF | White #FFFFFF | Secondary #B0C4CC\r\n"+
|
||
" Ready green (text) #2BEE70 | Ready green (icon) #00F573 | Warning #FFA500 | Alarm #E74C3C\r\n\r\n"+
|
||
"Controller / PLC info panel (native WinCC objects, bottom-left)\r\n"+
|
||
" Rows: CPU RUN | CPU FW V4.3 | ET200SP | PROFINET | HMI LINK | cycle time.\r\n"+
|
||
" WinCC: one Int status per row in DB_HMI (0 OFFLINE / 1 RUN-OK / 2 MAINT / 3 FAULT),\r\n"+
|
||
" LED dot via appearance animation, word via text list (translatable).\r\n"+
|
||
" Sources: heartbeat = CPU RUN, DeviceStates/OB86 = ET200 + PROFINET,\r\n"+
|
||
" HMI_LifeCounter watchdog = HMI LINK, FW as constant in DB_HMI.\r\n";
|
||
|
||
/* ---------- export actions ---------- */
|
||
document.getElementById('btnPackage').addEventListener('click', async function(){
|
||
try{
|
||
setStatus('Rendering 32 background frames...'); await new Promise(function(r){setTimeout(r,20);});
|
||
var files = [];
|
||
for(var f=0; f<FRAMES; f++){
|
||
files.push({ name:'background/BG_Breath_'+pad2(f)+'.png', data: await canvasBytes(bgFrameCanvas(f)) });
|
||
if(f%8===7) setStatus('Rendering background frames... ('+(f+1)+'/32)');
|
||
}
|
||
setStatus('Rendering foreground...'); await new Promise(function(r){setTimeout(r,20);});
|
||
files.push({ name:'foreground/Startup_Foreground.png', data: await canvasBytes(fgCanvas) });
|
||
setStatus('Rendering icon...'); await new Promise(function(r){setTimeout(r,20);});
|
||
files.push({ name:'icon/SystemReady_Icon.png', data: await canvasBytes(iconCanvas) });
|
||
var prevs=[0,8,16,24];
|
||
for(var p=0;p<prevs.length;p++){
|
||
setStatus('Rendering composite preview frame '+pad2(prevs[p])+'...'); await new Promise(function(r){setTimeout(r,20);});
|
||
files.push({ name:'previews/Composite_Frame_'+pad2(prevs[p])+'.png', data: await canvasBytes(compositeCanvas(prevs[p], false, 'allok')) });
|
||
}
|
||
setStatus('Rendering ready-state preview...'); await new Promise(function(r){setTimeout(r,20);});
|
||
files.push({ name:'previews/Composite_Ready_State.png', data: await canvasBytes(compositeCanvas(16, true, 'allok')) });
|
||
setStatus('Rendering ET200 fault-state preview...'); await new Promise(function(r){setTimeout(r,20);});
|
||
files.push({ name:'previews/Composite_ET200_Fault.png', data: await canvasBytes(compositeCanvas(0, false, 'et200')) });
|
||
setStatus('Rendering offline-state preview...'); await new Promise(function(r){setTimeout(r,20);});
|
||
files.push({ name:'previews/Composite_PLC_Offline.png', data: await canvasBytes(compositeCanvas(0, false, 'offline')) });
|
||
files.push({ name:'README.txt', data: new TextEncoder().encode(README) });
|
||
setStatus('Building and verifying ZIP...');
|
||
var dirs = ['background/','foreground/','icon/','previews/'].map(function(d){ return { name:d, data:new Uint8Array(0) }; });
|
||
var zip = makeZip(dirs.concat(files));
|
||
var v = await verifyZip(zip);
|
||
if(!v.ok){ setStatus('ZIP self-check FAILED: '+v.err); return; }
|
||
deliver(zip, 'Haulick32T_StartupScreen.zip');
|
||
setStatus('Package verified: '+v.count+' entries, all CRC OK, '+(zip.size/1048576).toFixed(2)+' MB.\nIf no file appeared, click the green SAVE button above.');
|
||
}catch(err){ setStatus('Export failed: '+err.message); }
|
||
});
|
||
|
||
document.getElementById('btnBg').addEventListener('click', async function(){
|
||
try{
|
||
setStatus('Rendering background ZIP...'); await new Promise(function(r){setTimeout(r,20);});
|
||
var files=[];
|
||
for(var f=0; f<FRAMES; f++){
|
||
files.push({ name:'BG_Breath_'+pad2(f)+'.png', data: await canvasBytes(bgFrameCanvas(f)) });
|
||
if(f%8===7) setStatus('Rendering... ('+(f+1)+'/32)');
|
||
}
|
||
var zip = makeZip(files);
|
||
var v = await verifyZip(zip);
|
||
if(!v.ok){ setStatus('ZIP self-check FAILED: '+v.err); return; }
|
||
deliver(zip, 'Haulick32T_Background_Frames.zip');
|
||
setStatus('Background package verified: '+v.count+' entries, all CRC OK. If no file appeared, click the green SAVE button above.');
|
||
}catch(err){ setStatus('Export failed: '+err.message); }
|
||
});
|
||
|
||
document.getElementById('btnFg').addEventListener('click', async function(){
|
||
try{ setStatus('Rendering foreground...'); await new Promise(function(r){setTimeout(r,20);});
|
||
canvasBytes(fgCanvas).then(function(d){ deliver(new Blob([d],{type:'image/png'}),'Startup_Foreground.png'); setStatus('Foreground PNG ready ('+(d.length/1024).toFixed(0)+' KB) — see the green SAVE button.'); });
|
||
}catch(err){ setStatus('Export failed: '+err.message); }
|
||
});
|
||
|
||
document.getElementById('btnIcon').addEventListener('click', async function(){
|
||
try{ setStatus('Rendering icon...'); await new Promise(function(r){setTimeout(r,20);});
|
||
canvasBytes(iconCanvas).then(function(d){ deliver(new Blob([d],{type:'image/png'}),'SystemReady_Icon.png'); setStatus('Icon PNG ready ('+(d.length/1024).toFixed(0)+' KB) — see the green SAVE button.'); });
|
||
}catch(err){ setStatus('Export failed: '+err.message); }
|
||
});
|
||
</script>
|
||
</body>
|
||
</html> |