def attract_y(shape, locus, radius, exaggerate=1): """ Attracts the shape away from a XZ plane based upon a radius r, with optional exaggeration """ args = [ Shape.wrap(shape), list([Shape.wrap(i) for i in locus]), Shape.wrap(radius), Shape.wrap(exaggerate) ] return Shape( stdlib.attract_y(args[0].ptr, tvec3(*[a.ptr for a in args[1]]), args[2].ptr, args[3].ptr))
def repel(shape, locus, radius, exaggerate=1): """ Repels the shape away from a point based upon a radius r, with optional exaggeration """ args = [ Shape.wrap(shape), list([Shape.wrap(i) for i in locus]), Shape.wrap(radius), Shape.wrap(exaggerate) ] return Shape( stdlib.repel(args[0].ptr, tvec3(*[a.ptr for a in args[1]]), args[2].ptr, args[3].ptr))
def repel_xz(shape, locus, radius, exaggerate=1): """ Repels the shape away from line parallel to the Y axis, with a particular radius and optional exaggeration """ args = [ Shape.wrap(shape), list([Shape.wrap(i) for i in locus]), Shape.wrap(radius), Shape.wrap(exaggerate) ] return Shape( stdlib.repel_xz(args[0].ptr, tvec3(*[a.ptr for a in args[1]]), args[2].ptr, args[3].ptr))
def loft_between(a, b, lower, upper): """ Produces a blended loft between a (at lower.z) and b (at upper.z), with XY coordinates remapped to slide between lower.xy and upper.xy. a and b should be 2D shapes (i.e. invariant along the z axis) """ args = [ Shape.wrap(a), Shape.wrap(b), list([Shape.wrap(i) for i in lower]), list([Shape.wrap(i) for i in upper]) ] return Shape( stdlib.loft_between(args[0].ptr, args[1].ptr, tvec3(*[a.ptr for a in args[2]]), tvec3(*[a.ptr for a in args[3]])))
def shear_x_y(t, base, height, offset, base_offset=0): """ Shears a shape on the x axis as a function of y offset = base-offset at base.y offset = offset = base.y + h """ args = [ Shape.wrap(t), list([Shape.wrap(i) for i in base]), Shape.wrap(height), Shape.wrap(offset), Shape.wrap(base_offset) ] return Shape( stdlib.shear_x_y(args[0].ptr, tvec2(*[a.ptr for a in args[1]]), args[2].ptr, args[3].ptr, args[4].ptr))
def taper_xy_z(shape, base, height, scale, base_scale=1): """ Tapers a shape in the xy plane as a function of z width = base-scale at base width = scale at base + [0 0 height] """ args = [ Shape.wrap(shape), list([Shape.wrap(i) for i in base]), Shape.wrap(height), Shape.wrap(scale), Shape.wrap(base_scale) ] return Shape( stdlib.taper_xy_z(args[0].ptr, tvec3(*[a.ptr for a in args[1]]), args[2].ptr, args[3].ptr, args[4].ptr))
def taper_x_y(shape, base, h, scale, base_scale=1): """ Tapers a shape along the x axis as a function of y width = base-scale at base width = scale at base + [0 h] """ args = [ Shape.wrap(shape), list([Shape.wrap(i) for i in base]), Shape.wrap(h), Shape.wrap(scale), Shape.wrap(base_scale) ] return Shape( stdlib.taper_x_y(args[0].ptr, tvec2(*[a.ptr for a in args[1]]), args[2].ptr, args[3].ptr, args[4].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 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 offset(a, o): """ Expand or contract a given shape by an offset Positive offsets expand the shape; negative offsets shrink it """ args = [Shape.wrap(a), Shape.wrap(o)] return Shape(stdlib.offset(args[0].ptr, args[1].ptr))
def inverse(a): """ Returns a shape that's the inverse of the input shape """ args = [Shape.wrap(a)] return Shape(stdlib.inverse(args[0].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 morph(a, b, m): """ Morphs between two shapes. m = 0 produces a, m = 1 produces b """ args = [Shape.wrap(a), Shape.wrap(b), Shape.wrap(m)] return Shape(stdlib.morph(args[0].ptr, args[1].ptr, 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 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 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 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 revolve_y(shape, x0=0): """ Revolves a 2D (XY) shape about a line parallel to the Y axis with the given x value """ args = [Shape.wrap(shape), Shape.wrap(x0)] return Shape(stdlib.revolve_y(args[0].ptr, args[1].ptr))
def blend_rough(a, b, m): """ Blends two shapes by the given amount, using a fast-but-rough CSG approximation that may not preserve gradients """ args = [Shape.wrap(a), Shape.wrap(b), Shape.wrap(m)] return Shape(stdlib.blend_rough(args[0].ptr, args[1].ptr, args[2].ptr))
def reflect_xz(t): """ Reflects a shape about the plane X=Z """ args = [Shape.wrap(t)] return Shape(stdlib.reflect_xz(args[0].ptr))
def symmetric_x(t): """ Clips the given shape at the x origin, then duplicates the remaining shape reflected on the other side of the origin """ args = [Shape.wrap(t)] return Shape(stdlib.symmetric_x(args[0].ptr))
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 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 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 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 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 clearance(a, b, offset): """ Expands shape b by the given offset then subtracts it from shape a """ args = [Shape.wrap(a), Shape.wrap(b), Shape.wrap(offset)] return Shape(stdlib.clearance(args[0].ptr, args[1].ptr, args[2].ptr))
def emptiness(): """ A value which is empty everywhere """ args = [] return Shape(stdlib.emptiness())
def blend_expt(a, b, m): """ Blends two shapes by the given amount using exponents """ args = [Shape.wrap(a), Shape.wrap(b), Shape.wrap(m)] return Shape(stdlib.blend_expt(args[0].ptr, args[1].ptr, args[2].ptr))
def scale_z(t, sz, z0=0): """ Scales a shape by sx on the x axis about 0 or an optional offset """ args = [Shape.wrap(t), Shape.wrap(sz), Shape.wrap(z0)] return Shape(stdlib.scale_z(args[0].ptr, args[1].ptr, args[2].ptr))