画十字架中的爱心

用tkinter画十字架中的爱心

from tkinter import *
import math
root = Tk()
w = Canvas(root, width=800, height=800)
w.pack()
# 画红色的坐标轴线
width=800
height=800
w0=width/2
h0=height/2
w.create_line(0, h0, width, h0, fill="red")
w.create_line(w0, 0, w0, height, fill="red")

def x(t):
    x = (w0 / 4) * (-2 * math.sin(t) + math.sin(2 * t))
    x+=w0    #平移x轴
    return x
def y(t):
    y = (h0 / 4) * (2 * math.cos(t) - math.cos(2 * t))
    y-=h0    #平移y轴
    y = -y    #y轴值反向
    return y
t = 0.0
while (t<(2*math.pi)):
    w.create_line(x(t), y(t), x(t+0.01), y(t+0.01),fill="blue")
    t+=0.01
root.mainloop()

运行结果:

 

 

利用turtle库绘制一个每方向为100像素长度的十字架

import turtle
for i in range(4):
    turtle.fd(100)
    turtle.fd(-100)
    turtle.seth((i+1)*90)    #seth 绝对角度

运行结果:

 

 

 

``` #include <iostream> #include <fstream> #include <vector> struct Frame {     uint8_t rows[8]; }; std::vector<Frame> generate_emojis() {     std::vector<Frame> frames;     // 四种表情模板     const Frame smile = {{         0b00111100, // 笑脸         0b01000010,         0b10100101,         0b10000001,         0b10100101,         0b10011001,         0b01000010,         0b00111100     }};     const Frame cry = {{         0b00111100, // 哭脸         0b01000010,         0b10100101,         0b10000001,         0b10011001,         0b10100101,         0b01000010,         0b00111100     }};     const Frame heart = {{         0b00000000, // 爱心         0b01100110,         0b11111111,         0b11111111,         0b01111110,         0b00111100,         0b00011000,         0b00000000     }};     const Frame sun = {{         0b00100100, // 太阳         0b00100100,         0b11011011,         0b01111110,         0b00111100,         0b01111110,         0b11011011,         0b00100100     }};     // 生成88帧(22次完整循环)     for (int i = 0; i < 88; ++i) {         switch(i % 4) {  // 四表情循环             case 0: frames.push_back(smile); break;             case 1: frames.push_back(cry);   break;             case 2: frames.push_back(heart); break;             case 3: frames.push_back(sun);   break;         }     }     return frames; } int main() {     std::vector<Frame> emojis = generate_emojis();         std::ofstream file("animation.bin", std::ios::binary);     if (!file) {         std::cerr << "文件创建失败!" << std::endl;         return 1;     }     // 验证帧数     std::cout << "实际生成帧数: " << emojis.size() << std::endl;     // 写入所有帧数据     for (const auto& frame : emojis) {         file.write(reinterpret_cast<const char*>(frame.rows), sizeof(frame.rows));     }     std::cout << "成功生成88帧动文件!" << std::endl;     return 0; }```依照这个代码,给出更多图案(64个)不重复
最新发布
03-17
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值