Methods
计算多个图形的总面积
| Name | Type | Description |
|---|---|---|
shapes |
Array.<Shape> | 图形数组 |
Returns:
所有图形的总面积
static SDK.ShapeFactory.createShape(type, options) → Shape
根据类型创建图形
| Name | Type | Description | |||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
type |
ShapeType | 图形类型 | |||||||||||||||||||||
options |
Object |
图形配置选项
|
Returns:
创建的图形对象
Throws:
-
Error : 当图形类型不支持或参数不正确时抛出错误
Example:
// 创建一个圆形
const circle = ShapeFactory.createShape(ShapeType.CIRCLE, {
name: 'myCircle',
x: 0,
y: 0,
radius: 5
});
// 创建一个矩形
const rect = ShapeFactory.createShape(ShapeType.RECTANGLE, {
name: 'myRect',
x: 0,
y: 0,
width: 4,
height: 5
});
static SDK.ShapeFactory.createShapes(configs) → Array.<Shape>
批量创建图形
| Name | Type | Description |
|---|---|---|
configs |
Array.<Object> | 图形配置数组 |
Returns:
创建的图形数组
Example:
const shapes = ShapeFactory.createShapes([
{
type: ShapeType.CIRCLE,
options: { name: 'c1', x: 0, y: 0, radius: 5 }
},
{
type: ShapeType.RECTANGLE,
options: { name: 'r1', x: 10, y: 10, width: 4, height: 5 }
}
]);
static SDK.ShapeFactory.findShapeByName(shapes, name) → Shape|undefined
根据名称查找图形
| Name | Type | Description |
|---|---|---|
shapes |
Array.<Shape> | 图形数组 |
name |
string | 要查找的图形名称 |
Returns:
找到的图形,如果未找到返回undefined
