跳到主要内容

CubicBezTo

使用两个控制点从当前点到指定终点绘制三次贝塞尔曲线。

语法

expression.CubicBezTo(x1, y1, x2, y2, x3, y3);

expression - 表示 ApiPath 类的变量。

参数

名称必需/可选数据类型默认值描述
x1必需GeometryCoordinate第一个控制点的 X 坐标。
y1必需GeometryCoordinate第一个控制点的 Y 坐标。
x2必需GeometryCoordinate第二个控制点的 X 坐标。
y2必需GeometryCoordinate第二个控制点的 Y 坐标。
x3必需GeometryCoordinate终点的 X 坐标。
y3必需GeometryCoordinate终点的 Y 坐标。

返回值

此方法不返回任何数据。

示例

在演示文稿中绘制三次贝塞尔曲线作为自定义形状的一部分。

// How do I create a smooth curved segment in a custom shape in a presentation?

// Add a cubic Bézier curve to a geometry path on a slide in a presentation.

let presentation = Api.GetPresentation();
let slide = presentation.GetSlideByIndex(0);
let customGeometry = Api.CreateCustomGeometry();
let path = customGeometry.AddPath();
path.SetWidth(120 * 36000);
path.SetHeight(120 * 36000);
path.MoveTo(0, 60 * 36000);
path.CubicBezTo(0, 0, 60 * 36000, 0, 60 * 36000, 60 * 36000);
path.QuadBezTo(120 * 36000, 60 * 36000, 120 * 36000, 120 * 36000);
path.ArcTo(60 * 36000, 60 * 36000, 0, 10800000);
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", 120 * 36000, 120 * 36000, fill, stroke);
shape.SetGeometry(customGeometry);
shape.SetPosition(2000000, 1000000);
slide.AddObject(shape);