Here is a Python output with an image:
# draw a flower with module turtle
import turtle as tu
tu.title('I call this one Flower')
# values for speed are 'fastest' (no delay), 'fast', (delay 5ms),
# 'normal' (delay 10ms), 'slow' (delay 15ms), and 'slowest' (delay 20ms)
tu.speed('fastest')
#turtle.color((.3,.5,.3))
tu.color('red')
tu.width(2)
radius = 180 # size of circle --> length of petal
extent = 70 # number of degrees in arc --> width of petal
angle = 0 # start out with a horizontal petal
x1 = 0 # location in X direction
y1 = -20 # location in Y direction
def flower():
tu.up()
tu.goto(x1,y1)
tu.setheading(angle)
tu.left(extent/2)
tu.down()
tu.circle(-radius, extent)
tu.up()
tu.goto(x1,y1)
tu.down()
tu.setheading(angle)
tu.right(extent/2)
# fills half the flower petal
tu.begin_fill()
tu.circle(radius, extent)
tu.end_fill()
tu.up()
tu.goto(x1,y1)
tu.setheading(angle)
tu.down()
for angle in range(-45, 135, 45):
radius = radius + 20
flower()
for angle in range(135, 270, 45):
radius = radius - 20
flower()
tu.color('blue')
tu.up()
tu.goto(-60, -170)
tu.write("Fowers are beautiful!")
tu.up()
tu.setheading(90)
tu.goto(0, -15)
# keep showing until corner x is clicked
tu.done()
sneekula
Nearly a Posting Maven
2,427 posts since Oct 2006
Reputation Points: 961
Solved Threads: 212
Here is an example that actually creates a jpeg image file of your labor:
# drawing with PIL (Python Image Library)
# draw and save a small French flag (blue, white, red)
from PIL import Image, ImageDraw
# create a new 24x16 pixel image surface (default is black bg)
img = Image.new("RGB", (24, 16))
# set up the new image surface for drawing
draw = ImageDraw.Draw (img)
# draw a blue rectangle
# x1, y1 are upper left corner coordinates here
w = 8
h = 16
x1 = 0
y1 = 0
draw.polygon([(x1,y1),
(x1+w,y1), (x1+w,y1+h), (x1,y1+h)], fill='blue')
# draw a white rectangle
w = 8
h = 16
x1 = 8
y1 = 0
draw.polygon([(x1,y1),
(x1+w,y1), (x1+w,y1+h), (x1,y1+h)], fill='white')
# draw a red rectangle
w = 8
h = 16
x1 = 16
y1 = 0
draw.polygon([(x1,y1),
(x1+w,y1), (x1+w,y1+h), (x1,y1+h)], fill='red')
img.save("french_flag.jpg")
# optionally look at the image you have drawn
img.show()
sneekula
Nearly a Posting Maven
2,427 posts since Oct 2006
Reputation Points: 961
Solved Threads: 212