赞
踩
@echo off color 0a :start set num=0 set "echos= " :num set /a a1=%random%%%3 if "%a1%" == "1" set "a1= " if "%a1%" == "2" set "a1= " if "%a1%" == "0" set /a a1=%random%%%2 set echos=%echos%%a1% set /a num=%num%+1 if "%num%" == "75" echo %echos%&&goto :start goto :num %0
使用步骤:
1.新建文本文档,重命名将后面的txt改成bat
2.右键选择编辑,进入文件
3.复制粘贴代码,保存
4.双击打开运行
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <style type="text/css"> html,body{width: 100%;height: 100%;} body{ background: #000; overflow: hidden; margin: 0; padding: 0; } </style> </head> <body> <canvas id="cvs"></canvas> <script type="text/javascript"> var cvs = document.getElementById("cvs"); var ctx = cvs.getContext("2d"); var cw = cvs.width = document.body.clientWidth; var ch = cvs.height = document.body.clientHeight; //动画绘制对象 var requestAnimationFrame = window.requestAnimationFrame || window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame || window.msRequestAnimationFrame; var codeRainArr = []; //代码雨数组 var cols = parseInt(cw/14); //代码雨列数 var step = 16 ; //步长,每一列内部数字之间的上下间隔 ctx.font = "bold 26px microsoft yahei"; //声明字体,个人喜欢微软雅黑 function createColorCv() { //画布基本颜色 ctx.fillStyle="#242424"; ctx.fillRect(0,0,cw,ch); } //创建代码雨 function createCodeRain() { for (var n = 0; n < cols; n++) { var col = []; //基础位置,为了列与列之间产生错位 var basePos = parseInt(Math.random()*300); //随机速度 3~13之间 var speed = parseInt(Math.random()*10)+3; //每组的x轴位置随机产生 var colx = parseInt(Math.random()*cw) //绿色随机 var rgbr= 0; var rgbg= parseInt(Math.random()*255); var rgbb= 0; //ctx.fillStyle = "rgb("+r+','+g+','+b+")" for (var i = 0; i < parseInt(ch/step)/2; i++) { var code = { x : colx, y : -(step*i)-basePos, speed : speed, // text : parseInt(Math.random()*10)%2 == 0 ? 0 : 1 //随机生成0或者1 text : ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","s","t","u","v","w","x","y","z"][parseInt(Math.random()*11)], //随机生成字母数组中的一个 color : "rgb("+rgbr+','+rgbg+','+rgbb+")" } col.push(code); } codeRainArr.push(col); } } //代码雨下起来 function codeRaining(){ //把画布擦干净 ctx.clearRect(0,0,cw,ch); //创建有颜色的画布 //createColorCv(); for (var n = 0; n < codeRainArr.length; n++) { //取出列 col = codeRainArr[n]; //遍历列,画出该列的代码 for (var i = 0; i < col.length; i++) { var code = col[i]; if(code.y > ch){ //如果超出下边界则重置到顶部 code.y = 0; }else{ //匀速降落 code.y += code.speed; } //颜色也随机变化 //ctx.fillStyle = "hsl("+(parseInt(Math.random()*359)+1)+",30%,"+(50-i*2)+"%)"; //绿色逐渐变浅 //ctx.fillStyle = "hsl(123,30%,"+(30-i*2)+"%)"; //绿色随机 //var r= 0; //var g= parseInt(Math.random()*255) + 3; //var b= 0; //ctx.fillStyle = "rgb("+r+','+g+','+b+")" ctx.fillStyle = code.color; //把代码画出来 ctx.fillText(code.text,code.x,code.y); } } requestAnimationFrame(codeRaining); } //创建代码雨 createCodeRain(); //开始下雨吧 GO>> requestAnimationFrame(codeRaining); </script> </body> </html>
使用步骤:
1.新建文本文档,重命名将txt改成html
2.右键编辑,进入文档
3.复制粘贴代码,保存
4.双击打开运行
import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; import java.awt.image.MemoryImageSource; import java.util.Random; import javax.swing.JDialog; import javax.swing.JPanel; import javax.swing.Timer; public class test extends JDialog implements ActionListener { private Random random = new Random(); private Dimension screenSize; private JPanel graphicsPanel; //行高,列宽 private final static int gap = 20; //存放雨点顶部的位置信息(marginTop) private int[] posArr; //行数 private int lines; //列数 private int columns; public test() { initComponents(); } private void initComponents() { setLayout(new BorderLayout()); graphicsPanel = new GraphicsPanel(); add(graphicsPanel, BorderLayout.CENTER); //设置光标不可见 Toolkit defaultToolkit = Toolkit.getDefaultToolkit(); Image image = defaultToolkit.createImage(new MemoryImageSource(0, 0, null, 0, 0)); Cursor invisibleCursor = defaultToolkit.createCustomCursor(image, new Point(0, 0), "cursor"); setCursor(invisibleCursor); //ESC键退出 KeyPressListener keyPressListener = new KeyPressListener(); this.addKeyListener(keyPressListener); //this.setAlwaysOnTop(true); //去标题栏 this.setUndecorated(true); //全屏 this.getGraphicsConfiguration().getDevice().setFullScreenWindow(this); this.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); setVisible(true); screenSize = Toolkit.getDefaultToolkit().getScreenSize(); lines = screenSize.height / gap; columns = screenSize.width / gap; posArr = new int[columns + 1]; random = new Random(); for (int i = 0; i < posArr.length; i++) { posArr[i] = random.nextInt(lines); } //每秒10帧 new Timer(100, this).start(); } /** * @return 随机字符 */ private char getChr() { return (char) (random.nextInt(94) + 33); } @Override public void actionPerformed(ActionEvent e) { graphicsPanel.repaint(); } private class GraphicsPanel extends JPanel { @Override public void paint(Graphics g) { Graphics2D g2d = (Graphics2D) g; g2d.setFont(getFont().deriveFont(Font.BOLD)); g2d.setColor(Color.BLACK); g2d.fillRect(0, 0, screenSize.width, screenSize.height); //当前列 int currentColumn = 0; for (int x = 0; x < screenSize.width; x += gap) { int endPos = posArr[currentColumn]; g2d.setColor(Color.CYAN); g2d.drawString(String.valueOf(getChr()), x, endPos * gap); int cg = 0; for (int j = endPos - 15; j < endPos; j++) { //颜色渐变 cg += 20; if (cg > 255) { cg = 255; } g2d.setColor(new Color(0, cg, 0)); g2d.drawString(String.valueOf(getChr()), x, j * gap); } //每放完一帧,当前列上雨点的位置随机下移1~5行 posArr[currentColumn] += random.nextInt(5); //当雨点位置超过屏幕高度时,重新产生一个随机位置 if (posArr[currentColumn] * gap > getHeight()) { posArr[currentColumn] = random.nextInt(lines); } currentColumn++; } } } private class KeyPressListener extends KeyAdapter { @Override public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { System.exit(0); } } } public static void main(String[] args) { new test(); } }
使用步骤:
1.如一二所示,建立Java文件
2.编译运行
#include <stdio.h> #include <time.h> #include <Windows.h> #include <graphics.h> #define WIDTH 960 #define HEIGHT 640 #define STR_SIZE 20 #define STR_NUM 128 #define STR_WIDTH 15 typedef struct Rain { int x; int y; int speed; TCHAR str[STR_SIZE]; }Rain; Rain rain[STR_NUM]; // 随机生成一个字符 char CreateCh() { char ch = 0; int flag = rand() % 3; // 0~2 if (flag == 0) ch = rand() % 26 + 'a'; // 产生小写字母a~z else if (flag == 1) ch = rand() % 26 + 'A'; // 产生大写字母A~Z else ch = rand() % 10 + '0'; // 产生数字0~9 return ch; } // 初始化结构体成员 void InitRain() { // 初始化字符的位置和速度 for (int i = 0; i < STR_NUM; ++i) { rain[i].x = i * STR_WIDTH; rain[i].y = rand() % HEIGHT; rain[i].speed = rand() % 5 + 5; } // 获取随机字符填充进数组 for (int i = 0; i < STR_NUM; i++) { for (int j = 0; j < STR_SIZE; j++) { rain[i].str[j] = CreateCh(); } } } // 输出到窗口中 void DrawRain() { cleardevice(); for (int i = 0; i < STR_NUM; i++) { for (int j = 0; j < STR_SIZE; j++) { outtextxy(rain[i].x, rain[i].y - STR_WIDTH * j, rain[i].str[j]); settextcolor(RGB(0, 255 - j * 13, 0)); } } } // 移动字符 void MoveRain() { for (int i = 0; i < STR_NUM; i++) { rain[i].y += rain[i].speed; if (rain[i].y - STR_WIDTH * STR_SIZE > HEIGHT) { rain[i].y = 0; } } } // 随机改变字符 void ChangeCh() { for (int i = 0; i < STR_NUM; i++) { rain[rand() % STR_NUM].str[rand() % STR_SIZE] = CreateCh(); } } int main() { srand((unsigned int)time(NULL)); // 初始化随机数种子 initgraph(WIDTH, HEIGHT); InitRain(); DWORD t1, t2; t1 = GetTickCount(); t2 = t1; while (1) { BeginBatchDraw(); // 双缓冲机制 DrawRain(); ChangeCh(); if (t2 - t1 > 20) { MoveRain(); t1 = t2; } t2 = GetTickCount(); EndBatchDraw(); } getchar(); closegraph(); return 0; }
import random import pygame from pygame.locals import * from sys import exit PANEL_width = 1920 PANEL_highly = 1080 FONT_PX = 20 pygame.init() # 创建一个可是窗口 winSur = pygame.display.set_mode((PANEL_width, PANEL_highly), FULLSCREEN, 32) font = pygame.font.SysFont("123.ttf", 25) bg_suface = pygame.Surface((PANEL_width, PANEL_highly), flags=pygame.SRCALPHA) pygame.Surface.convert(bg_suface) bg_suface.fill(pygame.Color(0, 0, 0, 16)) winSur.fill((0, 0, 0)) # 数字版 # texts = [font.render(str(i), True, (0, 255, 0)) for i in range(10)] # # 二进制版 # letter = ['1', '0', '1', '1', '1', '0', '0', '0', '1', '0', '1', '0', '1', '0', '0', '1', '1', '0', '0', '0', '1', '1' # ,'1', '0', '1', '0', '0', '1', '0', '1'] # # 汉字版,你看不到字 # letter = ['我', '爱', '你', '我', '爱你', '我爱你', '我非常爱你', '我爱你', '我爱', '我', '爱', '你', # '我爱你', '爱', '我', '爱你', '我', '我爱', '爱你', '你'] # # 字母版 letter = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v' ,'w', 'x', 'y', 'z'] texts = [ font.render(str(letter[i]), True, (0, 255, 0)) for i in range(20) ] # 按屏幕的宽带计算可以在画板上放几列坐标并生成一个列表 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.QUIT: exit() elif event.type == pygame.KEYDOWN: chang = pygame.key.get_pressed() if (chang[32]): exit() # 将暂停一段给定的毫秒数 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] += 1 if drops[i] * 10 > PANEL_highly or random.random() > 0.95: drops[i] = 0 pygame.display.flip()
有同学问到,怎么在手机上使用呀,现在就告诉大家
链接:https://pan.baidu.com/s/12eel9ARFw8xSts3nQljneg
提取码:x052
1.最简单的方法就是用HTML,在网盘下载之后会有一个叫做***代码雨.html***的文件,只需要用浏览器打开就可以了,如果出现打不开的情况,多尝试几遍,或者用不同的浏览器就好了。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。