当前位置:网站首页>[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…
边栏推荐
- 使用二维码传输文件的小工具 - QFileTrans 1.2.0.1
- lua学习
- Images using redis cache Linux master-slave synchronization server hard drive full of moved to the new directory which points to be modified
- Distributed systems revisited: there will never be a perfect consistency scheme...
- Open Source License Description LGPL
- [C language] Detailed explanation of stacks and queues (define, destroy, and data operations)
- 毕设-基于SSM房屋租赁管理系统
- 金仓数据库如何验证安装文件平台正确性
- Use SuperMap iDesktopX data migration tool to migrate ArcGIS data
- How OpenGL works
猜你喜欢
如何在WordPress中添加特定类别的小工具
The usage of try...catch and finally in js
大像素全景制作完成后,推广方式有哪些?
Ant Sword Advanced Module Development
【 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
QT language file production
View handler stepping record
VSCode Change Default Terminal how to modify the Default Terminal VSCode
The 20th day of the special assault version of the sword offer
The linear table lookup
随机推荐
Cybersecurity and the Metaverse: Identifying Weak Links
(十一)元类
Compressed storage of special matrices
Native js realizes the effect of selecting and canceling all the multi-select boxes
Details such as compiling pretreatment
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
Why did they choose to fall in love with AI?
Programmer's Tanabata Romantic Moment
优炫数据库的单节点如何转集群
CPDA|How Operators Learn Data Analysis (SQL) from Negative Foundations
mysql tree structure query problem
Matlab drawing 3
【Daily Training】1403. Minimum Subsequence in Non-Increasing Order
Chinese characters to Pinyin
PostgreSQL数据库 用navicat 打开表结构的时候报错 cannot update secondarysnapshot during a parallel operation 怎么解决?
Regular expression to match a certain string in the middle
如何在WordPress中添加特定类别的小工具
1873. 计算特殊奖金
leetcode - symmetric binary tree
解决端口占用问题 Port xxxx was already in use