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 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 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 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 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 pyramid_z(a, b, zmin, height): """ A pyramid defined by its base rectangle, lower Z value, and height """ args = [list([Shape.wrap(i) for i in a]), list([Shape.wrap(i) for i in b]), Shape.wrap(zmin), Shape.wrap(height)] return Shape(stdlib.pyramid_z( tvec2(*[a.ptr for a in args[0]]), tvec2(*[a.ptr for a in args[1]]), args[2].ptr, args[3].ptr))
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 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 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 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 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_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 text(txt, pos=(0, 0)): """ Returns the given text, rendered in a custom f-rep font (with a character height of 1) """ args = [txt.encode('utf-8'), list([Shape.wrap(i) for i in pos])] return Shape(stdlib.text(args[0], tvec2(*[a.ptr for a in args[1]])))