Shape(ptr)
array_polar(shape, n, center=(0, 0))
Iterates a shape about an optional center position
array_polar_z(shape, n, center=(0, 0))
Iterates a shape about an optional center position
array_x(shape, nx, dx)
Iterates a part in a 1D array
array_xy(shape, nx, ny, delta)
Iterates a part in a 2D array
array_xyz(shape, nx, ny, nz, delta)
Iterates a part in a 3D array
attract(shape, locus, radius, exaggerate=1)
Attracts the shape away from a point based upon a radius r, with optional exaggeration
attract_x(shape, locus, radius, exaggerate=1)
Attracts the shape away from a YZ plane based upon a radius r, with optional exaggeration
attract_xy(shape, locus, radius, exaggerate=1)
Attracts the shape away from line parallel to the Z axis, with a particular radius and optional exaggeration
attract_xz(shape, locus, radius, exaggerate=1)
Attracts the shape away from line parallel to the Y axis, with a particular radius and optional exaggeration
attract_y(shape, locus, radius, exaggerate=1)
Attracts the shape away from a XZ plane based upon a radius r, with optional exaggeration
attract_yz(shape, locus, radius, exaggerate=1)
Attracts the shape away from line parallel to the X axis, with a particular radius and optional exaggeration
attract_z(shape, locus, radius, exaggerate=1)
Attracts the shape away from a XY plane based upon a radius r, with optional exaggeration
blend(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.
blend_difference(a, b, m, o=0)
Blends the subtraction of b, with optional offset o, from a, with smoothness m
blend_expt(a, b, m)
Blends two shapes by the given amount using exponents
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.
blend_rough(a, b, m)
Blends two shapes by the given amount, using a fast-but-rough CSG approximation that may not preserve gradients
box(a, b)
A box with the given bounds, which will stay creased if offset
box_centered(size, center=(0, 0, 0))
A box with the given size and (optional) center, with edges that will stay sharp if offset.
box_exact(a, b)
A box with the given bounds with a Euclidean distance metric
box_exact_centered(size, center=(0, 0, 0))
A box with the given size, centered around the given point, with a Euclidean distance metric
box_mitered(a, b)
A box with the given bounds, which will stay creased if offset
box_mitered_centered(size, center=(0, 0, 0))
A box with the given size and (optional) center, with edges that will stay sharp if offset.
circle(r, center=(0, 0))
A 2D circle with the given radius and optional center
clearance(a, b, offset)
Expands shape b by the given offset then subtracts it from shape a
cone(radius, height, base=(0, 0, 0))
A cone defined by its radius, height, and (optional) base location
cone_ang(angle, height, base=(0, 0, 0))
A cone defined by its slope angle, height, and (optional) base location
cone_ang_z(angle, height, base=(0, 0, 0))
A cone defined by its slope angle, height, and (optional) base location
cone_z(radius, height, base=(0, 0, 0))
A cone defined by its radius, height, and (optional) base location
cube(a, b)
A box with the given bounds, which will stay creased if offset
cube_centered(size, center=(0, 0, 0))
A box with the given size and (optional) center, with edges that will stay sharp if offset.
cylinder(r, h, base=(0, 0, 0))
A cylinder with the given radius and height, extruded from the (optional) base position.
cylinder_z(r, h, base=(0, 0, 0))
A cylinder with the given radius and height, extruded from the (optional) base position.
difference(a, b, *rest)
Subtracts any number of shapes from the first argument
emptiness()
A value which is empty everywhere
extrude_z(t, zmin, zmax)
Extrudes a 2D shape between zmin and zmax
gyroid(period, thickness)
A volume-filling gyroid with the given periods and thickness
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
intersection(a, *args)
Returns the intersection of two shapes
inverse(a)
Returns a shape that's the inverse of the input shape
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)
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)
morph(a, b, m)
Morphs between two shapes. m = 0 produces a, m = 1 produces b
move(shape, v)
Moves the given shape in 2D or 3D space
offset(a, o)
Expand or contract a given shape by an offset Positive offsets expand the shape; negative offsets shrink it
polygon(r, n, center=(0, 0))
A polygon with center-to-vertex distance r and n sides
pyramid_z(a, b, zmin, height)
A pyramid defined by its base rectangle, lower Z value, and height
rectangle(a, b)
A rectangle with the given bounding corners
rectangle_centered_exact(size, center=(0, 0))
An exact-field rectangle at the (optional) center
rectangle_exact(a, b)
A rectangle from an exact distance field
reflect_x(t, x0=0)
Reflects a shape about the x origin or an optional offset
reflect_xy(t)
Reflects a shape about the plane X=Y
reflect_xz(t)
Reflects a shape about the plane X=Z
reflect_y(t, y0=0)
Reflects a shape about the y origin or an optional offset
reflect_yz(t)
Reflects a shape about the plane Y=Z
reflect_z(t, z0=0)
Reflects a shape about the z origin or an optional offset
repel(shape, locus, radius, exaggerate=1)
Repels the shape away from a point based upon a radius r, with optional exaggeration
repel_x(shape, locus, radius, exaggerate=1)
Repels the shape away from a YZ plane based upon a radius r, with optional exaggeration
repel_xy(shape, locus, radius, exaggerate=1)
Repels the shape away from line parallel to the Z axis, with a particular radius and optional exaggeration
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
repel_y(shape, locus, radius, exaggerate=1)
Repels the shape away from a XZ plane based upon a radius r, with optional exaggeration
repel_yz(shape, locus, radius, exaggerate=1)
Repels the shape away from line parallel to the X axis, with a particular radius and optional exaggeration
repel_z(shape, locus, radius, exaggerate=1)
Repels the shape away from a XY plane based upon a radius r, with optional exaggeration
revolve_y(shape, x0=0)
Revolves a 2D (XY) shape about a line parallel to the Y axis with the given x value
ring(ro, ri, center=(0, 0))
A 2D ring with the given outer/inner radii and optional center
rotate(t, angle, center=(0, 0, 0))
Rotate the given shape by an angle in radians The center of rotation is [0 0 0] or specified by the optional argument
rotate_x(t, angle, center=(0, 0, 0))
Rotate the given shape by an angle in radians The center of rotation is [0 0 0] or specified by the optional argument
rotate_y(t, angle, center=(0, 0, 0))
Rotate the given shape by an angle in radians The center of rotation is [0 0 0] or specified by the optional argument
rotate_z(t, angle, center=(0, 0, 0))
Rotate the given shape by an angle in radians The center of rotation is [0 0 0] or specified by the optional argument
rounded_box(a, b, r)
Rounded box with the given bounds and radius (as a 0-1 fraction)
rounded_cube(a, b, r)
Rounded box with the given bounds and radius (as a 0-1 fraction)
rounded_rectangle(a, b, r)
A rectangle with rounded corners
scale_x(t, sx, x0=0)
Scales a shape by sx on the x axis about 0 or an optional offset
scale_xyz(t, s, center=(0, 0, 0))
Scales a shape on all three axes, about 0 or an optional offset
scale_y(t, sy, y0=0)
Scales a shape by sx on the x axis about 0 or an optional offset
scale_z(t, sz, z0=0)
Scales a shape by sx on the x axis about 0 or an optional offset
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
shell(a, offset)
Returns a shell of a shape with the given offset
sphere(radius, center=(0, 0, 0))
A sphere with the given radius and (optional) center
symmetric_x(t)
Clips the given shape at the x origin, then duplicates the remaining shape reflected on the other side of the origin
symmetric_y(t)
Clips the given shape at the y origin, then duplicates the remaining shape reflected on the other side of the origin
symmetric_z(t)
Clips the given shape at the z origin, then duplicates the remaining shape reflected on the other side of the origin
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]
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]
text(txt, pos=(0, 0))
Returns the given text, rendered in a custom f-rep font (with a character height of 1)
torus(ro, ri, center=(0, 0, 0))
A torus with the given outer radius, inner radius, and (optional) center
torus_z(ro, ri, center=(0, 0, 0))
A torus with the given outer radius, inner radius, and (optional) center
triangle(a, b, c)
A 2D triangle
tvec2(x, y)
tvec3(x, y, z)
twirl_axis_x(shape, amount, radius, center=(0, 0, 0))
Twirls the shape in the x axis about the line extending from the (optional) center point
twirl_axis_y(shape, amount, radius, center=(0, 0, 0))
Twirls the shape in the y axis about the line extending from the (optional) center point
twirl_axis_z(shape, amount, radius, center=(0, 0, 0))
Twirls the shape in the z axis about the line extending from the (optional) center point
twirl_x(shape, amount, radius, center=(0, 0, 0))
Twirls the shape in the x axis about the (optional) center point
twirl_y(shape, amount, radius, center=(0, 0, 0))
Twirls the shape in the y axis about the (optional) center point
twirl_z(shape, amount, radius, center=(0, 0, 0))
Twirls the shape in the z axis about the (optional) center point
union(a, *args)
Returns the union of two shapes
Last active
March 7, 2023 12:48
-
-
Save llandsmeer/fba9b7ced52edd623eef56ea5d127a77 to your computer and use it in GitHub Desktop.
libfive studio examples in python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# translation of the scheme examples here to python: | |
# https://libfive.com/examples/ | |
import studio | |
studio.set_bounds([-10, -10, -10], [10, 10, 10]) | |
studio.set_quality(8) | |
studio.set_resolution(10) | |
from libfive.stdlib import * | |
# | |
difference( | |
sphere(1, [0, 0, 0]), | |
cylinder_z(0.6, 2, [0, 0, -1]), | |
reflect_xz(cylinder_z(0.6, 2, [0, 0, -1])), | |
reflect_yz(cylinder_z(0.6, 2, [0, 0, -1])) | |
) |
Generated with
/usr/lib/python3/dist-packages/libfive/stdlib
rg ^def | tr . ' ' | awk 'a!=$1{print "# "$1}{a=$1; print}' | sed 's/.*def / - /g' | tr -d ':'
- union(a, b)
- intersection(a, b)
- inverse(a)
- difference(a, b)
- offset(a, o)
- clearance(a, b, offset)
- shell(a, offset)
- blend_expt(a, b, m)
- blend_expt_unit(a, b, m)
- blend_rough(a, b, m)
- blend_difference(a, b, m, o=0)
- morph(a, b, m)
- loft(a, b, zmin, zmax)
- loft_between(a, b, lower, upper)
- union(a, *args)
- intersection(a, *args)
- difference(a, b, *rest)
- circle(r, center=(0, 0))
- ring(ro, ri, center=(0, 0))
- polygon(r, n, center=(0, 0))
- rectangle(a, b)
- rounded_rectangle(a, b, r)
- rectangle_exact(a, b)
- rectangle_centered_exact(size, center=(0, 0))
- triangle(a, b, c)
- box_mitered(a, b)
- box_mitered_centered(size, center=(0, 0, 0))
- box_exact_centered(size, center=(0, 0, 0))
- box_exact(a, b)
- rounded_box(a, b, r)
- sphere(radius, center=(0, 0, 0))
- half_space(norm, point=(0, 0, 0))
- cylinder_z(r, h, base=(0, 0, 0))
- cone_ang_z(angle, height, base=(0, 0, 0))
- cone_z(radius, height, base=(0, 0, 0))
- pyramid_z(a, b, zmin, height)
- torus_z(ro, ri, center=(0, 0, 0))
- gyroid(period, thickness)
- emptiness()
- array_x(shape, nx, dx)
- array_xy(shape, nx, ny, delta)
- array_xyz(shape, nx, ny, nz, delta)
- array_polar_z(shape, n, center=(0, 0))
- extrude_z(t, zmin, zmax)
- move(t, offset)
- reflect_x(t, x0=0)
- reflect_y(t, y0=0)
- reflect_z(t, z0=0)
- reflect_xy(t)
- reflect_yz(t)
- reflect_xz(t)
- symmetric_x(t)
- symmetric_y(t)
- symmetric_z(t)
- scale_x(t, sx, x0=0)
- scale_y(t, sy, y0=0)
- scale_z(t, sz, z0=0)
- scale_xyz(t, s, center=(0, 0, 0))
- rotate_x(t, angle, center=(0, 0, 0))
- rotate_y(t, angle, center=(0, 0, 0))
- rotate_z(t, angle, center=(0, 0, 0))
- taper_x_y(shape, base, h, scale, base_scale=1)
- taper_xy_z(shape, base, height, scale, base_scale=1)
- shear_x_y(t, base, height, offset, base_offset=0)
- repel(shape, locus, radius, exaggerate=1)
- repel_x(shape, locus, radius, exaggerate=1)
- repel_y(shape, locus, radius, exaggerate=1)
- repel_z(shape, locus, radius, exaggerate=1)
- repel_xy(shape, locus, radius, exaggerate=1)
- repel_yz(shape, locus, radius, exaggerate=1)
- repel_xz(shape, locus, radius, exaggerate=1)
- attract(shape, locus, radius, exaggerate=1)
- attract_x(shape, locus, radius, exaggerate=1)
- attract_y(shape, locus, radius, exaggerate=1)
- attract_z(shape, locus, radius, exaggerate=1)
- attract_xy(shape, locus, radius, exaggerate=1)
- attract_yz(shape, locus, radius, exaggerate=1)
- attract_xz(shape, locus, radius, exaggerate=1)
- revolve_y(shape, x0=0)
- twirl_x(shape, amount, radius, center=(0, 0, 0))
- twirl_axis_x(shape, amount, radius, center=(0, 0, 0))
- twirl_y(shape, amount, radius, center=(0, 0, 0))
- twirl_axis_y(shape, amount, radius, center=(0, 0, 0))
- twirl_z(shape, amount, radius, center=(0, 0, 0))
- twirl_axis_z(shape, amount, radius, center=(0, 0, 0))
- move(shape, v)
- text(txt, pos=(0, 0))
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment