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

Method CreatePath

core/graphics/shape/Rect.cpp:10–69  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8}
9
10void xg::shape::Rect::CreatePath(canvas::CanvasContext &context) const {
11 context.BeginPath();
12 if(radius_ <= XG_EPS) {
13 if(this->HasRounding()) {
14 float height = static_cast<float>(size_.height);//height < 0 柱朝上
15 float width = static_cast<float>(size_.width);
16 float x = static_cast<float>(point_.x);
17 float y = static_cast<float>(point_.y);
18 if (width >= 0) {
19 context.MoveTo(x + roundings[2], y);
20 context.LineTo(x + width - roundings[3], y);
21 } else {
22 context.MoveTo(x - roundings[2], y);
23 context.LineTo(x + width + roundings[3], y);
24 }
25 if (height < 0) {
26 context.QuadraticCurveTo(x + width, y, x + width, y - roundings[3]);
27 context.LineTo(x + width, y + height + roundings[1]);
28 }else {
29 context.QuadraticCurveTo(x + width, y, x + width, y + roundings[3]);
30 context.LineTo(x + width, y + height - roundings[1]);
31 }
32 if (width >= 0) {
33 context.QuadraticCurveTo(x + width, y + height, x + width - roundings[1], y + height);
34 context.LineTo(x + roundings[0], y + height);
35 } else {
36 context.QuadraticCurveTo(x + width, y + height, x + width + roundings[1], y + height);
37 context.LineTo(x - roundings[0], y + height);
38 }
39 if (height < 0) {
40 context.QuadraticCurveTo(x, y + height, x, y + height + roundings[0]);
41 context.LineTo(x, y - roundings[2]);
42 } else {
43 context.QuadraticCurveTo(x, y + height, x, y + height - roundings[0]);
44 context.LineTo(x, y + roundings[2]);
45 }
46 if (width >= 0) {
47 context.QuadraticCurveTo(x, y, x + roundings[2], y);
48 } else {
49 context.QuadraticCurveTo(x, y, x - roundings[2], y);
50 }
51 } else {
52 context.Rect(point_.x, point_.y, size_.width, size_.height);
53 }
54 context.ClosePath();
55 } else {
56 double unitX = std::cos(startAngle_);
57 double unitY = std::sin(startAngle_);
58 context.SetLineDash(this->dash_);
59 context.MoveTo(unitX * radius0_ + point_.x, unitY * radius0_ + point_.y);
60 context.LineTo(unitX * radius_ + point_.x, unitY * radius_ + point_.y);
61 if(fabs(endAngle_ - startAngle_) > 0.0001 || (fabs(startAngle_) <= XG_EPS && fabs(endAngle_) <= XG_EPS)) {
62 context.Arc(point_.x, point_.y, radius_, startAngle_, endAngle_, false);
63 context.LineTo(std::cos(endAngle_) * radius0_ + point_.x, std::sin(endAngle_) * radius0_ + point_.y);
64 if(radius0_ >= XG_EPS) {
65 context.Arc(point_.x, point_.y, radius0_, endAngle_, startAngle_, true);
66 }
67 }

Callers 2

DoClipMethod · 0.45
DoClipByIdentifierMethod · 0.45

Calls 9

HasRoundingMethod · 0.95
BeginPathMethod · 0.45
MoveToMethod · 0.45
LineToMethod · 0.45
QuadraticCurveToMethod · 0.45
RectMethod · 0.45
ClosePathMethod · 0.45
SetLineDashMethod · 0.45
ArcMethod · 0.45

Tested by

no test coverage detected