跳到主要内容

MoveTo

将当前路径移动到指定坐标。

语法

expression.MoveTo(x, y);

expression - 表示 ApiPath 类的变量。

参数

名称必需/可选数据类型默认值描述
x必需GeometryCoordinateX 坐标。
y必需GeometryCoordinateY 坐标。

返回值

此方法不返回任何数据。

示例

创建自定义形状并将其添加到幻灯片。应用具有特定填充和笔触属性的自定义几何图形。

// How can I move to using a geometry path in a presentation?

// Move to for a geometry path in a presentation.

let presentation = Api.GetPresentation();
let slide = presentation.GetSlideByIndex(0);
let customGeometry = Api.CreateCustomGeometry();
let path = customGeometry.AddPath();
path.SetWidth(100 * 36000);
path.SetHeight(100 * 36000);
path.SetStroke(true);
path.SetFill("norm");
path.MoveTo(50 * 36000, 0);
path.LineTo(70 * 36000, 45 * 36000);
path.LineTo(55 * 36000, 70 * 36000);
path.LineTo(100 * 36000, 100 * 36000);
path.LineTo(0, 100 * 36000);
path.Close();
let fill = Api.CreateSolidFill(Api.RGB(100, 150, 200));
let stroke = Api.CreateStroke(36000, Api.CreateSolidFill(Api.RGB(50, 75, 100)));
let shape = Api.CreateShape("rect", 100 * 36000, 100 * 36000, fill, stroke);
shape.SetGeometry(customGeometry);
shape.SetPosition(2000000, 1000000);
slide.AddObject(shape);