当前位置:网站首页>[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…
边栏推荐
猜你喜欢

How Jin Cang database correctness verification platform installation file

Intersection of Boolean Operations in SuperMap iDesktop.Net - Repairing Complex Models with Topological Errors

Use SuperMap iDesktopX data migration tool to migrate ArcGIS data

线上MySQL的自增id用尽怎么办?

VSCode Change Default Terminal how to modify the Default Terminal VSCode

QT language file production

通过模拟Vite一起深入其工作原理

Everyone in China said data, you need to focus on core characteristic is what?

Details such as compiling pretreatment

论治理与创新,2022 开放原子全球开源峰会 OpenAnolis 分论坛圆满落幕
随机推荐
word分栏小记
思考(八十八):使用 protobuf 自定义选项,做数据多版本管理
[Fortune-telling-60]: "The Soldier, the Tricky Way"-2-Interpretation of Sun Tzu's Art of War
使用二维码传输文件的小工具 - QFileTrans 1.2.0.1
private封装
引领数字医学高地,中山医院探索打造未来医院“新范式”
The design idea of DMicro, the Go microservice development framework
torch.roll()
剑指offer专项突击版第20天
Snapback - same tree
1667. Fix names in tables
rpc-remote procedure call demo
1667. 修复表中的名字
【 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
What should I do if the self-incrementing id of online MySQL is exhausted?
为什么pca分量没有关联
论治理与创新,2022 开放原子全球开源峰会 OpenAnolis 分论坛圆满落幕
【七夕节】浪漫七夕,代码传情。将爱意变成绚烂的立体场景,给她(他)一个惊喜!(送代码)
Open Source License Description LGPL
Apache DolphinScheduler, a new generation of distributed workflow task scheduling platform in practice - Medium