当前位置:网站首页>[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…
边栏推荐
- Open Source License Description LGPL
- HDU 1114: Piggy-Bank ← The Complete Knapsack Problem
- 剑指offer专项突击版第20天
- Snapback - same tree
- 虚拟内存原理与技术
- 2022高处安装、维护、拆除考试题模拟考试题库及在线模拟考试
- Object.defineProperty monitors data changes in real time and updates the page
- The pit of std::string::find return value
- 注意潍坊开具发票一般需要注意
- QT language file production
猜你喜欢

大像素全景制作完成后,推广方式有哪些?

The linear table lookup

Talking about data security governance and privacy computing

腾讯云【Hiflow】新时代自动化工具

龙蜥社区第二届理事大会圆满召开!理事换届选举、4 位特约顾问加入

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

基于左序遍历的数据存储实践

云原生(三十二) | Kubernetes篇之平台存储系统介绍

How to sort multiple fields and multiple values in sql statement

Ant Sword Advanced Module Development
随机推荐
21天学习挑战赛(2)图解设备树的使用
Likou - preorder traversal, inorder traversal, postorder traversal of binary tree
1527. 患某种疾病的患者
语法基础(变量、输入输出、表达式与顺序语句)
Intersection of Boolean Operations in SuperMap iDesktop.Net - Repairing Complex Models with Topological Errors
北斗三号短报文终端露天矿山高边坡监测方案
Study Notes-----Left-biased Tree
QT语言文件制作
Turn: Charles Handy: Who you are is more important than what you do
论治理与创新,2022 开放原子全球开源峰会 OpenAnolis 分论坛圆满落幕
1667. 修复表中的名字
In 2022, you still can't "low code"?Data science can also play with Low-Code!
VSCode Change Default Terminal how to modify the Default Terminal VSCode
Gantt chart is here, project management artifact, template is used directly
undo问题
开源协议说明LGPL
Countdown to 2 days|Cloud native Meetup Guangzhou Station, waiting for you!
Programmer's Tanabata Romantic Moment
注意潍坊开具发票一般需要注意
J9 Digital Currency: What is the creator economy of web3?