怎么用编程做红色爱心

时间:2025-01-26 08:02:18 网络游戏

使用Python的turtle库

```python

import turtle

import math

def draw_heart():

turtle.color('red')

turtle.begin_fill()

turtle.left(140)

turtle.forward(224)

for i in range(200):

turtle.right(1)

turtle.forward(2)

turtle.left(120)

for i in range(200):

turtle.right(1)

turtle.forward(2)

turtle.forward(224)

turtle.end_fill()

turtle.speed(0)

turtle.bgcolor('black')

turtle.penup()

turtle.goto(0, -200)

turtle.pendown()

draw_heart()

turtle.done()

```

使用HTML和CSS

```html