Luca448 commited on
Commit
98bcea4
·
1 Parent(s): 08781d1

Savestate: Implement Photorealistic Desk Presentation Layer to simulate high-end physical paper mockup

Browse files
Files changed (2) hide show
  1. index.html +1 -1
  2. src/views/chat/chat-view.js +59 -3
index.html CHANGED
@@ -74,7 +74,7 @@
74
  </head>
75
  <body class="dark-theme in-chat-view">
76
 
77
- <div id="live-version-badge" style="position: fixed; top: 50px; left: 50%; transform: translateX(-50%); font-size: 10px; color: var(--text-secondary); opacity: 0.6; z-index: 99999; pointer-events: none; font-weight: 500; font-family: monospace; letter-spacing: 1px; background: rgba(0,0,0,0.2); padding: 2px 8px; border-radius: 10px; border: 1px solid rgba(255,255,255,0.05);">BUILD 1.8.222</div>
78
 
79
  <!-- SVG Filters for Liquid Glass Refraction -->
80
  <svg width="0" height="0" style="position: absolute; pointer-events: none;">
 
74
  </head>
75
  <body class="dark-theme in-chat-view">
76
 
77
+ <div id="live-version-badge" style="position: fixed; top: 50px; left: 50%; transform: translateX(-50%); font-size: 10px; color: var(--text-secondary); opacity: 0.6; z-index: 99999; pointer-events: none; font-weight: 500; font-family: monospace; letter-spacing: 1px; background: rgba(0,0,0,0.2); padding: 2px 8px; border-radius: 10px; border: 1px solid rgba(255,255,255,0.05);">BUILD 1.8.223</div>
78
 
79
  <!-- SVG Filters for Liquid Glass Refraction -->
80
  <svg width="0" height="0" style="position: absolute; pointer-events: none;">
src/views/chat/chat-view.js CHANGED
@@ -4614,10 +4614,66 @@ body { margin: 0; padding: 0; background: #000; overflow: hidden; display: flex;
4614
  fCtx.restore();
4615
  });
4616
 
4617
- // Reset blend mode just in case
4618
- fCtx.globalCompositeOperation = 'source-over';
 
4619
 
4620
- const resultBase64 = finalCanvas.toDataURL('image/jpeg', 0.92);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4621
  img.src = resultBase64;
4622
 
4623
  const loadingText = img.previousElementSibling;
 
4614
  fCtx.restore();
4615
  });
4616
 
4617
+ // --- PHOTOREALISTIC DESK PRESENTATION LAYER ---
4618
+ // Instead of just returning the flat scan, we create a beautiful mockup
4619
+ // of the paper lying on a wooden desk with shadows and lighting.
4620
 
4621
+ const mockupCanvas = document.createElement('canvas');
4622
+ // We make the final image a standard landscape photo ratio (e.g., 1600x1200)
4623
+ const mw = Math.max(1600, width * 1.5);
4624
+ const mh = Math.max(1200, height * 1.2);
4625
+ mockupCanvas.width = mw;
4626
+ mockupCanvas.height = mh;
4627
+ const mCtx = mockupCanvas.getContext('2d');
4628
+
4629
+ // 1. Draw blurred, dark aesthetic background (simulating a premium desk/surface)
4630
+ // A rich dark gradient
4631
+ const bgGrad = mCtx.createRadialGradient(mw/2, mh/2, mh/4, mw/2, mh/2, mw);
4632
+ bgGrad.addColorStop(0, '#2d3748');
4633
+ bgGrad.addColorStop(1, '#1a202c');
4634
+ mCtx.fillStyle = bgGrad;
4635
+ mCtx.fillRect(0, 0, mw, mh);
4636
+
4637
+ // 2. Add subtle grain/texture to background
4638
+ mCtx.fillStyle = 'rgba(255,255,255,0.015)';
4639
+ for(let i=0; i<10000; i++) {
4640
+ mCtx.fillRect(Math.random()*mw, Math.random()*mh, 2, 2);
4641
+ }
4642
+
4643
+ // 3. Draw the paper with drop shadow and rotation
4644
+ mCtx.save();
4645
+
4646
+ // Paper rotation (-3 to +3 degrees)
4647
+ const paperAngle = (Math.random() - 0.5) * 6 * Math.PI / 180;
4648
+ mCtx.translate(mw/2, mh/2);
4649
+ mCtx.rotate(paperAngle);
4650
+
4651
+ // Scale paper so it fits nicely
4652
+ const scale = Math.min((mw * 0.75) / width, (mh * 0.85) / height);
4653
+ const drawW = width * scale;
4654
+ const drawH = height * scale;
4655
+
4656
+ // Drop shadow
4657
+ mCtx.shadowColor = 'rgba(0, 0, 0, 0.45)';
4658
+ mCtx.shadowBlur = 40;
4659
+ mCtx.shadowOffsetX = 15;
4660
+ mCtx.shadowOffsetY = 25;
4661
+
4662
+ // Draw the flat image (which now contains the ink) onto the mockup
4663
+ mCtx.drawImage(finalCanvas, -drawW/2, -drawH/2, drawW, drawH);
4664
+
4665
+ // 4. Add realistic lighting gradient over the paper
4666
+ mCtx.shadowColor = 'transparent'; // turn off shadow for lighting
4667
+ mCtx.globalCompositeOperation = 'overlay';
4668
+ const lightGrad = mCtx.createLinearGradient(-drawW/2, -drawH/2, drawW/2, drawH/2);
4669
+ lightGrad.addColorStop(0, 'rgba(255,255,255,0.15)'); // Light from top-left
4670
+ lightGrad.addColorStop(1, 'rgba(0,0,0,0.1)'); // Shadow at bottom-right
4671
+ mCtx.fillStyle = lightGrad;
4672
+ mCtx.fillRect(-drawW/2, -drawH/2, drawW, drawH);
4673
+
4674
+ mCtx.restore();
4675
+
4676
+ const resultBase64 = mockupCanvas.toDataURL('image/jpeg', 0.92);
4677
  img.src = resultBase64;
4678
 
4679
  const loadingText = img.previousElementSibling;