How to make simple graphics in Turtle Graphics – 2

Posted

in

by

Python Code

from turtle import * 

def frame():
    #setup (width=200, height=200, startx=0, starty=0)
    setup(500,500,0,0);
    screensize(canvwidth = 480, canvheight = 480, bg = "cyan")

def box1(size, angle):
    penup()
    goto(-(size/2),(size/2))
    pendown()
    forward(size)
    right(angle)
    forward(size)
    right(angle)
    forward(size)
    right(angle)
    forward(size)
    penup()

def text():
    goto(-230,-230)
    pendown()
    #turtle.write(arg, move=False, align='left', font=('Arial', 8, 'normal'))
    write("exasub.com", False, align="left", font = ('Arial', 16, 'normal'))
    
if __name__ == "__main__":
    frame();
    box1(400,90);
    text();
    mainloop()

Python Code

from turtle import * 

def frame():
    #setup (width=200, height=200, startx=0, starty=0)
    setup(500,500,0,0);
    screensize(canvwidth = 480, canvheight = 480, bg = "cyan")

def box1(size, angle):
    penup()
    goto(-(size/2),(size/2))
    pendown()
    forward(size)
    right(angle)
    forward(size)
    right(angle)
    forward(size)
    right(angle)
    forward(size)
    penup()

def text():
    goto(-230,-230)
    pendown()
    #turtle.write(arg, move=False, align='left', font=('Arial', 8, 'normal'))
    write("exasub.com", False, align="left", font = ('Arial', 16, 'normal'))
    penup()

def drawCircle():
    # Draw a circle in Anticlockwise direction
    goto(0,0)
    pendown()
    color("red")
    begin_fill()    # Start Filling the semi-circle
    circle(100,-180,40); # circle(radius, angle, steps)
    end_fill()      # Stop Filling the semi-circle
    penup()
    #Draw a circle in Clockwise Direction
    goto(0,0)
    pendown()
    color("green")
    begin_fill()
    circle(100,360,40)
    end_fill()
    penup()

def drawTriangle():
    home()
    pendown()
    color("grey")
    begin_fill()
    circle(50, 360, 3)
    end_fill()
    penup()

    
if __name__ == "__main__":
    frame();
    box1(400,90);
    text();
    drawCircle();
    drawTriangle()
    #drawCircle();
    mainloop()

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *