jhh6576 commited on
Commit
2f0439a
·
verified ·
1 Parent(s): 78a53ec

Update app_enhanced.py

Browse files
Files changed (1) hide show
  1. app_enhanced.py +56 -34
app_enhanced.py CHANGED
@@ -538,73 +538,96 @@ 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; }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
- /* <<< CSS VARIANT #85: CURVED MASKED TAIL >>> */
547
  .speech-bubble.speech {
548
- /* Bubble Variables */
549
- --b: 2.5em; /* tail base width */
550
- --h: 1.5em; /* tail height */
551
- --t: 0.6; /* thickness (0-1) */
552
- --p: var(--tail-pos, 50%); /* position from slider */
553
- --r: 15px; /* radius */
554
-
 
555
  background: var(--bubble-fill-color, #4ECDC4);
556
  color: var(--bubble-text-color, #fff);
557
  padding: 1em;
558
 
559
- /* The specific #85 border radius calculation for the bottom side (default) */
560
- border-radius: var(--r) var(--r) min(var(--r),100% - var(--p) - (1 - var(--t))*var(--b)/2) min(var(--r),var(--p) - (1 - var(--t))*var(--b)/2)/var(--r);
561
- position: relative;
 
 
 
 
 
 
562
  }
563
 
564
- /*
565
- The Tail Shape using Masking.
566
- This pseudo-element creates the curved shark-fin shape.
567
- */
568
  .speech-bubble.speech:before {
569
  content: "";
570
  position: absolute;
571
  width: var(--b);
572
  height: var(--h);
573
- background: inherit; /* Matches bubble color */
574
  border-bottom-left-radius: 100%;
575
  pointer-events: none;
576
 
577
- /* The magic mask gradient that carves the curve */
578
- -webkit-mask: radial-gradient(calc(var(--t)*100%) 105% at 100% 0,#0000 99%,#000 101%);
579
- mask: radial-gradient(calc(var(--t)*100%) 105% at 100% 0,#0000 99%,#000 101%);
580
  }
581
 
582
- /* BOTTOM TAIL (Default) */
583
  .speech-bubble.speech.tail-bottom:before {
584
  top: 100%;
585
- /* Complex clamp to keep tail attached during slider movement */
586
- left: clamp(0%, var(--p) - (1 - var(--t))*var(--b)/2, 100% - (1 - var(--t))*var(--b));
587
  }
588
 
589
- /* TOP TAIL (Reflected) */
590
  .speech-bubble.speech.tail-top {
591
  /* Flip border radius logic for top */
592
- border-radius: min(var(--r),var(--p) - (1 - var(--t))*var(--b)/2) min(var(--r),100% - var(--p) - (1 - var(--t))*var(--b)/2) var(--r) var(--r)/var(--r);
 
 
593
  }
594
  .speech-bubble.speech.tail-top:before {
595
  bottom: 100%;
596
- left: clamp(0%, var(--p) - (1 - var(--t))*var(--b)/2, 100% - (1 - var(--t))*var(--b));
597
- transform: scaleY(-1); /* Flip the curve vertically */
598
  }
599
 
600
  /* LEFT TAIL (Rotated) */
601
  .speech-bubble.speech.tail-left {
602
- /* Fallback radius for side tails to prevent breakage */
603
- border-radius: var(--r);
604
  }
605
  .speech-bubble.speech.tail-left:before {
606
  right: 100%;
607
- top: clamp(0%, var(--p) - (1 - var(--t))*var(--b)/2, 100% - (1 - var(--t))*var(--b));
608
  transform: rotate(90deg);
609
  transform-origin: right top;
610
  }
@@ -615,12 +638,11 @@ class EnhancedComicGenerator:
615
  }
616
  .speech-bubble.speech.tail-right:before {
617
  left: 100%;
618
- top: clamp(0%, var(--p) - (1 - var(--t))*var(--b)/2, 100% - (1 - var(--t))*var(--b));
619
  transform: rotate(-90deg);
620
  transform-origin: left top;
621
  }
622
 
623
- /* Other Bubble Types */
624
  .speech-bubble.thought { background: white; border: 2px dashed #555; color: #333; border-radius: 50%; }
625
  .speech-bubble.reaction { background: #FFD700; border: 3px solid #E53935; color: #D32F2F; font-weight: 900; text-transform: uppercase; width: 180px; clip-path: polygon(0% 25%, 17% 21%, 17% 0%, 31% 16%, 50% 4%, 69% 16%, 83% 0%, 83% 21%, 100% 25%, 85% 45%, 95% 62%, 82% 79%, 100% 97%, 79% 89%, 60% 98%, 46% 82%, 27% 95%, 15% 78%, 5% 62%, 15% 45%); }
626
  .speech-bubble.narration { background: #FAFAFA; border: 2px solid #BDBDBD; color: #424242; border-radius: 3px; }
@@ -683,7 +705,7 @@ class EnhancedComicGenerator:
683
  <div class="color-picker-grid">
684
  <div>
685
  <label for="bubble-text-color">Text</label>
686
- <input type="color" id="bubble-text-color" value="#333333" disabled>
687
  </div>
688
  <div>
689
  <label for="bubble-fill-color">Fill</label>
 
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
+ /* <<< VARIANT #85: MASKED CURVED TAIL >>> */
566
  .speech-bubble.speech {
567
+ /* Variables defined inline via slider, default values here */
568
+ --b: 3em; /* tail base width */
569
+ --h: 1.8em; /* tail height */
570
+ --t: 0.6; /* thickness factor */
571
+ --p: var(--tail-pos, 50%); /* Slider position */
572
+ --r: 15px; /* Border Radius */
573
+
574
+ /* IMPORTANT: Default colors in case var is missing */
575
  background: var(--bubble-fill-color, #4ECDC4);
576
  color: var(--bubble-text-color, #fff);
577
  padding: 1em;
578
 
579
+ /* Robust border-radius calculation using calc() for compatibility */
580
+ /* TopLeft TopRight BottomRight BottomLeft / VerticalRadius */
581
+ border-radius: var(--r) var(--r)
582
+ min(var(--r), calc(100% - var(--p) - (1 - var(--t)) * var(--b) / 2))
583
+ min(var(--r), calc(var(--p) - (1 - var(--t)) * var(--b) / 2))
584
+ / var(--r);
585
+
586
+ /* Ensure it stays absolute to position on image */
587
+ position: absolute;
588
  }
589
 
590
+ /* The Tail Pseudo-Element */
 
 
 
591
  .speech-bubble.speech:before {
592
  content: "";
593
  position: absolute;
594
  width: var(--b);
595
  height: var(--h);
596
+ background: inherit; /* Inherits teal/fill color */
597
  border-bottom-left-radius: 100%;
598
  pointer-events: none;
599
 
600
+ /* Mask gradient to create the 'cutout' curve */
601
+ -webkit-mask: radial-gradient(calc(var(--t)*100%) 105% at 100% 0, #0000 99%, #000 101%);
602
+ mask: radial-gradient(calc(var(--t)*100%) 105% at 100% 0, #0000 99%, #000 101%);
603
  }
604
 
605
+ /* BOTTOM TAIL (Standard) */
606
  .speech-bubble.speech.tail-bottom:before {
607
  top: 100%;
608
+ left: clamp(0%, calc(var(--p) - (1 - var(--t)) * var(--b) / 2), calc(100% - (1 - var(--t)) * var(--b)));
 
609
  }
610
 
611
+ /* TOP TAIL (Flipped) */
612
  .speech-bubble.speech.tail-top {
613
  /* Flip border radius logic for top */
614
+ border-radius: min(var(--r), calc(var(--p) - (1 - var(--t)) * var(--b) / 2))
615
+ min(var(--r), calc(100% - var(--p) - (1 - var(--t)) * var(--b) / 2))
616
+ var(--r) var(--r) / var(--r);
617
  }
618
  .speech-bubble.speech.tail-top:before {
619
  bottom: 100%;
620
+ left: clamp(0%, calc(var(--p) - (1 - var(--t)) * var(--b) / 2), calc(100% - (1 - var(--t)) * var(--b)));
621
+ transform: scaleY(-1);
622
  }
623
 
624
  /* LEFT TAIL (Rotated) */
625
  .speech-bubble.speech.tail-left {
626
+ border-radius: var(--r); /* Simplification for side tails to avoid breakage */
 
627
  }
628
  .speech-bubble.speech.tail-left:before {
629
  right: 100%;
630
+ top: clamp(0%, calc(var(--p) - (1 - var(--t)) * var(--b) / 2), calc(100% - (1 - var(--t)) * var(--b)));
631
  transform: rotate(90deg);
632
  transform-origin: right top;
633
  }
 
638
  }
639
  .speech-bubble.speech.tail-right:before {
640
  left: 100%;
641
+ top: clamp(0%, calc(var(--p) - (1 - var(--t)) * var(--b) / 2), calc(100% - (1 - var(--t)) * var(--b)));
642
  transform: rotate(-90deg);
643
  transform-origin: left top;
644
  }
645
 
 
646
  .speech-bubble.thought { background: white; border: 2px dashed #555; color: #333; border-radius: 50%; }
647
  .speech-bubble.reaction { background: #FFD700; border: 3px solid #E53935; color: #D32F2F; font-weight: 900; text-transform: uppercase; width: 180px; clip-path: polygon(0% 25%, 17% 21%, 17% 0%, 31% 16%, 50% 4%, 69% 16%, 83% 0%, 83% 21%, 100% 25%, 85% 45%, 95% 62%, 82% 79%, 100% 97%, 79% 89%, 60% 98%, 46% 82%, 27% 95%, 15% 78%, 5% 62%, 15% 45%); }
648
  .speech-bubble.narration { background: #FAFAFA; border: 2px solid #BDBDBD; color: #424242; border-radius: 3px; }
 
705
  <div class="color-picker-grid">
706
  <div>
707
  <label for="bubble-text-color">Text</label>
708
+ <input type="color" id="bubble-text-color" value="#ffffff" disabled>
709
  </div>
710
  <div>
711
  <label for="bubble-fill-color">Fill</label>