Appearance
@jtopo/core / ShapeBuilder
Class: ShapeBuilder
几何形状生成器, 用于生成几何形状的顶点坐标
js
// 生成一个10x10的网格
let points = ShapeBuilder.grid(10, 10);
console.log(points);
// 生成一个圆环
let circlePoints = ShapeBuilder.circle({ vertexCount: 10 });
console.log(circlePoints);
// 生成一个正多边形
let polygonPoints = ShapeBuilder.polygon(5);
console.log(polygonPoints);
// 生成一个三角形
let trianglePoints = ShapeBuilder.circle({ vertexCount: 3, beginAngle: 0, endAngle: Math.PI * 2 });
console.log(trianglePoints);
Table of contents
Constructors
Methods
Constructors
constructor
new ShapeBuilder()
Methods
circle
Static
circle(opt
): any
[]
生成圆环点坐标
Parameters
Name | Type |
---|---|
opt | BuildCircleOpt |
Returns
any
[]
PointLike[] 顶点坐标集合
grid
Static
grid(rows
, cols
): PointLike
[]
生成二维网格坐标(外边框)数组
Parameters
Name | Type | Description |
---|---|---|
rows | number | 行 |
cols | number | 列 |
Returns
PointLike[] 顶点坐标集合
innerGrid
Static
innerGrid(rows
, cols
): PointLike
[]
生成二维内网格坐标数组
Parameters
Name | Type | Description |
---|---|---|
rows | number | 行 |
cols | number | 列 |
Returns
PointLike[] 顶点坐标集合
polygon
Static
polygon(edgeCount
): any
[]
生成 正多边形 (最小为3边形,小于3边形时,按3边形处理)
Parameters
Name | Type | Description |
---|---|---|
edgeCount | number | 边数 |
Returns
any
[]
PointLike[] 顶点坐标集合