Пример #1
0
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))
Пример #2
0
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))
Пример #3
0
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))
Пример #4
0
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]])))
Пример #5
0
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))
Пример #6
0
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))
Пример #7
0
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))
Пример #8
0
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]])))
Пример #9
0
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))
Пример #10
0
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))
Пример #11
0
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))
Пример #12
0
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))
Пример #13
0
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))
Пример #14
0
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]])))
Пример #15
0
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))
Пример #16
0
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))
Пример #17
0
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))
Пример #18
0
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))
Пример #19
0
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))
Пример #20
0
def reflect_xz(t):
    """ Reflects a shape about the plane X=Z
    """
    args = [Shape.wrap(t)]
    return Shape(stdlib.reflect_xz(args[0].ptr))
Пример #21
0
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))
Пример #22
0
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]])))
Пример #23
0
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))
Пример #24
0
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]])))
Пример #25
0
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))
Пример #26
0
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))
Пример #27
0
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))
Пример #28
0
def emptiness():
    """ A value which is empty everywhere
    """
    args = []
    return Shape(stdlib.emptiness())
Пример #29
0
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))
Пример #30
0
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))