@@ -36,51 +36,6 @@ import {
36
36
} from './utilities' ;
37
37
import { type List } from './types' ;
38
38
39
- /**
40
- * Colour the shape using the specified hex colour code.
41
- *
42
- * @param {Shape } shape - The Shape to be coloured and returned
43
- * @param {string } hex - The colour code to use
44
- * @returns {Shape } The colorized shape
45
- */
46
- function colorize ( shape : Shape , hex : string ) {
47
- let color : Color = hexToColor ( hex ) ;
48
- let coloredSolid : Solid = _colorize ( color , shape . solid ) ;
49
- return new Shape ( coloredSolid ) ;
50
- }
51
-
52
- /**
53
- * Returns a lambda function that contains the center of the given shape in the
54
- * x, y and z direction. Providing 'x', 'y', 'z' as input would return x, y and
55
- * z coordinates of shape's center
56
- *
57
- * For example
58
- * ````
59
- * const a = shape_center(sphere);
60
- * a('x'); // Returns the x coordinate of the shape's center
61
- * ````
62
- *
63
- * @param {Shape } shape - The scale to be measured
64
- * @returns {(String) => number } A lambda function providing the shape's center
65
- * coordinates
66
- */
67
- function shape_center ( shape : Shape ) : ( axis : String ) => number {
68
- let bounds : BoundingBox = measureBoundingBox ( shape . solid ) ;
69
- let centerCoords : Coordinates = [
70
- bounds [ 0 ] [ 0 ] + ( bounds [ 1 ] [ 0 ] - bounds [ 0 ] [ 0 ] ) / 2 ,
71
- bounds [ 0 ] [ 1 ] + ( bounds [ 1 ] [ 1 ] - bounds [ 0 ] [ 1 ] ) / 2 ,
72
- bounds [ 0 ] [ 2 ] + ( bounds [ 1 ] [ 2 ] - bounds [ 0 ] [ 2 ] ) / 2 ,
73
- ] ;
74
- return ( axis : String ) : number => {
75
- let i : number = axis === 'x' ? 0 : axis === 'y' ? 1 : axis === 'z' ? 2 : - 1 ;
76
- if ( i === - 1 ) {
77
- throw Error ( "shape_center's returned function expects a proper axis." ) ;
78
- } else {
79
- return centerCoords [ i ] ;
80
- }
81
- } ;
82
- }
83
-
84
39
/**
85
40
* Center the provided shape with the middle base of the shape at (0, 0, 0).
86
41
*
@@ -500,7 +455,7 @@ export function intersect(a: Shape, b: Shape): Shape {
500
455
* @returns {Shape } Resulting Shape
501
456
*/
502
457
export function scale ( entity : Entity , x : number , y : number , z : number ) : Entity {
503
- if ( x === 0 || y === 0 || z == = 0 ) {
458
+ if ( x <= 0 || y <= 0 || z < = 0 ) {
504
459
throw new Error ( 'factors must be non-zero' ) ;
505
460
}
506
461
return entity . scale ( [ x , y , z ] ) ;
0 commit comments