You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
c = Circle()
c = Circle(radius=50)
c = Circle(center=Point(x=100, y=100), radius=50)
create a rectangle:
r = Rectangle()
r = Rectangle(width=200, height=100)
r = Rectangle(center=Point(x=0, y=50), width=100, height=50)
create a line:
z = Line()
z = Line(start=Point(x=100, y=0), end=Point(x=150, y=100))
Combining Shapes
c = Circle()
r = Rectangle()
shape = c + r
When you have an list of shapes, you can combine all of them using Group.
def concentric_circles(center, radius, n):
circles = [Circle(center, radius*i/n) for i in range(1, n+1)]
return Group(circles)
Transformations
translate:
shape = Circle() | Translate(x=10, y=10)
rotate:
shape = Rectangle() | Rotate(angle=45)
shape = Rectangle() | Rotate(angle=45, anchor=Point(x=100, y=100))
shape = Line() | Rotate(angle=15, anchor="end") # rotate around the end point of the line
# using anchors on combines shapes
r = Rectangle()
d = Line(start=rect.points[1], end=rect.points[2])
shape = r + d
shape2 = shape | Rotate(angle=15, anchor="1.end")
# or using labels
r = Rectangle()
d = Line(start=rect.points[1], end=rect.points[2])
shape = r.label("r") + d.label("diag")
shape2 = shape | Rotate(angle=15, anchor="diag.end")
shape2 = shape | Rotate(angle=15, anchor="r.p2")
c = circle()
c = circle(radius=50)
c = circle(center=Point(x=100, y=100), radius=50)
create a rectangle:
r = rectangle()
r = rectangle(width=200, height=100)
r = rectangle(center=Point(x=0, y=50), width=100, height=50)
create a line:
z = line()
z = line(start=point(x=100, y=0), end=Point(x=150, y=100))
Combining Shapes
c = circle()
r = rectangle()
shape = c + r
When you have an list of shapes, you can combine all of them using Group.
def concentric_circles(center, radius, n):
circles = [circle(center, radius*i/n) for i in range(1, n+1)]
return group(circles)
Transformations
translate:
shape = circle() | translate(x=10, y=10)
rotate:
shape = rectangle() | rotate(angle=45)
shape = rectangle() | rotate(angle=45, anchor=point(x=100, y=100))
shape = line() | rotate(angle=15, anchor="end") # rotate around the end point of the line
# using anchors on combines shapes
r = rectangle()
d = line(start=rect.points[1], end=rect.points[2])
shape = r + d
shape2 = shape | rotate(angle=15, anchor="1.end")
# or using labels
r = rectangle()
d = line(start=rect.points[1], end=rect.points[2])
shape = r.label("r") + d.label("diag")
shape2 = shape | rotate(angle=15, anchor="diag.end")
shape2 = shape | rotate(angle=15, anchor="r.p2")