making carrom board from turtle python

def squares(x,y,f,p,c):
 t.speed(0)
 t.up()
 t.goto(x,y)
 t.down()
 t.begin_fill()
 t.pensize(p)
 t.pencolor(c)
 t.fillcolor(c)
 for i in range(4):
  t.forward(f)
  t.left(90)
 t.end_fill()

def outline(x,y,f,p,c):
 t.speed(0)
 t.up()
 t.goto(x,y)
 t.down()
 t.pensize(p)
 t.pencolor(c)
 for i in range(4):
  t.forward(f)
  t.left(90)

def circlefill(x,y,r,c):
  t.speed(0)
  t.up()
  t.goto(x,y)
  t.down()
  t.begin_fill()
  t.fillcolor(c)
  t.circle(r)
  t.end_fill()  

def circlefillout(x,y,r,c):
  t.speed(0)
  t.up()
  t.goto(x,y)
  t.down()
  t.pencolor(c)
  t.begin_fill()
  t.fillcolor(c)
  t.circle(r)
  t.end_fill()

def circle(x,y,r,p,c):
  t.speed(0)
  t.up()
  t.goto(x,y)
  t.down()
  t.pensize(p)
  t.pencolor(c)
  t.circle(r) 

def arrowcircle(x,y,r,p,c):
  t.speed(0)
  t.up()
  t.goto(x,y)
  t.down()
  t.pensize(p)
  t.pencolor(c)
  t.circle(r) 
  t.up()
  t.home()
  t.down()

def arrow(x,y,f,r,p):
  t.speed(0)
  t.up()
  t.goto(x,y)
  t.down()
  t.pensize(p)
  t.left(90)
  t.forward(f)#right curve
  t.right(90)
  t.circle(-r,130)
  t.right(120)
  t.pensize(p)
  t.forward(5)
  t.backward(5)
  t.left(270)
  t.forward(5)
  t.backward(5)
  t.up()
  t.goto(x,y)
  t.down()#left curve
  t.left(70)
  t.forward(f)
  t.left(90)
  t.circle(r,130)
  t.left(120)
  t.pensize(p)
  t.forward(5)
  t.backward(5)
  t.right(270)
  t.forward(5)
  t.backward(5)
  t.up()#
  t.goto(x,y)
  t.down()
  t.pensize(p)
  t.right(20)
  t.forward(5)
  t.backward(5)
  t.left(260)
  t.forward(5)
  
def line(x,y,a,f,p):
 t.speed(0)
 t.up()
 t.goto(x,y)
 t.down()
 t.pensize(p)
 t.left(a)
 t.forward(f) 
        
def diamond2(x,y,a,c):
 t.speed(0)
 t.up()
 t.goto(x,y)
 t.down()
 t.begin_fill()
 t.pensize(3)
 t.fillcolor(c)
 t.left(a)
 t.left(90)
 t.forward(80)
 t.left(90)
 t.forward(29.1)
 t.left(110)
 t.forward(85.1)
 t.right(110)  
 t.end_fill()
def diamond1(x,y,a,c):
 t.speed(0)
 t.up()
 t.goto(x,y)
 t.down()
 t.begin_fill()
 t.pensize(3)
 t.fillcolor(c)
 t.left(a)
 t.left(90)
 t.forward(80)
 t.right(90)
 t.forward(29.1)
 t.right(110)
 t.forward(85.1)
 t.left(110)  
 t.end_fill()
def go_to(x,y):
 t.up()
 t.goto(x,y)
 t.down() 
import turtle as t

#outer squares
squares(-465,-465,930,60,"salmon3")#1st bgcolor
squares(-465,-465,920,60,"salmon4")#2rd bgcolor
squares(-450,-450,900,60,"brown4")#sienna4
squares(-390,-390,780,5,"sandybrown")
squares(-350,-350,700,5,"navajowhite")

#carrom outline
outline(-400,-400,800,16,"gray17")#brown4

#circle
circlefill(-360,-400,40,"black")
circlefill(360,-400,40,"black")
circlefill(-360,320,40,"black")
circlefill(360,320,40,"black")

#center circle
circle(0,-130,130,3,"black")
circle(0,-100,100,25,"orangeRed2")
circle(0,-90,90,10,"black")

#four arrow
t.right(45)
arrow(-300,-300,220,33.3,3)#left buttom
t.right(130)
arrow(-300,300,220,33.3,3)#left top
t.right(130)
arrow(300,300,220,33.3,3)#right top
t.right(130)
arrow(300,-300,220,33.3,3)#right buttom

#rectangle shape pattern in carrom
line(-300,-190,5,390,10)#left side
line(-260,-190,0,390,4)
line(300,-190,0,390,10)#right side
line(260,-190,0,390,4)
line(-190,300,-90,390,10)#top side
line(-190,260,0,390,4)
line(-190,-300,0,390,10)#buttom side
line(-190,-260,0,390,4)

#line's circle
circle(-281,-220,22,4,"black")
circle(281,-220,22,4,"black")
circle(-281,185,22,4,"black")
circle(281,185,22,4,"black")
#board color circle
circlefill(-281,-220,22,"navajowhite")
circlefill(281,-220,22,"navajowhite")
circlefill(-281,185,22,"navajowhite")
circlefill(281,185,22,"navajowhite")
#red color inner circle in left side
circlefillout(-281,-213,15,"orangeRed2")
circlefillout(281,-213,15,"orangeRed2")
circlefillout(-281,192,15,"orangeRed2")
circlefillout(281,192,15,"orangeRed2")

circle(-195,260,22,4,"black")
circle(206,260,22,4,"black")
circle(-195,-304,22,4,"black")
circle(206,-304,22,4,"black")
#board color circle
circlefill(-195,260,22,"navajowhite")
circlefill(206,260,22,"navajowhite")
circlefill(-195,-304,22,"navajowhite")
circlefill(206,-304,22,"navajowhite")
#red color inner circle in right side
circlefillout(-195,267,15,"orangeRed2")
circlefillout(206,267,15,"orangeRed2")
circlefillout(-195,-297,15,"orangeRed2")
circlefillout(206,-297,15,"orangeRed2")

#arrow circle
t.right(45)
arrowcircle(-265,-265,16,3,"black")#left buttom
t.left(45)
arrowcircle(-245,245,16,3,"black")#left top
t.right(45)
arrowcircle(245,245,16,3,"black")#right top
t.left(45)
arrowcircle(265,-265,16,3,"black")#right buttom


#center main
diamond1(0,-80,0,"orangeRed2")
diamond1(0,80,180,"orangeRed2")
diamond1(80,0,-90,"orangeRed2")
diamond1(-80,0,180,"orangeRed2")

diamond2(0,-80,90,"navajowhite")
diamond2(0,80,0,"navajowhite")
diamond2(-80,0,-90,"navajowhite")
diamond2(80,0,0,"navajowhite")

go_to(0,-80)
t.left(90)

diamond1(58,-58,45,"black")
diamond1(-58,58,180,"black")
diamond1(58,58,-90,"black")
diamond1(-58,-58,180,"black")

diamond2(58,-58,90,"navajowhite")
diamond2(-58,58,0,"navajowhite")
diamond2(58,58,90,"navajowhite")
diamond2(-58,-58,0,"navajowhite")

t.right(135)

circlefillout(0,-28,28,"black")
circlefillout(0,-24,24,"navajowhite")
circlefillout(0,-18,18,"orangeRed2")

t.hideturtle()
t.done()

Comments

Popular posts from this blog

creating lord shiva 2 by turtle python apni programming

creating half face lord shiva by python turtle

navratri special turtle python apni programming