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
Random circles with random colours
By
Devjith P
Run
def make_grid(n): width = 300 d = width/n xstart = -width/2 + d/2 ystart = width/2 - d/2 shapes = [] for i in range(n): for j in range(n): x = xstart + d*j y = ystart - d*i shape = make_shape(d) | translate(x=x, y=y) shapes.append(shape) return combine(shapes) def random_diagonal(width): r = random(1) if r < 0.5: fill1=color(r=rand_colours(),g=rand_colours(),b=rand_colours()) fill2=color(r=rand_colours(),g=rand_colours(),b=rand_colours()) # line from bottom-left to top-right return circle(r=width/2,fill=fill1,stroke="none")+ellipse(h=width,w=width/2,fill=fill2,stroke="none") else: # line from top-left to bottom-right fill3=color(r=rand_colours(),g=rand_colours(),b=rand_colours()) fill4=color(r=rand_colours(),g=rand_colours(),b=rand_colours()) return circle(r=width/2,fill=fill3,stroke="none")+ellipse(h=width/2,w=width,fill=fill4,stroke="none") def make_shape(width): return random_diagonal(width) def rand_colours(): col1=random(0,225) return col1 shape = make_grid(6) show(shape)
Comments
Want to discuss?
Post it here, our mentors will help you out.
Login