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
New Sketch
By
Neha Sunny Mathew
Run
def genBars(h=100, r=240, g=20, b=20, w=20): lines = line(x1=0,y1=0,x2=0,y2=0) w *= 2 step = 3.14 / w for i in range(w): val = step * (i + 1) xStep = i / 2 sVal = max(pow(sin(val), 0.5), 0.1) clr = color(r * sVal, g * sVal , b * sVal) lines += line(x1=xStep, x2=xStep, y1=0,y2=h, stroke=clr, fill=clr) return lines def genSphere(n=80, r=230, g=20, b=20): step = 1/n cir = circle(r=0) for i in range(n): val = step * (i + 1) sVal = max(pow(val, 0.25), 0.1) clr = color(r * sVal, g * sVal , b * sVal) cir += circle(r=100, fill=clr, stroke=clr) | scale(1 - val) return cir def genConectors(): bar = genBars(r=192,g=192,b=192) | translate(x=-10) bar2 = bar | translate(y=-100) bar3 = genBars(r=192,g=192,b=192) | rotate(90) | translate(y=-10) bar4 = bar3 | translate(x=100) bar5 = genBars(r=192,g=192,b=192, h=150) | rotate(-45) | translate(x=-120) bar6 = genBars(r=192,g=192,b=192, h=150) | rotate(45) | translate(x=100) bar7 = genBars(r=192,g=192,b=192, h=150) | rotate(-45) | translate(y=-100) bar8 = genBars(r=192,g=192,b=192, h=150) | rotate(45) | translate(y=-120) return bar + bar2 + bar3 + bar4 + bar5 + bar6 + bar7 + bar8 def genAtoms(): a1 = genSphere(r=0, g=190, b=200) | scale(0.25) | translate(y=100) a2 = genSphere(r=0, g=150, b=0) | scale(0.25) | translate(y=-100) a3 = genSphere(r=255, g=215, b=0) | scale(0.25) | translate(x=-100) a4 = genSphere(r=87, g=25, b=150) | scale(0.25) | translate(x=100) return a1 + a2 + a3 + a4 sphere = genSphere(r=255, g=215, b=0) | scale(0.33) connector = genConectors() atoms = genAtoms() arr= connector + sphere + atoms show(arr) c = circle(r=60,fill="pink") r = rectangle(w=100,h=100, fill="blue")|repeat(5,rotate(60)) r2= rectangle(w=50,h=50,fill="green")|repeat(12,rotate(30)) r3= rectangle(w=25,h=25,fill="yellow")|repeat(5,rotate(60)) c3= circle(r=12.5,fill="brown") r4= rectangle(w=12.5,h=12.5,fill="orange")|repeat(5,rotate(60)) c4=circle(r=6.25,fill="cyan") c5=circle(r=3,fill="red") mc=circle(r=72,fill="purple") shapes= mc+r+c+r2+r3+c3+r4+c4+c5 show(shapes) from joy import * r1 = rectangle(fill="red", l=50, w=30) | repeat(6, rotate(60)) r1 += circle(fill="blue", r =30) c1 = circle(fill="pink", r= 100) + circle(fill="green", r= 80) shapes= c1 + r1 show(shapes) from joy import * c1 = circle(border="pink", r=150) | repeat(6, scale(0.8)) shapes= c1 show(shapes)
Comments
Want to discuss?
Post it here, our mentors will help you out.
Login