LEARN WITH FUN@FUTURE_CODE
😘ONLINE PROPOSAL 😍
Python uses an interpreter to translate and run its code and that’s why it’s called a scripting language.
A python script normally can be full of functions that can be be imported as a library of function in other scripts.
This python code will help you to propose your girlfriend/boyfriend.
we are going to draw the rose flower🌹 with text to propose someone💖
PREVIEW:
Requirements: Text editor such as Python IDLE (pycharm).
- Install the python text editor such as pycharm use this source code given below.
- Import the turtle module. This turtle module is a pre-installed python library that enables users to create pictures and shapes by providing them with a virtual canvas.
To install turtle module : pip install turtle
Let's we import the turtle module as t.
Then we create a function to draw the curve degree for rose. To draw the curved degree we use for loop in range of n.
import turtle as t
def DegreeCurve(n, r, d=1):
for i in range(n):
t.left(d)
Let's we make circle to make the bottom of the rose with radius r.
t.circle(r, abs(d))
Now we create pen and we make the pen colour as black and fill_colour of the rose as red(which colour you need) and we creating the leaves with green colour.
s=0.2
t.setup(450*5*s, 750*5*s)
t.pencolor("black")
t.fillcolor("red")
t.speed(100)
t.penup()
t.goto(0, 900*s)
t.pendown()
t.begin_fill()
t.circle(200*s,30)
DegreeCurve(60,50*s)
t.circle(200*s,30)
DegreeCurve(4,100*s)
t.circle(200*s,50)
DegreeCurve(50,50*s)
t.circle(350*s,65)
DegreeCurve(40,70*s)
t.circle(150*s,50)
DegreeCurve(20,50*s,-1)
t.circle(400*s,60)
DegreeCurve(18,50*s)
t.fd(250*s)
t.right(150)
t.circle(-500*s,12)
t.left(140)
t.circle(550*s,110)
t.left(27)
t.circle(650*s,100)
t.left(130)
t.circle(-300*s,20)
t.right(123)
t.circle(220*s,57)
t.end_fill()
t.left(120)
t.fd(280*s)
t.left(115)
t.circle(300*s,33)
t.left(180)
t.circle(-300*s,33)
DegreeCurve(70,225*s,-1)
t.circle(350*s,104)
t.left(90)
t.circle(200*s,105)
t.circle(-500*s,63)
t.penup()
t.goto(170*s,-30*s)
t.pendown()
t.left(160)
DegreeCurve(20,2500*s)
DegreeCurve(220,250*s,-1)
t.fillcolor('green')
t.penup()
t.goto(670*s,-180*s)
t.pendown()
t.right(140)
t.begin_fill()
t.circle(300*s,120)
t.left(60)
t.circle(300*s,120)
t.end_fill()
t.penup()
t.goto(180*s,-550*s)
t.pendown()
t.right(85)
t.circle(600*s,40)
t.penup()
t.goto(-150*s,-1000*s)
t.pendown()
t.begin_fill()
t.rt(120)
t.circle(300*s,115)
t.left(75)
t.circle(300*s,100)
t.end_fill()
t.penup()
t.goto(430*s,-1070*s)
t.pendown()
t.right(30)
t.circle(-600*s,35)
Now we create the text what we need to insert in the rose.To create the text we are going to define the function as text.
lets we set position of text in the rose(-58,-21)which represent the x, y coordinates of 2D.
The colour and font of the text are set. And my text be "I LOVE YOU BABY".(instead of using the text baby you can put your boyfriend/girlfriend name)
def txt():
t.penup()
t.setpos(-58,-21)
t.pendown()
t.color('blue')
t.write("I LOVE YOU BABY",font=("verdana",21,"bold"))
txt()
The turtle.done() function is used to starts the event loop calling Tkinter's main loop functions.It must be the last statement of the turtle code.
t.done()
OUTPUT:
click for source code


Comments
Post a Comment