黑客数字雨

news/2024/11/28 7:47:27/

代码


import random
import pygame
pygame.init()
screenInfo = pygame.display.Info()
PANEL_width = screenInfo.current_w
PANEL_highly = screenInfo.current_h
FONT_PX = 15
winSur = pygame.display.set_mode((PANEL_width, PANEL_highly))  # 全屏模式
font = pygame.font.SysFont("arial", 20)
bg_suface = pygame.Surface((PANEL_width, PANEL_highly), flags=pygame.SRCALPHA)
pygame.Surface.convert(bg_suface)
bg_suface.fill(pygame.Color(0, 0, 0, 28))
winSur.fill((0, 0, 0))
letter = ["0", "1"]
texts = [font.render(str(letter[i]), True, (0, 255, 0))for i in range(len(letter))]
column = int(PANEL_width / FONT_PX)
drops = [0 for i in range(column)]
while True:for event in pygame.event.get():if event.type == pygame.KEYDOWN:  # 按esc键退出pygame.quit()pygame.time.delay(30)winSur.blit(bg_suface, (0, 0))for i in range(len(drops)):text = random.choice(texts)winSur.blit(text, (i * FONT_PX, drops[i] * FONT_PX))drops[i] += 1if drops[i] * 10 > PANEL_highly or random.random() > 0.95:drops[i] = 0pygame.display.flip()

效果
请添加图片描述

网页版


<!DOCTYPE html>
<html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta http-equiv="X-UA-Compatible" content="ie=edge"><title>黑客数字雨</title><style>body {margin: 0;padding: 0;}.bind {width: 200px;height: 200px;margin: 0 auto;margin-top: 150px;top: 50%;left: 50%;transition: all 1s ease 0s;}.icon {cursor: pointer;opacity: 0.9;animation: move 2s linear infinite;}@keyframes move {0% {transform: scale(0.5, 0.5);}100% {transform: scale(1, 1);}}canvas {width: 100%;height: 100%;}</style>
</head><body><div class="bind" onclick="start()"><svg id="icon" t="1633583358049" class="icon" viewBox="0 0 1024 1024" version="1.1"xmlns="http://www.w3.org/2000/svg" p-id="2404" width="200" height="200"><pathd="M329.4 460.5c10-2.3 16.3-12.2 14.1-22.3-4.7-21.1-5.5-42.7-2.1-64.3 14.6-94.2 103.1-159.1 197.4-144.5 22.2 3.4 43.2 11 62.3 22.4 8.9 5.3 20.3 2.4 25.5-6.4 5.3-8.8 2.4-20.3-6.4-25.6-23.3-13.9-48.7-23.1-75.7-27.3-114.5-17.7-222.2 61-239.9 175.6-4 26.2-3.2 52.5 2.6 78.2 1.9 8.7 9.6 14.6 18.2 14.6 1.3 0.1 2.7-0.1 4-0.4z"fill="#1afa29" p-id="2405"></path><pathd="M847.9 599.4c0-26.6-10.5-50.1-28-66.4 17.6-40.7 27.5-85.5 27.5-132.7 0-184.8-150.3-335.1-335.1-335.1S177.2 215.5 177.2 400.3c0 110.7 54.1 208.8 137 269.9 0.6 3.3 1.3 6.6 2.3 9.9 3.2 10.8 7.5 20.4 13 28.8 30.1 45.8 64.1 97.7 97.9 148.3 34.2 51.2 83.8 83.1 147.2 94.7 8 1.4 15.3 2.4 22.3 3.3 3.4 0.5 6.8 0.9 10.2 1.4 2.7 0.4 5.3 0.6 8 0.6h37.8c3 0 6-0.2 8.9-0.7 3.3-0.5 6.7-1.1 10-1.6 5.7-0.9 11.5-1.8 17.2-2.8 80.2-13.8 140.7-74.1 154.3-153.7 2.8-15.9 4.2-32 4.3-47.7 0.2-59.7 0.2-67.2 0.2-91.4 0.1-12.3 0.1-29.1 0.1-59.9z m-614.8-199c0-154.2 125-279.2 279.3-279.2 154.2 0 279.2 125 279.2 279.2 0 39.1-8.2 76.3-22.7 110.1-2.6-0.2-5.2-0.4-7.9-0.4-8.1 0-16 1.1-23.5 3.2-8.7-8.2-19.1-14.7-30.8-18.7-1.9-0.6-3.9-1.2-5.8-1.7 9.2-18.6 15.9-38.8 19.2-60.4 7.2-46.4-1-92.7-23.7-133.7-5-9-16.3-12.3-25.3-7.3-9 5-12.3 16.3-7.3 25.3 18.7 33.8 25.4 71.8 19.5 110-3.7 24.1-12.4 46.2-24.7 65.5-1.1 0.3-2.3 0.4-3.3 0.7-7.7-7-16.9-12.8-27.4-17.3-8-4.2-17-6.5-26.2-6.5h-1.9v-65c0-45.4-30.1-80.6-75-87.7-4.2-0.7-8.4-1-12.5-1-43.9 0-82.4 35.3-85.9 78.6-0.4 5.6-0.4 10.2-0.4 14V550c-17.4-10-33.1-22.9-46.2-38.6-6.6-7.9-18.3-8.9-26.2-2.3-7.9 6.6-8.9 18.3-2.3 26.2 9.1 10.9 19.3 20.6 30.2 29.3-22.6 5.8-42.5 20.2-54.8 40.5-0.5 0.8-0.8 1.6-1.3 2.4-56.8-51.1-92.3-125-92.3-207.1z m558.8 350.2c0 12.8-1.3 25.9-3.5 38.6-9.6 56.2-52.1 98.3-108.5 108-8.9 1.5-17.8 2.8-26.8 4.3h-37.8c-10.1-1.5-20.4-2.6-30.5-4.4-46.5-8.5-84.3-31-110.8-70.7-32.8-49.2-65.3-98.5-97.7-147.9-2.7-4.2-4.7-9-6.1-13.8-6.1-20.9 6.2-42.4 26.8-46.4 3-0.6 5.9-0.9 8.6-0.9 12.5 0 23.1 5.6 31.3 16.2 13.6 17.6 26.4 35.7 39.6 53.6l4.2 5.7c0.3-0.2 0.7-0.3 1.1-0.4v-5-279.2c0-3.2 0-6.3 0.2-9.5 1.2-14.7 15.6-27.2 30.2-27.2 1.3 0 2.6 0.1 3.9 0.3 17.4 2.7 27.8 14.8 27.8 32.5 0 49.7 0 132.9 0.1 182.6 0 2.6 0.2 5.3 0.9 7.7 1.3 4 4.3 6.2 8.6 6.5h0.9c4.1 0 7.2-2.1 8.8-5.7 1-2.3 1.1-5.1 1.1-7.7v-22.5-6.6c0-11.2 3.8-21 13.3-27.6 3.5-2.4 7.7-3.9 11.6-5.8h12.6c0.5 0.3 0.8 0.7 1.3 0.9 16.3 5.6 23.9 16.2 23.9 33.4v22.2-16.4 22.2c0 1.6-0.1 3.2 0.1 4.7 0.7 5.4 4.8 8.9 10 8.9h1c5.5-0.5 8.7-4.2 9-11.1v-0.2-1.2-10.6c0.2-7.3 2-14.2 6.7-20.2 6.2-7.8 15.2-12.1 24.6-12.1 3.4 0 6.9 0.6 10.2 1.7 12.9 4.4 21.2 17 21.2 31.9v28c0 1.9 0 3.9 0.2 5.8 0.6 5.1 3.9 7.7 8.6 8.6 0.5 0.1 1 0.1 1.5 0.1 3.7 0 7.7-2.6 8.9-6.3 0.8-2.4 1-5.1 1-7.7V602v11.3s0.1-3.4 0.1-13.2c0-5.4 1-11.3 3.2-16.3 4.7-11.1 16-17.8 27.7-17.8 2.2 0 4.3 0.2 6.4 0.7 15.1 3.3 24.6 16.1 24.6 32.7 0 90.3 0.1 60.8-0.1 151.2z"fill="#1afa29" p-id="2406"></path></svg></div><canvas id="canvas" style="width: 100%;height: 100%;background:#111;display: none;"></canvas><script>//获取画布对象var can = document.querySelector("canvas");//获取画布的上下文var ctx = can.getContext("2d");//设置canvas的宽度和高度can.width = window.innerWidth;can.height = window.innerHeight;console.log(can.width)//每个文字的字体大小var fontSize = 16;//计算列var colunms = Math.floor(window.innerWidth / fontSize);//记录每列文字的y轴坐标var arr = [];//给每一个文字初始化一个起始点的位置for (var i = 0; i < colunms; i++) {arr.push(0);}//运动的文字var str = "01";function start() {console.log('start')document.getElementById("canvas").style.display = "";//显示var elem = document.getElementById("canvas");requestFullScreen(elem); // 某个页面元素}var times;//全屏功能function requestFullScreen(element) {draw()// 流动速度times = setInterval(() => {draw()}, 30);// 判断各种浏览器,找到正确的方法var requestMethod = element.requestFullScreen || //W3Celement.webkitRequestFullScreen || //FireFoxelement.mozRequestFullScreen || //Chrome等element.msRequestFullScreen; //IE11if (requestMethod) {requestMethod.call(element);} else if (typeof window.ActiveXObject !== "undefined") { //for Internet Explorervar wscript = new ActiveXObject("WScript.Shell");if (wscript !== null) {wscript.SendKeys("{F11}");}}}//退出全屏 判断浏览器种类function exitFull() {// 判断各种浏览器,找到正确的方法var exitMethod = document.exitFullscreen || //W3Cdocument.mozCancelFullScreen || //FireFoxdocument.webkitExitFullscreen || //Chrome等document.webkitExitFullscreen; //IE11if (exitMethod) {exitMethod.call(document);} else if (typeof window.ActiveXObject !== "undefined") { //for Internet Explorervar wscript = new ActiveXObject("WScript.Shell");if (wscript !== null) {wscript.SendKeys("{F11}");}}}//监听退出全屏事件window.onresize = function () {if (checkFull()) {clearInterval(times);document.getElementById("canvas").style.display = "none";//显示}}function checkFull() {var isFull = document.fullscreenEnabled || window.fullScreen || document.webkitIsFullScreen || document.msFullscreenEnabled;//to fix : false || undefined == undefinedif (isFull === undefined) { isFull = false; }return isFull;}//绘画的函数function draw() {//布满全屏的黑色遮罩层ctx.fillStyle = "rgba(0,0,0,0.05)";ctx.fillRect(0, 0, window.innerWidth, window.innerHeight);//给字体设置样式ctx.font = "700 " + fontSize + "px  微软雅黑";//给字体添加颜色ctx.fillStyle = "#00cc33";//写入画布中for (var i = 0; i < colunms; i++) {var index = Math.floor(Math.random() * str.length);var x = i * fontSize;var y = arr[i] * fontSize;ctx.fillText(str[index], x, y);//如果文字的Y轴坐标大于画布的高度,1/100*colunms概率将该文字的Y轴坐标重置为0if (y >= can.height && Math.random() > 0.99) {arr[i] = 0;}//文字Y轴坐标+1arr[i]++;}}</script>
</body></html>

http://www.ppmy.cn/news/409313.html

相关文章

个人计算机组装零件,如何组装自己的一台私人电脑?选购配件很重要

前言&#xff1a; 鸟枪和大炮的区别在哪里&#xff1f;在制作工艺&#xff0c;制作材料和制作成本。这次我就亲身体验一下鸟枪换大炮以后感觉怎么样&#xff1f;对于电脑的电源来说一说模组平台就是想到的贵啊&#xff0c;买不起啊&#xff0c;动不动就是上千元的支出真心的消费…

地图加偏解释

根据国家的相关法规&#xff0c;在国内发行的民用地图产品不允许使用真实坐标&#xff0c;必须加入一定偏移&#xff08;出于国家安全考虑&#xff09;。用法律的形式对所有在民用发行的地图类产品加了强制性规范&#xff0c;要求所有地图类产品都必须使用国家测绘局的一种加偏…

首次定位时间TTFF的天花板是多少?教你如何计算TTFF理论值

常见的GPS 芯片/模块的冷启动首次定位时间TTFF&#xff08;Time To First Fix&#xff09;一般在40s左右&#xff0c;那么TTFF理论最短时间的“天花板”是多少&#xff1f; 某款GNSS多模芯片TTFF指标35s 要解答这个问题&#xff0c;首先需要我们来了解一下GPS 导航电文的结构…

使用思博伦卫星导航模拟器GSS7000方法

最近公司在技术研发上投入巨大,购买了一台卫星导航模拟器业内鼎鼎大名的GSS7000,正好借着学习使用的机会记录下使用方法。 1, 硬件连接 ↑如上图所示,首先使用射频同轴电缆线将GSS7000前面板的N 头RF out 接入被测物 (DUT) 的射频天线口。DUT通过USB线接入电脑输出NMEA信…

使用 RTKLIB 测试Ulbox F9P 解算RTK

整个测试的逻辑是&#xff1a; RTKLIB 获取F9P的GNSS原始观测量 千寻CROS站过来的差分RCTM改正信息&#xff0c;最后解算获得高精度定位。 结论&#xff1a;实测中发现RTKLIB 解算RTK算法相对与F9P自身的RTK 弱一点&#xff0c;在开阔环境下只能获得浮点解。 1&#xff0c;设…

卫星导航模拟器GSS7000测试NTRIP RTK--以Ublox F9P 为例.rtklib原始观测量解算固定解FIX

GSS7000 Ntrip 测试指南 Ntrip (Networked Transport of RTCM via Internet Protocol). (通过互联网进行RTCM网络传输的协议) 是在互联网上进行RTK数据传输的协议。 Ntrip是一个应用层协议&#xff0c;可以通过互联网将RTCM改正数据从参考站传输到流动站。最简单的理解NTRIP …

双节锂电升压充电芯片FP6291

FP6291 是一种电流模式&#xff08;CC 模式&#xff09;升压 DC-DC 转换器&#xff0c;其PWM 电路内置 0.2Ω MOSFET使这种转换器具有很好的功率效率&#xff0c;可以搭配 3.3uH小型贴片电感&#xff0c;减少成品体 积&#xff0c;0.6V 精准的参考电压和内部软启动功能可以减少…

远翔小升压FP6291

FP6291 是一种电流模式&#xff08;CC 模式&#xff09;升压 DC-DC 转换器&#xff0c;其PWM 电路内置 0.2Ω MOSFET使这种转换器具有很好的功率效率&#xff0c;可以搭配 3.3uH小型贴片电感&#xff0c;减少成品体 积&#xff0c;0.6V 精准的参考电压和内部软启动功能可以减少…