MCPcopy Create free account
hub / github.com/antvis/F2Native / CreatePath

Method CreatePath

core/graphics/shape/Area.cpp:16–35  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14}
15
16void xg::shape::Area::CreatePath(canvas::CanvasContext &context) const {
17 context.BeginPath();
18 if(mergePoints_.size()) {
19 context.MoveTo(mergePoints_[0].x + this->point_.x, mergePoints_[0].y + this->point_.y);
20 std::size_t len = mergePoints_.size();
21 if(smooth_ && len > 2) {
22 array<Point, 2> constraint = {Point(0, 0), Point(1, 1)};
23 BezierPath b_path = util::PathUtil::getSplinePath(mergePoints_, false, constraint);
24 auto lineTo = [&](const BezierPoint &point) {
25 context.BezierCurveTo(point.cp1.x, point.cp1.y, point.cp2.x, point.cp2.y, point.p.x, point.p.y);
26 };
27 // TODO 增加计算基于 point_ 的偏移
28 std::for_each(b_path.begin(), b_path.end(), lineTo);
29 } else {
30 auto lineTo = [&](const Point &point) { context.LineTo(point.x + this->point_.x, point.y + this->point_.y); };
31 std::for_each(mergePoints_.begin() + 1, mergePoints_.end(), lineTo);
32 }
33 context.ClosePath();
34 }
35}
36
37BBox xg::shape::Area::CalculateBox(canvas::CanvasContext &context) const {
38 // TODO 增加计算基于 point_ 的偏移

Callers

nothing calls this directly

Calls 9

beginMethod · 0.80
endMethod · 0.80
PointClass · 0.50
BeginPathMethod · 0.45
sizeMethod · 0.45
MoveToMethod · 0.45
BezierCurveToMethod · 0.45
LineToMethod · 0.45
ClosePathMethod · 0.45

Tested by

no test coverage detected