动态八卦图html,HTML绘制太极八卦图

实现效果如下:

f0a3ca22e031faab54bedf338f48032b.png

实现代码如下:

太极八卦图

div{

text-align: center;

margin-top: 30px;

}

#mytj{

background-color: skyblue;

}

var mytj = document.getElementById('mytj');

var mt = mytj.getContext('2d');

//左边黑色大半圆

mt.beginPath();

mt.arc(300,300,200,90*Math.PI/180,270*Math.PI/180,false);

mt.fillStyle='#000';

mt.fill();

//右边白色大半圆

mt.beginPath();

mt.arc(300,300,200,270*Math.PI/180,90*Math.PI/180,false);

mt.fillStyle='#fff';

mt.fill();

//左边白色中半圆

mt.beginPath();

mt.arc(300,200,100,90*Math.PI/180,270*Math.PI/180,false);

mt.fillStyle='#fff';

mt.fill();

//右边黑色中半圆

mt.beginPath();

mt.arc(300,400,100,270*Math.PI/180,90*Math.PI/180,false);

mt.fillStyle='#000';

mt.fill();

//左边黑色小圆

mt.beginPath();

mt.arc(300,200,50,0*Math.PI/180,360*Math.PI/180,false);

mt.fillStyle='#000';

mt.fill();

//右边白色小圆

mt.beginPath();

mt.arc(300,400,50,0*Math.PI/180,360*Math.PI/180,false);

mt.fillStyle='#fff';

mt.fill();

来源:https://www.cnblogs.com/lidyfamily/p/11543115.html

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
你可以使用Python的turtle库来绘制太极八卦图。具体步骤如下: 1. 导入turtle库 ```python import turtle ``` 2. 创建画布和画笔 ```python window = turtle.Screen() pen = turtle.Turtle() ``` 3. 设置画笔的颜色和大小 ```python pen.color('black') pen.pensize(3) ``` 4. 绘制圆形和半圆形 ```python # 绘制黑色半圆 pen.begin_fill() pen.fillcolor('black') pen.circle(100, 180) pen.end_fill() # 绘制白色半圆 pen.begin_fill() pen.fillcolor('white') pen.circle(100, -180) pen.end_fill() # 绘制黑色小圆 pen.penup() pen.goto(0, 50) pen.pendown() pen.begin_fill() pen.fillcolor('black') pen.circle(25) pen.end_fill() # 绘制白色小圆 pen.penup() pen.goto(0, -50) pen.pendown() pen.begin_fill() pen.fillcolor('white') pen.circle(25) pen.end_fill() ``` 5. 绘制两个小圆内部的阴阳鱼 ```python # 绘制黑色阴鱼 pen.penup() pen.goto(0, 25) pen.pendown() pen.color('white', 'black') pen.begin_fill() pen.circle(-25, 180) pen.circle(-12.5, -180) pen.left(90) pen.forward(50) pen.end_fill() # 绘制白色阳鱼 pen.penup() pen.goto(0, -25) pen.pendown() pen.color('black', 'white') pen.begin_fill() pen.circle(25, 180) pen.circle(12.5, -180) pen.left(90) pen.forward(-50) pen.end_fill() ``` 6. 隐藏画笔 ```python pen.hideturtle() ``` 完整代码如下: ```python import turtle window = turtle.Screen() pen = turtle.Turtle() pen.color('black') pen.pensize(3) # 绘制黑色半圆 pen.begin_fill() pen.fillcolor('black') pen.circle(100, 180) pen.end_fill() # 绘制白色半圆 pen.begin_fill() pen.fillcolor('white') pen.circle(100, -180) pen.end_fill() # 绘制黑色小圆 pen.penup() pen.goto(0, 50) pen.pendown() pen.begin_fill() pen.fillcolor('black') pen.circle(25) pen.end_fill() # 绘制白色小圆 pen.penup() pen.goto(0, -50) pen.pendown() pen.begin_fill() pen.fillcolor('white') pen.circle(25) pen.end_fill() # 绘制黑色阴鱼 pen.penup() pen.goto(0, 25) pen.pendown() pen.color('white', 'black') pen.begin_fill() pen.circle(-25, 180) pen.circle(-12.5, -180) pen.left(90) pen.forward(50) pen.end_fill() # 绘制白色阳鱼 pen.penup() pen.goto(0, -25) pen.pendown() pen.color('black', 'white') pen.begin_fill() pen.circle(25, 180) pen.circle(12.5, -180) pen.left(90) pen.forward(-50) pen.end_fill() # 隐藏画笔 pen.hideturtle() window.mainloop() ```

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值