Prometech Computer Sciences Corp commited on
Commit
1ed9dac
·
verified ·
1 Parent(s): 8a1490b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +75 -76
app.py CHANGED
@@ -766,7 +766,81 @@ with gr.Blocks(title="PrettyBird – Behavioral Consciousness Engine (BCE)") as
766
  <div id="stars2"></div>
767
  <div id="stars3"></div>
768
  """)
769
- gr.HTML('<canvas id="pb-binary"></canvas>')
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
770
 
771
  gr.Markdown(HEADER_MD)
772
 
@@ -837,80 +911,5 @@ with gr.Blocks(title="PrettyBird – Behavioral Consciousness Engine (BCE)") as
837
  elem_classes=["pb-audio"]
838
  )
839
 
840
- BINARY_JS = r"""
841
- () => {
842
- // bazen DOM geç geliyor; küçük retry
843
- const tryInit = (tries=0) => {
844
- const canvas = document.getElementById("pb-binary");
845
- if (!canvas) {
846
- if (tries < 40) setTimeout(() => tryInit(tries+1), 150);
847
- return;
848
- }
849
-
850
- const ctx = canvas.getContext("2d", { alpha: true });
851
- const COLORS = ["#118188", "#233cad"];
852
- const PHRASE = "CICIKUŞ PROMETECH DAVRANIŞSAL BİLİNÇ MOTORU";
853
-
854
- let w=0, h=0, cols=0, drops=[], fontSize=16;
855
-
856
- const resize = () => {
857
- const dpr = Math.max(1, window.devicePixelRatio || 1);
858
- w = Math.floor(window.innerWidth);
859
- h = Math.floor(window.innerHeight);
860
-
861
- canvas.style.width = w + "px";
862
- canvas.style.height = h + "px";
863
- canvas.width = Math.floor(w * dpr);
864
- canvas.height = Math.floor(h * dpr);
865
- ctx.setTransform(dpr, 0, 0, dpr, 0, 0);
866
-
867
- fontSize = Math.max(14, Math.min(20, Math.floor(w / 80)));
868
- cols = Math.max(10, Math.floor(w / fontSize));
869
- drops = new Array(cols).fill(0).map(() => Math.random() * h);
870
- };
871
-
872
- const pickChar = () => {
873
- if (Math.random() < 0.06) return PHRASE[Math.floor(Math.random() * PHRASE.length)];
874
- return Math.random() < 0.5 ? "0" : "1";
875
- };
876
-
877
- const draw = () => {
878
- // iz bırakma: çok karartmasın diye alpha düşük
879
- ctx.fillStyle = "rgba(0,0,0,0.05)";
880
- ctx.fillRect(0, 0, w, h);
881
-
882
- ctx.font = fontSize + "px VT323, monospace";
883
-
884
- for (let i = 0; i < cols; i++) {
885
- const x = i * fontSize;
886
- const y = drops[i];
887
- const ch = pickChar();
888
- const c = COLORS[(i + Math.floor(y / fontSize)) % COLORS.length];
889
-
890
- ctx.shadowColor = c;
891
- ctx.shadowBlur = 10;
892
- ctx.fillStyle = c;
893
- ctx.fillText(ch, x, y);
894
-
895
- // orta hız
896
- drops[i] += fontSize * (0.9 + Math.random() * 0.5);
897
-
898
- if (drops[i] > h + 60 && Math.random() > 0.985) {
899
- drops[i] = -Math.random() * 300;
900
- }
901
- }
902
- requestAnimationFrame(draw);
903
- };
904
-
905
- resize();
906
- window.addEventListener("resize", resize, { passive: true });
907
- draw();
908
- };
909
-
910
- tryInit();
911
- }
912
- """
913
-
914
  if __name__ == "__main__":
915
  demo.launch()
916
- demo.load(None, None, None, js=BINARY_JS)
 
766
  <div id="stars2"></div>
767
  <div id="stars3"></div>
768
  """)
769
+ gr.HTML(r"""
770
+ <canvas id="pb-binary"></canvas>
771
+ <script>
772
+ (function () {
773
+ const COLORS = ["#118188", "#233cad"]; // camgöbeği + codeblue
774
+ const PHRASE = "CICIKUŞ PROMETECH DAVRANIŞSAL BİLİNÇ MOTORU";
775
+
776
+ function init() {
777
+ const canvas = document.getElementById("pb-binary");
778
+ if (!canvas) return false;
779
+
780
+ const ctx = canvas.getContext("2d", { alpha: true });
781
+ let w=0, h=0, cols=0, drops=[], fontSize=16;
782
+
783
+ function resize() {
784
+ const dpr = Math.max(1, window.devicePixelRatio || 1);
785
+ w = Math.floor(window.innerWidth);
786
+ h = Math.floor(window.innerHeight);
787
+
788
+ canvas.style.width = w + "px";
789
+ canvas.style.height = h + "px";
790
+ canvas.width = Math.floor(w * dpr);
791
+ canvas.height = Math.floor(h * dpr);
792
+ ctx.setTransform(dpr, 0, 0, dpr, 0, 0);
793
+
794
+ fontSize = Math.max(14, Math.min(20, Math.floor(w / 80)));
795
+ cols = Math.max(12, Math.floor(w / fontSize));
796
+ drops = new Array(cols).fill(0).map(() => Math.random() * h);
797
+ }
798
+
799
+ function pickChar() {
800
+ if (Math.random() < 0.06) return PHRASE[Math.floor(Math.random() * PHRASE.length)];
801
+ return Math.random() < 0.5 ? "0" : "1";
802
+ }
803
+
804
+ function draw() {
805
+ // trail bırak, ama öldürme
806
+ ctx.fillStyle = "rgba(0,0,0,0.06)";
807
+ ctx.fillRect(0, 0, w, h);
808
+
809
+ ctx.font = fontSize + "px VT323, monospace";
810
+
811
+ for (let i = 0; i < cols; i++) {
812
+ const x = i * fontSize;
813
+ const y = drops[i];
814
+ const ch = pickChar();
815
+ const c = COLORS[(i + Math.floor(y / fontSize)) % COLORS.length];
816
+
817
+ ctx.shadowColor = c;
818
+ ctx.shadowBlur = 12;
819
+ ctx.fillStyle = c;
820
+ ctx.fillText(ch, x, y);
821
+
822
+ drops[i] += fontSize * (0.9 + Math.random() * 0.55);
823
+ if (drops[i] > h + 80 && Math.random() > 0.985) drops[i] = -Math.random() * 320;
824
+ }
825
+
826
+ requestAnimationFrame(draw);
827
+ }
828
+
829
+ resize();
830
+ window.addEventListener("resize", resize, { passive: true });
831
+ draw();
832
+ return true;
833
+ }
834
+
835
+ // Gradio DOM bazen geç geliyor → retry
836
+ let tries = 0;
837
+ const t = setInterval(() => {
838
+ tries++;
839
+ if (init() || tries > 60) clearInterval(t);
840
+ }, 150);
841
+ })();
842
+ </script>
843
+ """)
844
 
845
  gr.Markdown(HEADER_MD)
846
 
 
911
  elem_classes=["pb-audio"]
912
  )
913
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
914
  if __name__ == "__main__":
915
  demo.launch()