jhh6576 commited on
Commit
b9ce9f8
·
verified ·
1 Parent(s): 52a8ead

Update app_enhanced.py

Browse files
Files changed (1) hide show
  1. app_enhanced.py +41 -51
app_enhanced.py CHANGED
@@ -509,78 +509,60 @@ class EnhancedComicGenerator:
509
  .panel img { width: 100%; height: 100%; object-fit: cover; object-position: center; transition: transform 0.1s ease-out; }
510
  .panel img.pannable { cursor: grab; }
511
  .panel img.panning { cursor: grabbing; }
512
- .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; padding: 8px; box-shadow: 2px 2px 5px rgba(0,0,0,0.3); z-index: 10; cursor: move; overflow: visible; font-size: 13px; font-weight: bold; text-align: center; }
 
 
 
 
 
 
513
  .bubble-text { padding: 2px; word-wrap: break-word; }
514
  .speech-bubble.selected { outline: 2px dashed #4CAF50; }
515
  .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; }
516
 
517
- /* --- NEW BUBBLE STYLES --- */
518
  .speech-bubble.speech {
519
- padding: 20px 30px;
520
- border-radius: 10px;
521
- border: 3px solid black;
522
- background: white;
523
- color: black;
524
  font-family: "Permanent Marker", cursive;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
525
  }
526
- .speech-bubble.speech:before {
527
- content: '';
528
- position: absolute;
529
- bottom: -50px;
530
- height: 50px;
531
- width: 90px;
532
- border-radius: 0 0 100%;
533
- box-shadow: -2px -2px 0 0 #000 inset, -23px 0 0 0 #fff inset, -25px -2px 0 0 #000 inset;
534
- left: 0;
535
- }
536
- .speech-bubble.speech.flipped:before {
537
- border-radius: 0 0 0 100%;
538
- box-shadow: 2px -2px 0 0 #000 inset, 23px 0 0 0 #fff inset, 25px -2px 0 0 #000 inset;
539
- right: 0;
540
- left: auto;
541
- }
542
-
543
  .speech-bubble.thought {
544
  border-radius: 50%;
545
  border: 3px solid black;
546
- background: white;
547
- color: black;
548
  }
549
  .speech-bubble.thought:before {
550
- content: '';
551
- position: absolute;
552
- height: 3px;
553
- width: 3px;
554
- bottom: -20px;
555
- border-radius: 100%;
556
- background: #fff;
557
  left: 20px;
558
  box-shadow: 0 0 0 7px white, 0 0 0 10px black, -20px 15px 0 5px white, -20px 15px 0 8px black, -40px 20px 0 2px white, -40px 20px 0 5px black;
559
  }
560
  .speech-bubble.thought.flipped:before {
561
- right: 20px;
562
- left: auto;
563
  box-shadow: 0 0 0 7px white, 0 0 0 10px black, 20px 15px 0 5px white, 20px 15px 0 8px black, 40px 20px 0 2px white, 40px 20px 0 5px black;
564
  }
565
 
566
  .speech-bubble.reaction {
 
567
  background: #FFD700;
568
  border: 3px solid #E53935;
569
  color: #D32F2F;
570
- font-weight: 900;
571
- border-radius: 50%;
572
- position: relative;
573
- }
574
- .speech-bubble.reaction:before, .speech-bubble.reaction:after {
575
- content: '';
576
- position: absolute;
577
- top: -3px; left: -3px; right: -3px; bottom: -3px;
578
- background: inherit;
579
- clip-path: polygon(50% 0%, 60% 40%, 100% 40%, 70% 65%, 85% 100%, 50% 75%, 15% 100%, 30% 65%, 0% 40%, 40% 40%);
580
- z-index: -1;
581
- }
582
- .speech-bubble.reaction:after {
583
- transform: rotate(20deg);
584
  }
585
 
586
  .speech-bubble.narration { background: #FAFAFA; border: 2px solid #BDBDBD; color: #424242; border-radius: 3px; }
@@ -592,6 +574,7 @@ class EnhancedComicGenerator:
592
  .resize-handle.sw { bottom: -5px; left: -5px; cursor: sw-resize; }
593
  .resize-handle.ne { top: -5px; right: -5px; cursor: ne-resize; }
594
  .resize-handle.nw { top: -5px; left: -5px; cursor: nw-resize; }
 
595
  .edit-controls { position: fixed; bottom: 20px; right: 20px; background: rgba(44, 62, 80, 0.9); color: white; padding: 10px 15px; border-radius: 8px; font-size: 13px; z-index: 1000; box-shadow: 0 4px 12px rgba(0,0,0,0.3); width: 220px; }
596
  .edit-controls h4 { margin: 0 0 10px 0; color: #26a69a; text-align: center; }
597
  .edit-controls button, .edit-controls select, .edit-controls input { margin-top: 5px; padding: 6px 8px; font-size: 12px; border: none; border-radius: 4px; cursor: pointer; font-weight: bold; width: 100%; box-sizing: border-box; }
@@ -729,7 +712,13 @@ class EnhancedComicGenerator:
729
  if(currentlySelectedBubble) currentlySelectedBubble.style.color = e.target.value;
730
  });
731
  document.getElementById('bubble-fill-color').addEventListener('input', (e) => {
732
- if(currentlySelectedBubble) currentlySelectedBubble.style.backgroundColor = e.target.value;
 
 
 
 
 
 
733
  });
734
 
735
  document.addEventListener('mousemove', e => { if (isPanning) panImage(e); if (draggedBubble) drag(e); if(isResizing) resizeBubble(e); });
@@ -816,7 +805,8 @@ class EnhancedComicGenerator:
816
 
817
  const styles = window.getComputedStyle(currentlySelectedBubble);
818
  document.getElementById('bubble-text-color').value = rgbToHex(styles.color);
819
- document.getElementById('bubble-fill-color').value = rgbToHex(styles.backgroundColor);
 
820
  document.getElementById('bubble-type-select').value = currentlySelectedBubble.dataset.type || 'speech';
821
  document.getElementById('font-select').value = styles.fontFamily.split(',')[0].replace(/"/g, "").replace(/'/g, "").trim();
822
 
 
509
  .panel img { width: 100%; height: 100%; object-fit: cover; object-position: center; transition: transform 0.1s ease-out; }
510
  .panel img.pannable { cursor: grab; }
511
  .panel img.panning { cursor: grabbing; }
512
+ .speech-bubble {
513
+ position: absolute; display: flex; justify-content: center; align-items: center;
514
+ width: 150px; height: 80px; min-width: 50px; min-height: 30px;
515
+ box-sizing: border-box;
516
+ box-shadow: 2px 2px 5px rgba(0,0,0,0.3); z-index: 10; cursor: move;
517
+ font-size: 13px; font-weight: bold; text-align: center;
518
+ }
519
  .bubble-text { padding: 2px; word-wrap: break-word; }
520
  .speech-bubble.selected { outline: 2px dashed #4CAF50; }
521
  .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; }
522
 
 
523
  .speech-bubble.speech {
 
 
 
 
 
524
  font-family: "Permanent Marker", cursive;
525
+ color: #000;
526
+ padding: 1em;
527
+ --r: 1.2em; /* radius */
528
+ --b: 2em; /* base */
529
+ --h: 1.5em; /* height */
530
+ --p: 50%;
531
+ --x: 1.8em;
532
+ --c: #FFFFFF;
533
+ border-radius: var(--r) var(--r) min(var(--r),100% - var(--p) - var(--b)/2) min(var(--r),var(--p) - var(--b)/2)/var(--r);
534
+ clip-path: polygon(0 100%,0 0,100% 0,100% 100%,
535
+ clamp(var(--b),var(--p) + var(--b)/2,100%) 100%,
536
+ calc(var(--p) + var(--x)) calc(100% + var(--h)),
537
+ clamp(0%,var(--p) - var(--b)/2,100% - var(--b)) 100%);
538
+ background: var(--c);
539
+ border-image: conic-gradient(var(--c) 0 0) 0 0 1 0/0 0 var(--h) 0/0 999px var(--h) 999px;
540
+ border: 3px solid black;
541
  }
542
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
543
  .speech-bubble.thought {
544
  border-radius: 50%;
545
  border: 3px solid black;
546
+ background: white; color: black;
 
547
  }
548
  .speech-bubble.thought:before {
549
+ content: ''; position: absolute;
550
+ height: 3px; width: 3px; bottom: -20px;
551
+ border-radius: 100%; background: #fff;
 
 
 
 
552
  left: 20px;
553
  box-shadow: 0 0 0 7px white, 0 0 0 10px black, -20px 15px 0 5px white, -20px 15px 0 8px black, -40px 20px 0 2px white, -40px 20px 0 5px black;
554
  }
555
  .speech-bubble.thought.flipped:before {
556
+ right: 20px; left: auto;
 
557
  box-shadow: 0 0 0 7px white, 0 0 0 10px black, 20px 15px 0 5px white, 20px 15px 0 8px black, 40px 20px 0 2px white, 40px 20px 0 5px black;
558
  }
559
 
560
  .speech-bubble.reaction {
561
+ border-radius: 50%;
562
  background: #FFD700;
563
  border: 3px solid #E53935;
564
  color: #D32F2F;
565
+ clip-path: polygon(100% 50%,78% 60%,88% 82%,65% 76%,59% 99%,45% 80%,25% 93%,27% 69%,3% 67%,20% 50%,3% 33%,27% 31%,25% 7%,45% 20%,59% 1%,65% 24%,88% 18%,78% 40%);
 
 
 
 
 
 
 
 
 
 
 
 
 
566
  }
567
 
568
  .speech-bubble.narration { background: #FAFAFA; border: 2px solid #BDBDBD; color: #424242; border-radius: 3px; }
 
574
  .resize-handle.sw { bottom: -5px; left: -5px; cursor: sw-resize; }
575
  .resize-handle.ne { top: -5px; right: -5px; cursor: ne-resize; }
576
  .resize-handle.nw { top: -5px; left: -5px; cursor: nw-resize; }
577
+
578
  .edit-controls { position: fixed; bottom: 20px; right: 20px; background: rgba(44, 62, 80, 0.9); color: white; padding: 10px 15px; border-radius: 8px; font-size: 13px; z-index: 1000; box-shadow: 0 4px 12px rgba(0,0,0,0.3); width: 220px; }
579
  .edit-controls h4 { margin: 0 0 10px 0; color: #26a69a; text-align: center; }
580
  .edit-controls button, .edit-controls select, .edit-controls input { margin-top: 5px; padding: 6px 8px; font-size: 12px; border: none; border-radius: 4px; cursor: pointer; font-weight: bold; width: 100%; box-sizing: border-box; }
 
712
  if(currentlySelectedBubble) currentlySelectedBubble.style.color = e.target.value;
713
  });
714
  document.getElementById('bubble-fill-color').addEventListener('input', (e) => {
715
+ if(currentlySelectedBubble) {
716
+ if (currentlySelectedBubble.classList.contains('speech')) {
717
+ currentlySelectedBubble.style.setProperty('--c', e.target.value);
718
+ } else {
719
+ currentlySelectedBubble.style.backgroundColor = e.target.value;
720
+ }
721
+ }
722
  });
723
 
724
  document.addEventListener('mousemove', e => { if (isPanning) panImage(e); if (draggedBubble) drag(e); if(isResizing) resizeBubble(e); });
 
805
 
806
  const styles = window.getComputedStyle(currentlySelectedBubble);
807
  document.getElementById('bubble-text-color').value = rgbToHex(styles.color);
808
+ const fillColor = currentlySelectedBubble.classList.contains('speech') ? styles.getPropertyValue('--c').trim() : styles.backgroundColor;
809
+ document.getElementById('bubble-fill-color').value = rgbToHex(fillColor);
810
  document.getElementById('bubble-type-select').value = currentlySelectedBubble.dataset.type || 'speech';
811
  document.getElementById('font-select').value = styles.fontFamily.split(',')[0].replace(/"/g, "").replace(/'/g, "").trim();
812