meta data for this page
Shape Attributes
at
Color
Shapes can exhibit different colors. And just like the other transformations, adding color to a shape produces a new shape, i.e. one with color.
Colors are not only important for visual rendering but also controlling the selection of filaments during 3D printing. Therefore, colors should be applied as the last step in designs to insure proper printing.
const myshape = colorize([1, 0, 0], sphere()) // RGB red const myshape = colorize([1, 0.5, 0.3], sphere()) // color const myshape = colorize([1, 0.5, 0.3, 0.6], sphere()) // color plus alpha transparency
Note: There are known issues with transparency, and depending on the order of colors, objects may not seem transparent. Try different 'alpha' values or colors.
Color Space Conversion
There are several functions to convert between color spaces, including color names.
const wildcylinder = colorize(colorNameToRgb('fuchsia'), cylinder()) const bluesphere = colorize(hexToRgb('#000080'), sphere()) // navy blue const mysphere = colorize(hslToRgb([0.9166666666666666, 1, 0.5]), sphere()) const mysphere = colorize(hsvToRgb([0.9166666666666666, 1, 1]), sphere())
whereas
- r,g,b (red, green, blue) of RGB color model
- h,s,l (hue, saturation, lightness) of HSL color model
- h,s,v (hue, saturation, value) of HSV color model
See the Extended Color Keywords for all available colors. Color keywords are case-insensitive, e.g. 'RED' is the same as 'red'.
Measurements
Sometimes the measurements of a shape can assist when creating a design. This is especially true for shapes imported from external formats.
Area
Measuring the area of a shape is possible, for both 2D and 3D shapes.
Note: The area for a path is always zero(0) as paths are infinitely thin.
Bounding Box
Measuring the bounding box (min and max bounds) of a shape is possible.
The getBounds function can be used to retrieve the bounding box of an object, returning an array with two points specifying the minimum and maximum coordinates, i.e. X, Y, Z values.
Bounding Sphere
Measuring the (approximate) bounding sphere of a shape is possible.
Center
Measuring the center of a shape is possible.
Note: This is equivalent to the center of the bounding box.
Center of Mass
Measuring the center of mass of a shape is possible.
Note: The center of mass for a path is always zero(0) as paths are infinitely thin.
Dimensions
Measuring the dimensions of a shape is possible.
Note: This is the equivalent width, depth, height of the bounding box.
Epsilon
Measuring the epsilon of shapes is possible. Epsilon values are used in various functions to determine minimum distances between points, planes, etc.
Volume
Measuring the volume of a shape is possible.
Note: The volume of 2D shapes is always zero(0).