Explore
Courses
Batches
Sketches
Statistics
Code a Pookkalam
Jobs
Devsprint
People
Course Creation
Create a Course
Guidelines
Resources
Support
Blogs
My Profile
About Us
Login
Sketches
0
Math is fun
By
Rohit T P
Run
# Each time you run you get a diffrent color import math consts = [] for i in range(4,12): consts.append((7,i)) step = 0.01 def flower(t,a,b): x = a*math.cos(b*t)*math.cos(t) y = a*math.cos(b*t)*math.sin(t) return point(x,y) polys = [] i=-10 for a,b in consts: points = [] while i < 10: points.append(flower(i,a,b)) i += step i=0 clr = color(r=random(b*40), g=random(b*30), b=random(b*40)) polys.append(polygon(points, stroke_width=0.1,fill=clr) | translate(0,b*10-10) | rotate(a*b)) hpoints = [] def heart(t): x = 16*(math.sin(t)**3) y = 13*math.cos(t)-5*math.cos(2*t)-2*math.cos(3*t)-math.cos(4*t) return point(x,y) i = -50 while i < 50: hpoints.append(heart(i)) i += step h = polygon(hpoints, stroke_width=0.25, fill="red") | scale(2.5) c = combine(polys) | scale(2) | repeat(30,rotate(12)) tcol = "yellow" t = rectangle(x=0,y=5,w=40,h=10,fill=tcol,stroke_width=0) + rectangle(x=0,y=-15,w=10,h=20,fill=tcol,stroke_width=0) show(rectangle(x=0,y=0,w=300,h=300,fill="#FFFF99"),c,h,t)
Comments
Want to discuss?
Post it here, our mentors will help you out.
Login