当前位置:网站首页>[Qixi Festival] Romantic Tanabata, code teaser.Turn love into a gorgeous three-dimensional scene and surprise her (him)!(send code)
[Qixi Festival] Romantic Tanabata, code teaser.Turn love into a gorgeous three-dimensional scene and surprise her (him)!(send code)
2022-08-05 03:06:00 【Trader in IT】
浪漫七夕,An code love
Turn love into gorgeous three-dimensional scene,给她(他)一个惊喜!
又是一年七夕节! coderRomance, of course, little also notcoding.Here for youpython+jsDo show a artifact.希望天下有情人终成眷属,两口子恩爱如初!
话不多少,上代码!
一、python代码(Sweet nothings turned binary code)
python的功能,Will want to express Chinese characters into lattice figure corresponding binary coding.文中HZK16为16*16The Chinese character dot matrix character,Need to download the saved toD盘根目录.
HZK16Font file download link:https://pan.baidu.com/s/1D_6yk79-pfGL4_Xif4DILg?pwd=qxkl 提取码:qxkl
# -*- coding: utf-8 -*-
def hanzi_dianzhen(hanzi):
'''函数功能:To convert input of Chinese characters dot matrix figure of binary strings'''
gbk = hanzi.encode('GBK')
# print('hanzi gbk',gbk)
L = list(gbk)
offset = 94*(L[0]-0xa0 -1) + L[1]-0xa0-1
offset = offset*32
# print('offset is :%d' % offset)
f = open('D:\\HZK16','rb')
# The query word stock for
f.seek(offset)
display = f.read(32)
display = list(display)
comp = [0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01]#Respectively, only the first8位为1(10000000),第7位为1...Used to phase&If a related to1
# 获取汉字codekey
codekey = []
for i in range(16):
for j in range(2):
codekey.append(display[i*2+j])
# 将codekey转为二进制,碰到1则输出,碰到0则输出空格,Chinese character lattice print.
bin_string = ''
for i in range(len(codekey)):
bits = bin(int(str(hex(codekey[i])),16))[2:].zfill(8)
if i % 2 ==0: print('\n')
for k in range(8):
if bits[k] == '1':
print('*',end=' ')
else:
print(' ',end=' ')
bin_string += str(bits)
# print('\n')
# print('汉字:',hanzi)
# print('汉字codekey:',codekey)
# print('汉字bin_string:',bin_string)
return str(bin_string)
def print_bin_list(bin_list):
'''The lattice string output for Chinese characters,每隔256(16*16)位,Newline output next Chinese.'''
for i in range(len(bin_list)):
for j in bin_list[i]:
if j % 16 ==0: print('\n')
if j == '1':
print('*',end=' ')
else:
print(' ',end=' ')
if __name__=='__main__':
hanzi_string = 'She I love you,,Tonight, the Tanabata!' # To express their replacement text.
bin_list = []
for i in hanzi_string:
bin_list.append(hanzi_dianzhen(i))
# 打印输出,检验结果是否正确
print('\nCopy the Chinese character string of binary codelistTo programming in the cat,替换相应字符串.\n',bin_list)
输出一个字,You can see what is the word?
二、js代码部分(Binary code to generate the three-dimensional scene)
Here you need to use the code to programming cat island3.0环境(https://box3.codemao.cn/).注册登录后,Enter the creative learning->地图,点击“新建地图”.
Select blank map
On the left side select script,And enter the followingjs代码,Click the upper right corner of the triangle, run.
js脚本如下,将bits_list The assignment for just nowpython代码的输出结果,Click run the test script:
/* In the specified location quickly built a solid rectangle */
function cubefill(vox, sx, sy, sz, xsize, ysize, zsize){
var xend = sx+xsize
var yend = sy+ysize
var zend = sz+zsize
for(var x=sx;x<xend;x++){
for(var y=sy;y<yend;y++){
for(var z=sz;z<zend;z++){
voxels.setVoxel(x,y,z,vox)
}}}
}
cubefill('carpet_03',0,9,0,256,1,256)
/* In the specified location quickly built a Chinese character */
function hanzi(vox, sx, sy, sz, bits){
// 初始化设定x,y,z坐标
var x = sx;
var y = sy+16;
var z = sz
for (var i=0;i<bits.length;i++){
if (i % 16 ==0){
x = sx;
y = y - 1;
}
if (bits[i] == '1'){
voxels.setVoxel(x, y , z, vox)
}
else{
voxels.setVoxel(x, y , z, 0)
}
x = x + 1;
}
}
/* 汉字点阵码list */
let bits_list = ['0000001000000000000000010000000001111111111111100100000000000010100000000000010000000000000000001111111111111110000000010000000000000001000000000000000100000000000000010000000000000001000000000000000100000000000000010000000000000101000000000000001000000000', '0000001000000000000000010000000001111111111111100100000000000010100000000000010000000000000000001111111111111110000000010000000000000001000000000000000100000000000000010000000000000001000000000000000100000000000000010000000000000101000000000000001000000000', '0000010010000000000011101010000001111000100100000000100010010000000010001000010011111111111111100000100010000000000010001001000000001010100100000000110001100000000110000100000001101000101000000000100100100000000010100001010000101000000101000001000000001100', '0000000001111000001111111000000000010001000100000000100100100000011111111111111001000010000000101000001000000100011111111111100000000100000000000000011111110000000010100010000000001001010000000001000010000000000100010110000000100010000111000000110000001000', '0001000100000000000100010000000000010001000000000010001111111100001000100000010001100100000010001010100001000000001000000100000000100001010100000010000101001000001000100100110000100100010001000010000001000000001000000100000000100001010000000010000010000000', '0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001100000000000001111000000000000111100000000000001100000000000000010000000000000010000000000000010000000000000000000000000000', '0000000100000000000000010000000000000010100000000000010001000000000010000010000000010010000100000010000110001110110000001000010000000000000000000001111111110000000000000001000000000000001000000000000000100000000000000100000000000000100000000000000100000000', '0000001000000000000000010000000001111111111111100100000100000010100010010010010000000101010100000001111111111000000100000001000000010000000100000001111111110000000100000001000000010000000100000001111111110000000100000001000000010000010100000001000000100000', '0000100000100000000010000010000000001000001000000000100000101000011111111111110000001000001000000000100000100000000010000010000000001000001000000000100000100100111111111111111000000000000000000000010001000000000011000011000000010000000110000010000000001000', '0000001000000000000000100000000000000010000000000000001000000000000000100000000000000010000001000000001111111110111111100000000000000010000000000000001000000000000000100000000000000010000001000000001000000100000000100000010000000001111111000000000000000000', '0000001000000000000000100000000000000010000010000000011111111100000001000000100000001000000010000001000000010000001001000001000001000011001000000000000101000000000000001000000000000001000000000000001000000000000001000000000000011000000000000110000000000000', '0000000000000000000000011000000000000011110000000000001111000000000000111100000000000011110000000000001111000000000000011000000000000001100000000000000110000000000000000000000000000001100000000000001111000000000000011000000000000000000000000000000000000000']
/* In the specified location quickly build Chinese characters */
for (var i=0;i<bits_list.length;i++){
hanzi('pink_light',60+i*17,10,60,bits_list[i])
}
- Set the snow effect(Under the sky floating red love),Set the sun,还可以设置背景音乐.
Click on the left side of the project under the most,进行保存.
三、Is romantic,Good is about to begin!
(Here is a screenshot,Of course also can match on music for the video,Double surprise oh!)
愿得一人心,白头不相离. The poem from ZhuoWenJun with sima xiangru's love story,Is has been extended so far,Even being composed songs.遇一人白首,This is most people's dream,If met will cherish.
while True:
if We_Were_in_Love == True:
print('Love each other together forever!')
Love does not need to explain,But occasionally let romantic ornament…
边栏推荐
- 链表的简单描述及代码的简单实现
- leetcode - a subtree of another tree
- The 22-07-31 weeks summary
- Native js realizes the effect of selecting and canceling all the multi-select boxes
- Apache DolphinScheduler, a new generation of distributed workflow task scheduling platform in practice - Medium
- QT:神奇QVarient
- Note that Weifang generally needs to pay attention to issuing invoices
- Cybersecurity and the Metaverse: Identifying Weak Links
- ASP.NET应用程序--Hello World
- 冒泡排序与快速排序
猜你喜欢
OpenGL 工作原理
【 genius_platform software platform development 】 : seventy-six vs the preprocessor definitions written cow force!!!!!!!!!!(in the other groups conding personnel told so cow force configuration to can
J9 Digital Currency: What is the creator economy of web3?
Matlab drawing 3
【已解决】Unity Coroutinue 协程未有效执行的问题
Dynamic management of massive service instances
.NET应用程序--Helloworld(C#)
云原生(三十二) | Kubernetes篇之平台存储系统介绍
2022高处安装、维护、拆除考试题模拟考试题库及在线模拟考试
Why did they choose to fall in love with AI?
随机推荐
Apache DolphinScheduler, a new generation of distributed workflow task scheduling platform in practice - Medium
基于左序遍历的数据存储实践
Tencent Cloud [Hiflow] New Era Automation Tool
torch.roll()
开源协议说明LGPL
Linux下常见的开源数据库,你知道几个?
2022-08-04: Input: deduplicated array arr, the numbers in it only contain 0~9.limit, a number.Return: The maximum number that can be spelled out with arr if the requirement is smaller than limit.from
UOS系统下ksql应用缺少动态库”libtinfo.so.5“问题
语法基础(变量、输入输出、表达式与顺序语句)
语法基础(变量、输入输出、表达式与顺序语句完成情况)
The Tanabata copywriting you want has been sorted out for you!
为什么pca分量没有关联
undo problem
[C language] Detailed explanation of stacks and queues (define, destroy, and data operations)
QT MV\MVC结构
【已解决】Unity Coroutinue 协程未有效执行的问题
sql server 安装提示用户名不存在
Cybersecurity and the Metaverse: Identifying Weak Links
引领数字医学高地,中山医院探索打造未来医院“新范式”
软链接引发的物理备份问题