Python
```python
import turtle
设置画布大小和背景颜色
screen = turtle.Screen()
screen.setup(width=600, height=400)
screen.bgcolor("white")
创建五环的颜色列表
colors = ["blue", "yellow", "black", "green", "red"]
创建一个海龟对象
pen = turtle.Turtle()
pen.speed(2)
绘制五环图案
for i in range(5):
pen.penup()
pen.goto(-110 + i * 55, 0)
pen.pendown()
pen.color(colors[i])
pen.circle(50)
隐藏海龟
pen.hideturtle()
关闭画布
turtle.done()
```
JavaScript (使用turtle库)
```javascript
import turtle from 'turtle';
// 创建画布和画笔
const window = turtle.Screen();
const pen = turtle.Turtle();
// 设置画笔颜色和线条宽度
pen.color("red");
pen.width(5);
// 绘制五环图案
pen.penup();
pen.goto(-100, 0);
pen.pendown();
pen.circle(50);
pen.penup();
pen.goto(0, 0);
pen.pendown();
pen.circle(50);
pen.penup();
pen.goto(100, 0);
pen.pendown();
pen.circle(50);
pen.penup();
pen.goto(-50, -50);
pen.pendown();
pen.circle(50);
pen.penup();
pen.goto(50, -50);
pen.pendown();
pen.circle(50);
// 关闭画布
window.exitonclick();
```
JavaScript (使用turtle库简化版)
```javascript
import turtle from 'turtle';
// 初始化turtle画笔
function init() {
turtle.pensize(20);
}
// 绘制圆圈函数
function draw_circle(circle_size=100, x=-250, y=-30, color='blue') {
turtle.penup();
turtle.goto(x, y);
turtle.pendown();
turtle.color(color);
turtle.circle(circle_size);
}
// 调用圆圈绘制函数绘制五个不同颜色的圆环
draw_circle(x=-250, y=-30, color='blue');
draw_circle(x=-150, y=-30, color='black');
draw_circle(x=0, y=-30, color='red');
draw_circle(x=150, y=-30, color='yellow');
draw_circle(x=-100, y=-70, color='green');
```
这些代码示例展示了如何使用Python和JavaScript的turtle库来绘制奥运五环。你可以根据自己的需求修改代码,例如改变画布大小、颜色等,以绘制出不同风格的奥运五环图案。