jhh6576 commited on
Commit
111bba5
·
verified ·
1 Parent(s): bdb845b

Update app_enhanced.py

Browse files
Files changed (1) hide show
  1. app_enhanced.py +77 -41
app_enhanced.py CHANGED
@@ -538,78 +538,114 @@ class EnhancedComicGenerator:
538
  .panel img { width: 100%; height: 100%; object-fit: cover; object-position: center; transition: transform 0.1s ease-out; }
539
  .panel img.pannable { cursor: grab; }
540
  .panel img.panning { cursor: grabbing; }
541
- .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; }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
542
  .bubble-text { padding: 0.8em; word-wrap: break-word; position: relative; z-index: 5; }
543
  .speech-bubble.selected { outline: 2px dashed #4CAF50; }
544
  .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; }
545
 
546
- /* <<< FIXED "SHARK FIN" TAIL USING BORDER-RADIUS (EXPORT SAFE) >>> */
 
 
 
 
 
547
  .speech-bubble.speech {
548
  --bubble-fill-color: #4ECDC4;
549
  --bubble-text-color: #ffffff;
550
- --bubble-border-color: #333333;
551
- --tail-pos: 50%;
552
 
 
 
 
 
 
 
 
553
  background: var(--bubble-fill-color);
554
  color: var(--bubble-text-color);
555
- border: 2px solid var(--bubble-border-color);
556
- border-radius: 12px;
557
  padding: 1em;
558
  position: absolute;
 
 
 
 
 
 
559
  }
560
 
 
561
  .speech-bubble.speech:before {
562
  content: "";
563
  position: absolute;
564
- width: 22px; height: 22px;
565
- background: var(--bubble-fill-color);
566
- /* The Curve Trick: Square with one rounded corner */
567
- border-bottom-right-radius: 100%;
568
 
569
- /* Optional border simulation if needed, but flat is safer for exact shape match */
570
- z-index: 1;
 
 
571
  }
572
 
573
  /* BOTTOM TAIL */
574
  .speech-bubble.speech.tail-bottom:before {
575
- top: 95%; /* Slight overlap */
576
- left: var(--tail-pos);
577
- transform: translateX(-50%) rotate(45deg) skew(15deg);
578
- border: 2px solid var(--bubble-border-color);
579
- border-top: 0; border-left: 0;
580
  }
581
 
582
- /* TOP TAIL */
 
 
 
 
 
583
  .speech-bubble.speech.tail-top:before {
584
- bottom: 95%;
585
- left: var(--tail-pos);
586
- border-top-left-radius: 100%;
587
- border-bottom-right-radius: 0;
588
- transform: translateX(-50%) rotate(45deg) skew(15deg);
589
- border: 2px solid var(--bubble-border-color);
590
- border-bottom: 0; border-right: 0;
591
  }
592
 
593
- /* LEFT TAIL */
 
 
 
594
  .speech-bubble.speech.tail-left:before {
595
- right: 95%;
596
- top: var(--tail-pos);
597
- border-bottom-left-radius: 100%;
598
- border-bottom-right-radius: 0;
599
- transform: translateY(-50%) rotate(45deg) skew(15deg);
600
- border: 2px solid var(--bubble-border-color);
601
- border-top: 0; border-right: 0;
602
  }
603
 
604
- /* RIGHT TAIL */
 
 
 
605
  .speech-bubble.speech.tail-right:before {
606
- left: 95%;
607
- top: var(--tail-pos);
608
- border-top-right-radius: 100%;
609
- border-bottom-right-radius: 0;
610
- transform: translateY(-50%) rotate(45deg) skew(15deg);
611
- border: 2px solid var(--bubble-border-color);
612
- border-bottom: 0; border-left: 0;
613
  }
614
 
615
  .speech-bubble.thought { background: white; border: 2px dashed #555; color: #333; border-radius: 50%; }
 
538
  .panel img { width: 100%; height: 100%; object-fit: cover; object-position: center; transition: transform 0.1s ease-out; }
539
  .panel img.pannable { cursor: grab; }
540
  .panel img.panning { cursor: grabbing; }
541
+
542
+ /* General Bubble Container */
543
+ .speech-bubble {
544
+ position: absolute;
545
+ display: flex;
546
+ justify-content: center;
547
+ align-items: center;
548
+ width: 150px;
549
+ height: 80px;
550
+ min-width: 50px;
551
+ min-height: 30px;
552
+ box-sizing: border-box;
553
+ z-index: 10;
554
+ cursor: move;
555
+ overflow: visible;
556
+ font-size: 13px;
557
+ font-weight: bold;
558
+ text-align: center;
559
+ font-family: 'Comic Neue', cursive;
560
+ }
561
  .bubble-text { padding: 0.8em; word-wrap: break-word; position: relative; z-index: 5; }
562
  .speech-bubble.selected { outline: 2px dashed #4CAF50; }
563
  .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; }
564
 
565
+ /* <<< EXPORT-SAFE VARIANT #85 (Using Border-Radius Tricks) >>> */
566
+ /*
567
+ Since html2canvas does NOT support CSS masks, we replicate the
568
+ "Shark Fin" shape using carefully crafted border-radius geometry.
569
+ This looks identical but renders perfectly on export.
570
+ */
571
  .speech-bubble.speech {
572
  --bubble-fill-color: #4ECDC4;
573
  --bubble-text-color: #ffffff;
 
 
574
 
575
+ /* The Main Body Bubble Variables */
576
+ --b: 3em; /* Tail base */
577
+ --h: 1.8em; /* Tail height */
578
+ --t: 0.6; /* Thickness */
579
+ --p: var(--tail-pos, 50%);
580
+ --r: 1.2em; /* Radius */
581
+
582
  background: var(--bubble-fill-color);
583
  color: var(--bubble-text-color);
 
 
584
  padding: 1em;
585
  position: absolute;
586
+
587
+ /* Replicate the bubble body shape from the user CSS */
588
+ border-radius: var(--r) var(--r)
589
+ min(var(--r), calc(100% - var(--p) - (1 - var(--t)) * var(--b) / 2))
590
+ min(var(--r), calc(var(--p) - (1 - var(--t)) * var(--b) / 2))
591
+ / var(--r);
592
  }
593
 
594
+ /* The Tail Pseudo-Element (Using Geometric Border Radius) */
595
  .speech-bubble.speech:before {
596
  content: "";
597
  position: absolute;
598
+ width: var(--b);
599
+ height: var(--h);
600
+ background: var(--bubble-fill-color); /* Same as body */
601
+ pointer-events: none;
602
 
603
+ /* This shape mimics the Shark Fin: Square with one rounded corner */
604
+ border-bottom-left-radius: 100%;
605
+
606
+ /* Optional: Use clip-path to clean up edges if needed, but this shape is pure */
607
  }
608
 
609
  /* BOTTOM TAIL */
610
  .speech-bubble.speech.tail-bottom:before {
611
+ top: 100%; /* Attach to bottom */
612
+ /* Exact positioning calc from user CSS */
613
+ left: clamp(0%, calc(var(--p) - (1 - var(--t)) * var(--b) / 2), calc(100% - (1 - var(--t)) * var(--b)));
614
+ /* No rotation needed for bottom-left curve look */
 
615
  }
616
 
617
+ /* TOP TAIL (Flip Vertical) */
618
+ .speech-bubble.speech.tail-top {
619
+ border-radius: min(var(--r), calc(var(--p) - (1 - var(--t)) * var(--b) / 2))
620
+ min(var(--r), calc(100% - var(--p) - (1 - var(--t)) * var(--b) / 2))
621
+ var(--r) var(--r) / var(--r);
622
+ }
623
  .speech-bubble.speech.tail-top:before {
624
+ bottom: 100%;
625
+ left: clamp(0%, calc(var(--p) - (1 - var(--t)) * var(--b) / 2), calc(100% - (1 - var(--t)) * var(--b)));
626
+ transform: scaleY(-1);
 
 
 
 
627
  }
628
 
629
+ /* LEFT TAIL (Rotate 90) */
630
+ .speech-bubble.speech.tail-left {
631
+ border-radius: var(--r);
632
+ }
633
  .speech-bubble.speech.tail-left:before {
634
+ right: 100%;
635
+ top: clamp(0%, calc(var(--p) - (1 - var(--t)) * var(--b) / 2), calc(100% - (1 - var(--t)) * var(--b)));
636
+ transform: rotate(90deg);
637
+ transform-origin: right top;
 
 
 
638
  }
639
 
640
+ /* RIGHT TAIL (Rotate -90) */
641
+ .speech-bubble.speech.tail-right {
642
+ border-radius: var(--r);
643
+ }
644
  .speech-bubble.speech.tail-right:before {
645
+ left: 100%;
646
+ top: clamp(0%, calc(var(--p) - (1 - var(--t)) * var(--b) / 2), calc(100% - (1 - var(--t)) * var(--b)));
647
+ transform: rotate(-90deg);
648
+ transform-origin: left top;
 
 
 
649
  }
650
 
651
  .speech-bubble.thought { background: white; border: 2px dashed #555; color: #333; border-radius: 50%; }