###### 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.

const { measureArea, measureBoundingBox, measureVolume } = require('@jscad/modeling').measurements

#### Area

Measuring the area of a shape is possible, for both 2D and 3D shapes.

let area = measureArea(sphere())

*Note: The area for a path is always zero(0) as paths are infinitely thin.*

In addition, the total (aggregate) area for the given geometries can be measured.

let totalArea = measureAggregateArea(sphere(),cube())

*Note: This measurement will not account for overlapping geometry.*

#### Bounding Box

Measuring the bounding box (min and max bounds) of a shape is possible.

The measureBoundingBox 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.

let bounds = measureBoundingBox(sphere())

In addition, the total (aggregate) bounding box for the given geometries can be measured.

let totalBounds = measureAggregateBoundingBox(sphere(),cube())

#### Bounding Sphere

Measuring the (approximate) bounding sphere of a shape is possible.

let bounds = measureBoundingSphere(cube())

#### Center

Measuring the center of a shape is possible.

let center = measureCenter(sphere())

*Note: This is equivalent to the center of the bounding box.*

#### Center of Mass

Measuring the center of mass of a shape is possible.

let center = measureCenterOfMass(sphere())

*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, i.e. width, depth, and height of a shape.

let dimensions = measureDimensions(sphere())

*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.

let epsilon = measureEpsilon(sphere())

In addition, the combined epsilon for a group geometries can be measured.

let groupEpsilon = measureAggregateEpsilon(sphere(),cube())

#### Volume

Measuring the volume of a shape is possible.

let volume = measureVolume(sphere())

*Note: The volume of 2D shapes is always zero(0).*

In addition, the total (aggregate) volume for the given geometries can be measured.

let totalVolume = measureAggregateVolume(sphere(),cube())

*Note: This measurement will not account for overlapping geometry.*