def difference(a, b): """ Subtracts the second shape from the first """ args = [Shape.wrap(a), Shape.wrap(b)] return Shape(stdlib.difference( args[0].ptr, args[1].ptr))
def shell(a, offset): """ Returns a shell of a shape with the given offset """ args = [Shape.wrap(a), Shape.wrap(offset)] return Shape(stdlib.shell( args[0].ptr, args[1].ptr))
def intersection(a, b): """ Returns the intersection of two shapes """ args = [Shape.wrap(a), Shape.wrap(b)] return Shape(stdlib.intersection( args[0].ptr, args[1].ptr))
def union(a, b): """ Returns the union of two shapes """ args = [Shape.wrap(a), Shape.wrap(b)] return Shape(stdlib._union( args[0].ptr, args[1].ptr))
def symmetric_y(t): """ Clips the given shape at the y origin, then duplicates the remaining shape reflected on the other side of the origin """ args = [Shape.wrap(t)] return Shape(stdlib.symmetric_y( args[0].ptr))
def sphere(radius, center=(0, 0, 0)): """ A sphere with the given radius and (optional) center """ args = [Shape.wrap(radius), list([Shape.wrap(i) for i in center])] return Shape(stdlib.sphere( args[0].ptr, tvec3(*[a.ptr for a in args[1]])))
def loft(a, b, zmin, zmax): """ Produces a blended loft between a (at zmin) and b (at zmax) a and b should be 2D shapes (i.e. invariant along the z axis) """ args = [Shape.wrap(a), Shape.wrap(b), Shape.wrap(zmin), Shape.wrap(zmax)] return Shape( stdlib.loft(args[0].ptr, args[1].ptr, args[2].ptr, args[3].ptr))
def move(t, offset): """ Moves the given shape in 2D or 3D space """ args = [Shape.wrap(t), list([Shape.wrap(i) for i in offset])] return Shape(stdlib.move( args[0].ptr, tvec3(*[a.ptr for a in args[1]])))
def rectangle_centered_exact(size, center=(0, 0)): """ An exact-field rectangle at the (optional) center """ args = [list([Shape.wrap(i) for i in size]), list([Shape.wrap(i) for i in center])] return Shape(stdlib.rectangle_centered_exact( tvec2(*[a.ptr for a in args[0]]), tvec2(*[a.ptr for a in args[1]])))
def blend_expt_unit(a, b, m): """ Blends two shapes by the given amount using exponents, with the blend term adjusted to produce results approximately resembling blend_rough for values between 0 and 1. """ args = [Shape.wrap(a), Shape.wrap(b), Shape.wrap(m)] return Shape(stdlib.blend_expt_unit(args[0].ptr, args[1].ptr, args[2].ptr))
def rectangle(a, b): """ A rectangle with the given bounding corners """ args = [list([Shape.wrap(i) for i in a]), list([Shape.wrap(i) for i in b])] return Shape( stdlib.rectangle(tvec2(*[a.ptr for a in args[0]]), tvec2(*[a.ptr for a in args[1]])))
def array_xy(shape, nx, ny, delta): """ Iterates a part in a 2D array """ args = [Shape.wrap(shape), nx, ny, list([Shape.wrap(i) for i in delta])] return Shape( stdlib.array_xy(args[0].ptr, args[1], args[2], tvec2(*[a.ptr for a in args[3]])))
def array_polar_z(shape, n, center=(0, 0)): """ Iterates a shape about an optional center position """ args = [Shape.wrap(shape), n, list([Shape.wrap(i) for i in center])] return Shape( stdlib.array_polar_z(args[0].ptr, args[1], tvec2(*[a.ptr for a in args[2]])))
def box_exact(a, b): """ A box with the given bounds with a Euclidean distance metric """ args = [list([Shape.wrap(i) for i in a]), list([Shape.wrap(i) for i in b])] return Shape( stdlib.box_exact(tvec3(*[a.ptr for a in args[0]]), tvec3(*[a.ptr for a in args[1]])))
def reflect_z(t, z0=0): """ Reflects a shape about the z origin or an optional offset """ args = [Shape.wrap(t), Shape.wrap(z0)] return Shape(stdlib.reflect_z( args[0].ptr, args[1].ptr))
def box_mitered(a, b): """ A box with the given bounds, which will stay creased if offset """ args = [list([Shape.wrap(i) for i in a]), list([Shape.wrap(i) for i in b])] return Shape( stdlib.box_mitered(tvec3(*[a.ptr for a in args[0]]), tvec3(*[a.ptr for a in args[1]])))
def gyroid(period, thickness): """ A volume-filling gyroid with the given periods and thickness """ args = [list([Shape.wrap(i) for i in period]), Shape.wrap(thickness)] return Shape(stdlib.gyroid( tvec3(*[a.ptr for a in args[0]]), args[1].ptr))
def rectangle_exact(a, b): """ A rectangle from an exact distance field """ args = [list([Shape.wrap(i) for i in a]), list([Shape.wrap(i) for i in b])] return Shape( stdlib.rectangle_exact(tvec2(*[a.ptr for a in args[0]]), tvec2(*[a.ptr for a in args[1]])))
def circle(r, center=(0, 0)): """ A 2D circle with the given radius and optional center """ args = [Shape.wrap(r), list([Shape.wrap(i) for i in center])] return Shape(stdlib.circle( args[0].ptr, tvec2(*[a.ptr for a in args[1]])))
def cylinder_z(r, h, base=(0, 0, 0)): """ A cylinder with the given radius and height, extruded from the (optional) base position. """ args = [Shape.wrap(r), Shape.wrap(h), list([Shape.wrap(i) for i in base])] return Shape( stdlib.cylinder_z(args[0].ptr, args[1].ptr, tvec3(*[a.ptr for a in args[2]])))
def torus_z(ro, ri, center=(0, 0, 0)): """ A torus with the given outer radius, inner radius, and (optional) center """ args = [Shape.wrap(ro), Shape.wrap(ri), list([Shape.wrap(i) for i in center])] return Shape(stdlib.torus_z( args[0].ptr, args[1].ptr, tvec3(*[a.ptr for a in args[2]])))
def blend_difference(a, b, m, o=0): """ Blends the subtraction of b, with optional offset o, from a, with smoothness m """ args = [Shape.wrap(a), Shape.wrap(b), Shape.wrap(m), Shape.wrap(o)] return Shape( stdlib.blend_difference(args[0].ptr, args[1].ptr, args[2].ptr, args[3].ptr))
def rounded_rectangle(a, b, r): """ A rectangle with rounded corners """ args = [list([Shape.wrap(i) for i in a]), list([Shape.wrap(i) for i in b]), Shape.wrap(r)] return Shape(stdlib.rounded_rectangle( tvec2(*[a.ptr for a in args[0]]), tvec2(*[a.ptr for a in args[1]]), args[2].ptr))
def polygon(r, n, center=(0, 0)): """ A polygon with center-to-vertex distance r and n sides """ args = [Shape.wrap(r), n, list([Shape.wrap(i) for i in center])] return Shape(stdlib.polygon( args[0].ptr, args[1], tvec2(*[a.ptr for a in args[2]])))
def ring(ro, ri, center=(0, 0)): """ A 2D ring with the given outer/inner radii and optional center """ args = [Shape.wrap(ro), Shape.wrap(ri), list([Shape.wrap(i) for i in center])] return Shape(stdlib.ring( args[0].ptr, args[1].ptr, tvec2(*[a.ptr for a in args[2]])))
def array_x(shape, nx, dx): """ Iterates a part in a 1D array """ args = [Shape.wrap(shape), nx, Shape.wrap(dx)] return Shape(stdlib.array_x( args[0].ptr, args[1], args[2].ptr))
def triangle(a, b, c): """ A 2D triangle """ args = [list([Shape.wrap(i) for i in a]), list([Shape.wrap(i) for i in b]), list([Shape.wrap(i) for i in c])] return Shape(stdlib.triangle( tvec2(*[a.ptr for a in args[0]]), tvec2(*[a.ptr for a in args[1]]), tvec2(*[a.ptr for a in args[2]])))
def cone_z(radius, height, base=(0, 0, 0)): """ A cone defined by its radius, height, and (optional) base location """ args = [Shape.wrap(radius), Shape.wrap(height), list([Shape.wrap(i) for i in base])] return Shape(stdlib.cone_z( args[0].ptr, args[1].ptr, tvec3(*[a.ptr for a in args[2]])))
def extrude_z(t, zmin, zmax): """ Extrudes a 2D shape between zmin and zmax """ args = [Shape.wrap(t), Shape.wrap(zmin), Shape.wrap(zmax)] return Shape(stdlib.extrude_z( args[0].ptr, args[1].ptr, args[2].ptr))
def half_space(norm, point=(0, 0, 0)): """ A plane which divides the world into inside and outside, defined by its normal and a single point on the plane """ args = [list([Shape.wrap(i) for i in norm]), list([Shape.wrap(i) for i in point])] return Shape(stdlib.half_space( tvec3(*[a.ptr for a in args[0]]), tvec3(*[a.ptr for a in args[1]])))