jhh6576 commited on
Commit
01ee770
·
verified ·
1 Parent(s): 20377b5

Update app_enhanced.py

Browse files
Files changed (1) hide show
  1. app_enhanced.py +27 -7
app_enhanced.py CHANGED
@@ -522,8 +522,8 @@ class EnhancedComicGenerator:
522
  <head>
523
  <meta charset="UTF-8">
524
  <title>Comic Editor</title>
525
- <!-- Use dom-to-image for better mask support on export -->
526
- <script src="https://cdnjs.cloudflare.com/ajax/libs/dom-to-image/2.6.0/dom-to-image.min.js"></script>
527
  <link rel="preconnect" href="https://fonts.googleapis.com">
528
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
529
  <link href="https://fonts.googleapis.com/css2?family=Bangers&family=Comic+Neue:wght@700&family=Gloria+Hallelujah&family=Lato&display=swap" rel="stylesheet">
@@ -539,13 +539,32 @@ class EnhancedComicGenerator:
539
  .panel img { width: 100%; height: 100%; object-fit: cover; object-position: center; transition: transform 0.1s ease-out; }
540
  .panel img.pannable { cursor: grab; }
541
  .panel img.panning { cursor: grabbing; }
542
- .speech-bubble { position: absolute; display: flex; justify-content: center; align-items: center; width: 150px; height: 80px; min-width: 50px; min-height: 30px; box-sizing: border-box; z-index: 10; cursor: move; overflow: visible; font-size: 13px; font-weight: bold; text-align: center; font-family: 'Comic Neue', cursive; }
543
- .bubble-text { padding: 0.8em; word-wrap: break-word; }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
544
  .speech-bubble.selected { outline: 2px dashed #4CAF50; }
545
  .speech-bubble textarea { position: absolute; top: 0; left: 0; width: 100%; height: 100%; box-sizing: border-box; border: 1px solid #4CAF50; background: rgba(255,255,255,0.95); font: inherit; text-align: center; resize: none; padding: 8px; z-index: 102; }
546
 
547
  /* <<< USER REQUESTED EXACT CSS (#5 Shape) with Mask >>> */
548
- /* NOTE: dom-to-image is required for this to export correctly. */
549
 
550
  .speech-bubble.speech {
551
  --b: 3em; /* tail base width */
@@ -1060,8 +1079,8 @@ class EnhancedComicGenerator:
1060
  alert(`Starting export of ${pages.length} page(s).`);
1061
  for (let i = 0; i < pages.length; i++) {
1062
  try {
1063
- // SWITCHED TO DOM-TO-IMAGE FOR MASK SUPPORT
1064
- const dataUrl = await domtoimage.toPng(pages[i]);
1065
  const link = document.createElement('a');
1066
  link.download = `comic-page-${i + 1}.png`;
1067
  link.href = dataUrl;
@@ -1237,6 +1256,7 @@ class EnhancedComicGenerator:
1237
  </script>
1238
  </body>
1239
  </html>'''
 
1240
  with open(os.path.join(self.output_dir, 'page.html'), 'w', encoding='utf-8') as f:
1241
  f.write(template_html)
1242
  print("📄 Template files copied successfully!")
 
522
  <head>
523
  <meta charset="UTF-8">
524
  <title>Comic Editor</title>
525
+ <!-- SWAPPED TO html-to-image for PERFECT MASK SUPPORT -->
526
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/html-to-image/1.11.11/html-to-image.min.js"></script>
527
  <link rel="preconnect" href="https://fonts.googleapis.com">
528
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
529
  <link href="https://fonts.googleapis.com/css2?family=Bangers&family=Comic+Neue:wght@700&family=Gloria+Hallelujah&family=Lato&display=swap" rel="stylesheet">
 
539
  .panel img { width: 100%; height: 100%; object-fit: cover; object-position: center; transition: transform 0.1s ease-out; }
540
  .panel img.pannable { cursor: grab; }
541
  .panel img.panning { cursor: grabbing; }
542
+
543
+ /* General Bubble Container */
544
+ .speech-bubble {
545
+ position: absolute;
546
+ display: flex;
547
+ justify-content: center;
548
+ align-items: center;
549
+ width: 150px;
550
+ height: 80px;
551
+ min-width: 50px;
552
+ min-height: 30px;
553
+ box-sizing: border-box;
554
+ z-index: 10;
555
+ cursor: move;
556
+ overflow: visible;
557
+ font-size: 13px;
558
+ font-weight: bold;
559
+ text-align: center;
560
+ font-family: 'Comic Neue', cursive;
561
+ }
562
+ .bubble-text { padding: 0.8em; word-wrap: break-word; position: relative; z-index: 5; }
563
  .speech-bubble.selected { outline: 2px dashed #4CAF50; }
564
  .speech-bubble textarea { position: absolute; top: 0; left: 0; width: 100%; height: 100%; box-sizing: border-box; border: 1px solid #4CAF50; background: rgba(255,255,255,0.95); font: inherit; text-align: center; resize: none; padding: 8px; z-index: 102; }
565
 
566
  /* <<< USER REQUESTED EXACT CSS (#5 Shape) with Mask >>> */
567
+ /* html-to-image supports CSS masks perfectly */
568
 
569
  .speech-bubble.speech {
570
  --b: 3em; /* tail base width */
 
1079
  alert(`Starting export of ${pages.length} page(s).`);
1080
  for (let i = 0; i < pages.length; i++) {
1081
  try {
1082
+ // SWITCHED TO html-to-image FOR BETTER MASK SUPPORT & PIXEL RATIO
1083
+ const dataUrl = await htmlToImage.toPng(pages[i], { pixelRatio: 3 });
1084
  const link = document.createElement('a');
1085
  link.download = `comic-page-${i + 1}.png`;
1086
  link.href = dataUrl;
 
1256
  </script>
1257
  </body>
1258
  </html>'''
1259
+ # --- CORRECTED INDENTATION ---
1260
  with open(os.path.join(self.output_dir, 'page.html'), 'w', encoding='utf-8') as f:
1261
  f.write(template_html)
1262
  print("📄 Template files copied successfully!")