2 + 3 #this code cell
5
if []: is not present that means it is markdown cell
# Header1
## Header2
### Header3
2 + 3
5
import requests
def download(url, filename):
with open(filename, "wb") as f:
resp = requests.get(url)
f.write(resp.content)
url = "https://raw.githubusercontent.com/fossunited/joy/main/joy.py"
download(url, "joy.py")
from joy import *
Just lego set there are some fundamental objects given to you. We will build new ideas from these peices
Line()
Circle()
Rectangle()
Line() + Rectangle()
Circle() + Rectangle()
shape = Circle() + Rectangle() + Line()
show(shape)
Circle(radius=100, stroke='red', stroke_width=5)
Circle(radius=100, stroke='none', fill='orange')
c1 = Circle(radius=100)
c2 = Circle(radius=50)
donut = c1 + c2
show(donut)
Problem
c1 = Circle(radius=100, fill='orange')
c2 = Circle(radius=50, fill='white')
donut = c1 + c2
show(donut)
c1 = Circle(radius=100, fill='orange', stroke='none')
c2 = Circle(radius=50, fill='white', stroke='none')
donut = c1 + c2
show(donut)
def donut(r):
donut_shape = Circle(radius=r) + Circle(radius=r/2)
return donut_shape
donut(100)
donut(150)
shape = Circle(radius=100)
for i in range(1, 10):
shape = shape + Circle(radius=100-i*10) # make note of indetation
show(shape)
def bulls_eye(radius, n):
shape = Circle(radius=radius)
for i in range(1, n):
shape = shape + Circle(radius=radius-i*10)
return shape
bulls_eye(100, 5)
bulls_eye(150, 15)
line = Line()
line | Rotate(45)
Rectangle()
Rectangle() | Rotate(angle=45)
Rectangle() | Rotate(angle=45, anchor=Point(x=-100, y=0))
Circle() | Scale(0.5)
Circle()
Circle() | Scale(sx=0.5, sy=1)
def donut(radius):
outer = Circle()
inner = outer | Scale(0.7)
return outer + inner
donut(100)
donut(50)
Rectangle()
Rectangle() | Translate(x=50, y=0)
Line() | Repeat(n=18, transformation=Rotate(angle=18))
Line() | Repeat(n=36, transformation=Rotate(angle=10, anchor=Point(-150, 0)))
Rectangle(width=200, height=200) | Repeat(n=18, transformation=Rotate(angle=10))
def Square(size):
return Rectangle(height=size, width=size)
Square(200) | Repeat(n=40, transformation=Scale(0.9))
Square(200) | Repeat(n=40, transformation=Scale(sx=0.9, sy=1))
Circle(center=Point(x=50, y=0)) | Repeat(n=18, transformation=Rotate(angle=20))
tx = Rotate(angle=5)| Scale(0.92)
Square(200) | Repeat(n=360//5, transformation=tx)
Circle(radius=20, center=Point(x=90, y=90))
Circle(radius=20, center=Point(x=90, y=90))| Repeat(n=360//20, transformation=Rotate(angle=20))
c = Circle(radius=20, center=Point(x=90, y=90))| Repeat(n=360//20, transformation=Rotate(angle=20))
c
c | Repeat(n=30, transformation=Scale(0.73))
Do ask other friends to visit this site for learning programming as fun https://mon.school/