1 /*
2 * Copyright (c) 2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 /**
17 * @file geometry_curves.h
18 *
19 * @brief Bezier Curve
20 *
21 * @since 1.0
22 * @version 1.0
23 */
24
25 #ifndef GRAPHIC_LITE_GEOMETRY_CURVES_H
26 #define GRAPHIC_LITE_GEOMETRY_CURVES_H
27
28 #include "gfx_utils/vector.h"
29 namespace OHOS {
30 const uint8_t CURVE_POINTS_LENGTH = 8;
31
32 enum CurveApproximationMethod {
33 CURVEINCREMENT,
34 CURVEDIVIDOPERATE
35 };
36
37 class QuadBezierCurveIncr {
38 public:
QuadBezierCurveIncr()39 QuadBezierCurveIncr() : numberSteps_(0), currentStep_(0), approximationScale_(1.0f) {}
40
QuadBezierCurveIncr(float x1,float y1,float x2,float y2,float x3,float y3)41 QuadBezierCurveIncr(float x1, float y1,
42 float x2, float y2,
43 float x3, float y3)
44 : numberSteps_(0), currentStep_(0), approximationScale_(1.0f)
45 {
46 Init(x1, y1, x2, y2, x3, y3);
47 }
48
49 void Init(float x1, float y1, float x2, float y2, float x3, float y3);
50
Reset()51 void Reset()
52 {
53 numberSteps_ = 0;
54 currentStep_ = -1;
55 }
56
ApproximationMethod(CurveApproximationMethod)57 void ApproximationMethod(CurveApproximationMethod) {}
58
ApproximationMethod()59 CurveApproximationMethod ApproximationMethod() const
60 {
61 return CURVEINCREMENT;
62 }
63
64 void ApproximationScale(float scale);
65 float ApproximationScale() const;
66
AngleTolerance(float)67 void AngleTolerance(float) {}
68
AngleTolerance()69 float AngleTolerance() const
70 {
71 return 0.0f;
72 }
73
CuspLimit(float)74 void CuspLimit(float) {}
75
CuspLimit()76 float CuspLimit() const
77 {
78 return 0.0f;
79 }
80
81 void Rewind(uint32_t pathId);
82 uint32_t GenerateVertex(float* x, float* y);
83
84 private:
85 int32_t numberSteps_;
86 int32_t currentStep_;
87 float approximationScale_;
88 PointF startCoordinate_;
89 PointF endCoordinate_;
90 PointF finalCoordinate_;
91 PointF deltaFinalCoordinate_;
92 PointF copyDeltaFinalCoordinate_;
93 PointF savedFinalCoordinate_;
94 PointF savedDeltaFinalCoordinate_;
95 };
96
97 class QuadrBezierCurveDividOp {
98 public:
QuadrBezierCurveDividOp()99 QuadrBezierCurveDividOp()
100 : approximationScale_(1.0f), distanceToleranceSquare_(0.0f), angleTolerance_(0.0f), count_(0) {}
101
QuadrBezierCurveDividOp(float x1,float y1,float x2,float y2,float x3,float y3)102 QuadrBezierCurveDividOp(float x1, float y1,
103 float x2, float y2,
104 float x3, float y3)
105 : approximationScale_(1.0f), angleTolerance_(0.0f), count_(0)
106 {
107 Init(x1, y1, x2, y2, x3, y3);
108 }
109
110 void Init(float x1, float y1, float x2, float y2, float x3, float y3);
111
Reset()112 void Reset()
113 {
114 points_.Clear();
115 count_ = 0;
116 }
117
ApproximationMethod(CurveApproximationMethod)118 void ApproximationMethod(CurveApproximationMethod) {}
119
ApproximationMethod()120 CurveApproximationMethod ApproximationMethod() const
121 {
122 return CURVEDIVIDOPERATE;
123 }
124
ApproximationScale(float scale)125 void ApproximationScale(float scale)
126 {
127 approximationScale_ = scale;
128 }
ApproximationScale()129 float ApproximationScale() const
130 {
131 return approximationScale_;
132 }
133
AngleTolerance(float angle)134 void AngleTolerance(float angle)
135 {
136 angleTolerance_ = angle;
137 }
AngleTolerance()138 float AngleTolerance() const
139 {
140 return angleTolerance_;
141 }
142
CuspLimit(float)143 void CuspLimit(float) {}
144
CuspLimit()145 float CuspLimit() const
146 {
147 return 0.0f;
148 }
149
Rewind(uint32_t)150 void Rewind(uint32_t)
151 {
152 count_ = 0;
153 }
154
GenerateVertex(float * x,float * y)155 uint32_t GenerateVertex(float* x, float* y)
156 {
157 if (count_ >= points_.Size()) {
158 return PATH_CMD_STOP;
159 }
160 const PointF& point = points_[count_++];
161 *x = point.x;
162 *y = point.y;
163 return (count_ == 1) ? PATH_CMD_MOVE_TO : PATH_CMD_LINE_TO;
164 }
165
166 private:
167 void Bezier(float x1, float y1,
168 float x2, float y2,
169 float x3, float y3);
170 void Recursive(float x1, float y1,
171 float x2, float y2,
172 float x3, float y3,
173 uint32_t level);
174
175 float approximationScale_;
176 float distanceToleranceSquare_;
177 float angleTolerance_;
178 uint32_t count_;
179 Graphic::Vector<PointF> points_;
180 };
181
182 struct CubicBezierCurvePoints {
183 float cpArray[CURVE_POINTS_LENGTH];
184
CubicBezierCurvePointsCubicBezierCurvePoints185 CubicBezierCurvePoints() {}
186
CubicBezierCurvePointsCubicBezierCurvePoints187 CubicBezierCurvePoints(float x1, float y1,
188 float x2, float y2,
189 float x3, float y3,
190 float x4, float y4)
191 {
192 cpArray[0] = x1;
193 cpArray[1] = y1;
194 cpArray[2] = x2;
195 cpArray[3] = y2;
196 cpArray[4] = x3;
197 cpArray[5] = y3;
198 cpArray[6] = x4;
199 cpArray[7] = y4;
200 }
201
InitCubicBezierCurvePoints202 void Init(float x1, float y1,
203 float x2, float y2,
204 float x3, float y3,
205 float x4, float y4)
206 {
207 cpArray[0] = x1;
208 cpArray[1] = y1;
209 cpArray[2] = x2;
210 cpArray[3] = y2;
211 cpArray[4] = x3;
212 cpArray[5] = y3;
213 cpArray[6] = x4;
214 cpArray[7] = y4;
215 }
216
217 float operator[](uint32_t i) const
218 {
219 return cpArray[i];
220 }
221 float& operator[](uint32_t i)
222 {
223 return cpArray[i];
224 }
225 };
226
227 class CubicBezierCurveIncrement {
228 public:
CubicBezierCurveIncrement()229 CubicBezierCurveIncrement()
230 : numberSteps_(0), currentStep_(0), approximationScale_(1.0f) {}
231
CubicBezierCurveIncrement(float x1,float y1,float x2,float y2,float x3,float y3,float x4,float y4)232 CubicBezierCurveIncrement(float x1, float y1, float x2, float y2,
233 float x3, float y3, float x4, float y4)
234 : numberSteps_(0), currentStep_(0), approximationScale_(1.0f)
235 {
236 Init(x1, y1, x2, y2, x3, y3, x4, y4);
237 }
238
CubicBezierCurveIncrement(const CubicBezierCurvePoints & curve4Points)239 CubicBezierCurveIncrement(const CubicBezierCurvePoints& curve4Points)
240 : numberSteps_(0), currentStep_(0), approximationScale_(1.0f)
241 {
242 Init(curve4Points[0], curve4Points[1], curve4Points[2], curve4Points[3],
243 curve4Points[4], curve4Points[5], curve4Points[6], curve4Points[7]);
244 }
245
246 void Init(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4);
Init(const CubicBezierCurvePoints & curve4Points)247 void Init(const CubicBezierCurvePoints& curve4Points)
248 {
249 Init(curve4Points[0], curve4Points[1], curve4Points[2], curve4Points[3],
250 curve4Points[4], curve4Points[5], curve4Points[6], curve4Points[7]);
251 }
252
Reset()253 void Reset()
254 {
255 numberSteps_ = 0;
256 currentStep_ = -1;
257 }
258
ApproximationMethod(CurveApproximationMethod)259 void ApproximationMethod(CurveApproximationMethod) {}
260
ApproximationMethod()261 CurveApproximationMethod ApproximationMethod() const
262 {
263 return CURVEINCREMENT;
264 }
265
266 void ApproximationScale(float scale);
267 float ApproximationScale() const;
268
AngleTolerance(float)269 void AngleTolerance(float) {}
270
AngleTolerance()271 float AngleTolerance() const
272 {
273 return 0.0f;
274 }
275
CuspLimit(float)276 void CuspLimit(float) {}
277
CuspLimit()278 float CuspLimit() const
279 {
280 return 0.0f;
281 }
282
283 void Rewind(uint32_t pathId);
284 uint32_t GenerateVertex(float* x, float* y);
285
286 private:
287 int32_t numberSteps_;
288 int32_t currentStep_;
289 float approximationScale_;
290 PointF startCoordinate_;
291 PointF endCoordinate_;
292 PointF finalCoordinate_;
293 PointF deltaFinalCoordinate_;
294 PointF copyDeltaFinalCoordinate_;
295 PointF repeatCopyDeltaFinalCoordinate_;
296 PointF savedFinalCoordinate_;
297 PointF savedDeltaFinalCoordinate_;
298 PointF savedCopyDeltaFinalCoordinate_;
299 };
300
CatromToBezier(float x1,float y1,float x2,float y2,float x3,float y3,float x4,float y4)301 inline CubicBezierCurvePoints CatromToBezier(float x1, float y1,
302 float x2, float y2,
303 float x3, float y3,
304 float x4, float y4)
305 {
306 return CubicBezierCurvePoints(
307 x2,
308 y2,
309 (-x1 + SIX_TIMES * x2 + x3) / SIX_TIMES,
310 (-y1 + SIX_TIMES * y2 + y3) / SIX_TIMES,
311 (x2 + SIX_TIMES * x3 - x4) / SIX_TIMES,
312 (y2 + SIX_TIMES * y3 - y4) / SIX_TIMES,
313 x3,
314 y3);
315 }
316
CatromToBezier(const CubicBezierCurvePoints & curve4Points)317 inline CubicBezierCurvePoints CatromToBezier(const CubicBezierCurvePoints& curve4Points)
318 {
319 return CatromToBezier(curve4Points[0], curve4Points[1], curve4Points[2],
320 curve4Points[3], curve4Points[4], curve4Points[5],
321 curve4Points[6], curve4Points[7]);
322 }
323 /**
324 * @brief bspline Convert Curve to Cubic Bezier Curve
325 * @param bspline Curve 4 points, start, end and middle 2 control points
326 * @since 1.0
327 * @version 1.0
328 */
UbsplineToBezier(float x1,float y1,float x2,float y2,float x3,float y3,float x4,float y4)329 inline CubicBezierCurvePoints UbsplineToBezier(float x1, float y1,
330 float x2, float y2,
331 float x3, float y3,
332 float x4, float y4)
333 {
334 return CubicBezierCurvePoints(
335 (x1 + FOUR_TIMES * x2 + x3) / SIX_TIMES,
336 (y1 + FOUR_TIMES * y2 + y3) / SIX_TIMES,
337 (FOUR_TIMES * x2 + TWO_TIMES * x3) / SIX_TIMES,
338 (FOUR_TIMES * y2 + TWO_TIMES * y3) / SIX_TIMES,
339 (TWO_TIMES * x2 + FOUR_TIMES * x3) / SIX_TIMES,
340 (TWO_TIMES * y2 + FOUR_TIMES * y3) / SIX_TIMES,
341 (x2 + FOUR_TIMES * x3 + x4) / SIX_TIMES,
342 (y2 + FOUR_TIMES * y3 + y4) / SIX_TIMES);
343 }
344 /**
345 * @brief bspline Convert Curve to Bezier Curve
346 * @param bspline Curve 4 points, start, end and middle 2 control points
347 * @since 1.0
348 * @version 1.0
349 */
UbsplineToBezier(const CubicBezierCurvePoints & curve4Points)350 inline CubicBezierCurvePoints UbsplineToBezier(const CubicBezierCurvePoints& curve4Points)
351 {
352 return UbsplineToBezier(curve4Points[0], curve4Points[1], curve4Points[2], curve4Points[3],
353 curve4Points[4], curve4Points[5], curve4Points[6], curve4Points[7]);
354 }
355 /**
356 * @brief Hermite Convert Curve to 3-order Bezier Curve
357 * @param Hermite Curve 2 points, start and end
358 * @since 1.0
359 * @version 1.0
360 */
HermiteToBezier(float x1,float y1,float x2,float y2,float x3,float y3,float x4,float y4)361 inline CubicBezierCurvePoints HermiteToBezier(float x1, float y1,
362 float x2, float y2,
363 float x3, float y3,
364 float x4, float y4)
365 {
366 return CubicBezierCurvePoints(
367 x1, y1,
368 (THREE_TIMES * x1 + x3) / THREE_TIMES,
369 (THREE_TIMES * y1 + y3) / THREE_TIMES,
370 (THREE_TIMES * x2 - x4) / THREE_TIMES,
371 (THREE_TIMES * y2 - y4) / THREE_TIMES,
372 x2, y2);
373 }
374 /**
375 * @brief Hermite Convert Curve to 3-order Bezier Curve
376 * @param Hermite Curve 2 points, start and end
377 * @since 1.0
378 * @version 1.0
379 */
HermiteToBezier(const CubicBezierCurvePoints & curve4Points)380 inline CubicBezierCurvePoints HermiteToBezier(const CubicBezierCurvePoints& curve4Points)
381 {
382 return HermiteToBezier(curve4Points[0], curve4Points[1],
383 curve4Points[2], curve4Points[3],
384 curve4Points[4], curve4Points[5],
385 curve4Points[6], curve4Points[7]);
386 }
387
388 class CubicBezierCurveDividOperate {
389 public:
CubicBezierCurveDividOperate()390 CubicBezierCurveDividOperate()
391 : approximationScale_(1.0f), distanceToleranceSquare_(0.0f),
392 angleTolerance_(0.0f), cuspLimit_(0.0f), count_(0) {}
393
CubicBezierCurveDividOperate(float x1,float y1,float x2,float y2,float x3,float y3,float x4,float y4)394 CubicBezierCurveDividOperate(float x1, float y1,
395 float x2, float y2,
396 float x3, float y3,
397 float x4, float y4)
398 : approximationScale_(1.0f), angleTolerance_(0.0f), cuspLimit_(0.0f), count_(0)
399 {
400 Init(x1, y1, x2, y2, x3, y3, x4, y4);
401 }
402
CubicBezierCurveDividOperate(const CubicBezierCurvePoints & curve4Points)403 CubicBezierCurveDividOperate(const CubicBezierCurvePoints& curve4Points)
404 : approximationScale_(1.0f), angleTolerance_(0.0f), count_(0)
405 {
406 Init(curve4Points[0], curve4Points[1],
407 curve4Points[2], curve4Points[3],
408 curve4Points[4], curve4Points[5],
409 curve4Points[6], curve4Points[7]);
410 }
411
412 void Init(float x1, float y1,
413 float x2, float y2,
414 float x3, float y3,
415 float x4, float y4);
416
Init(const CubicBezierCurvePoints & curve4Points)417 void Init(const CubicBezierCurvePoints& curve4Points)
418 {
419 Init(curve4Points[0], curve4Points[1],
420 curve4Points[2], curve4Points[3],
421 curve4Points[4], curve4Points[5],
422 curve4Points[6], curve4Points[7]);
423 }
424
Reset()425 void Reset()
426 {
427 points_.Clear();
428 count_ = 0;
429 }
430
ApproximationMethod(CurveApproximationMethod)431 void ApproximationMethod(CurveApproximationMethod) {}
432
ApproximationMethod()433 CurveApproximationMethod ApproximationMethod() const
434 {
435 return CURVEDIVIDOPERATE;
436 }
437
ApproximationScale(float scale)438 void ApproximationScale(float scale)
439 {
440 approximationScale_ = scale;
441 }
ApproximationScale()442 float ApproximationScale() const
443 {
444 return approximationScale_;
445 }
446
AngleTolerance(float angleValue)447 void AngleTolerance(float angleValue)
448 {
449 angleTolerance_ = angleValue;
450 }
AngleTolerance()451 float AngleTolerance() const
452 {
453 return angleTolerance_;
454 }
455
CuspLimit(float angleValue)456 void CuspLimit(float angleValue)
457 {
458 cuspLimit_ = (angleValue == 0.0f) ? 0.0f : PI - angleValue;
459 }
460
CuspLimit()461 float CuspLimit() const
462 {
463 return (cuspLimit_ == 0.0f) ? 0.0f : PI - cuspLimit_;
464 }
465
Rewind(uint32_t)466 void Rewind(uint32_t)
467 {
468 count_ = 0;
469 }
470
GenerateVertex(float * x,float * y)471 uint32_t GenerateVertex(float* x, float* y)
472 {
473 if (count_ >= points_.Size()) {
474 return PATH_CMD_STOP;
475 }
476 const PointF& p = points_[count_++];
477 *x = p.x;
478 *y = p.y;
479 return (count_ == 1) ? PATH_CMD_MOVE_TO : PATH_CMD_LINE_TO;
480 }
481
482 private:
483 void Bezier(float x1, float y1,
484 float x2, float y2,
485 float x3, float y3,
486 float x4, float y4);
487
488 void Recursive(float x1, float y1,
489 float x2, float y2,
490 float x3, float y3,
491 float x4, float y4,
492 uint32_t level);
493
494 float approximationScale_;
495 float distanceToleranceSquare_;
496 float angleTolerance_;
497 float cuspLimit_;
498 uint32_t count_;
499 Graphic::Vector<PointF> points_;
500 };
501
502 /**
503 * @brief quadratic Bezier curve.
504 *
505 * Draw a curve from the start, inflection and end points.
506 *
507 * @see QuadraticBezierCurve.
508 * @since 1.0
509 * @version 1.0
510 */
511 class QuadraticBezierCurve {
512 public:
QuadraticBezierCurve()513 QuadraticBezierCurve()
514 : approximationMethod_(CURVEDIVIDOPERATE) {}
515
QuadraticBezierCurve(float x1,float y1,float x2,float y2,float x3,float y3)516 QuadraticBezierCurve(float x1, float y1, float x2, float y2, float x3, float y3)
517 : approximationMethod_(CURVEDIVIDOPERATE)
518 {
519 Init(x1, y1, x2, y2, x3, y3);
520 }
521
Init(float x1,float y1,float x2,float y2,float x3,float y3)522 void Init(float x1, float y1, float x2, float y2, float x3, float y3)
523 {
524 if (approximationMethod_ == CURVEINCREMENT) {
525 curveInc_.Init(x1, y1, x2, y2, x3, y3);
526 } else {
527 curveDiv_.Init(x1, y1, x2, y2, x3, y3);
528 }
529 }
530
Reset()531 void Reset()
532 {
533 curveInc_.Reset();
534 curveDiv_.Reset();
535 }
536
ApproximationMethod(CurveApproximationMethod curveApproximationMethod)537 void ApproximationMethod(CurveApproximationMethod curveApproximationMethod)
538 {
539 approximationMethod_ = curveApproximationMethod;
540 }
541
ApproximationMethod()542 CurveApproximationMethod ApproximationMethod() const
543 {
544 return approximationMethod_;
545 }
546
SetApproximationScale(float scale)547 void SetApproximationScale(float scale)
548 {
549 curveInc_.ApproximationScale(scale);
550 curveDiv_.ApproximationScale(scale);
551 }
552
ApproximationScale()553 float ApproximationScale() const
554 {
555 return curveInc_.ApproximationScale();
556 }
557
AngleTolerance(float angle)558 void AngleTolerance(float angle)
559 {
560 curveDiv_.AngleTolerance(angle);
561 }
562
AngleTolerance()563 float AngleTolerance() const
564 {
565 return curveDiv_.AngleTolerance();
566 }
567
CuspLimit(float angleValue)568 void CuspLimit(float angleValue)
569 {
570 curveDiv_.CuspLimit(angleValue);
571 }
572
CuspLimit()573 float CuspLimit() const
574 {
575 return curveDiv_.CuspLimit();
576 }
577
Rewind(uint32_t pathId)578 void Rewind(uint32_t pathId)
579 {
580 if (approximationMethod_ == CURVEINCREMENT) {
581 curveInc_.Rewind(pathId);
582 } else {
583 curveDiv_.Rewind(pathId);
584 }
585 }
586
GenerateVertex(float * x,float * y)587 uint32_t GenerateVertex(float* x, float* y)
588 {
589 if (approximationMethod_ == CURVEINCREMENT) {
590 return curveInc_.GenerateVertex(x, y);
591 }
592 return curveDiv_.GenerateVertex(x, y);
593 }
594
595 private:
596 QuadBezierCurveIncr curveInc_;
597 QuadrBezierCurveDividOp curveDiv_;
598 CurveApproximationMethod approximationMethod_;
599 };
600
601 /**
602 * @brief Cubic Bezier curve
603 *
604 * Draw a curve according to the start point, control point and end point.
605 *
606 * @see CubicBezierCurve
607 * @since 1.0
608 * @version 1.0.
609 */
610 class CubicBezierCurve {
611 public:
CubicBezierCurve()612 CubicBezierCurve()
613 : approximationMethod_(CURVEDIVIDOPERATE) {}
614
CubicBezierCurve(float x1,float y1,float x2,float y2,float x3,float y3,float x4,float y4)615 CubicBezierCurve(float x1, float y1,
616 float x2, float y2,
617 float x3, float y3,
618 float x4, float y4)
619 : approximationMethod_(CURVEDIVIDOPERATE)
620 {
621 Init(x1, y1, x2, y2, x3, y3, x4, y4);
622 }
623
CubicBezierCurve(const CubicBezierCurvePoints & curve4Points)624 CubicBezierCurve(const CubicBezierCurvePoints& curve4Points)
625 : approximationMethod_(CURVEDIVIDOPERATE)
626 {
627 Init(curve4Points[0], curve4Points[1], curve4Points[2], curve4Points[3],
628 curve4Points[4], curve4Points[5], curve4Points[6], curve4Points[7]);
629 }
630
Init(float x1,float y1,float x2,float y2,float x3,float y3,float x4,float y4)631 void Init(float x1, float y1,
632 float x2, float y2,
633 float x3, float y3,
634 float x4, float y4)
635 {
636 if (approximationMethod_ == CURVEINCREMENT) {
637 curveInc_.Init(x1, y1, x2, y2, x3, y3, x4, y4);
638 } else {
639 curveDiv_.Init(x1, y1, x2, y2, x3, y3, x4, y4);
640 }
641 }
642
Init(const CubicBezierCurvePoints & curve4Points)643 void Init(const CubicBezierCurvePoints& curve4Points)
644 {
645 Init(curve4Points[0], curve4Points[1], curve4Points[2], curve4Points[3],
646 curve4Points[4], curve4Points[5], curve4Points[6], curve4Points[7]);
647 }
648
Reset()649 void Reset()
650 {
651 curveInc_.Reset();
652 curveDiv_.Reset();
653 }
654
ApproximationMethod(CurveApproximationMethod curveApproximationMethod)655 void ApproximationMethod(CurveApproximationMethod curveApproximationMethod)
656 {
657 approximationMethod_ = curveApproximationMethod;
658 }
659
ApproximationMethod()660 CurveApproximationMethod ApproximationMethod() const
661 {
662 return approximationMethod_;
663 }
664
SetApproximationScale(float scale)665 void SetApproximationScale(float scale)
666 {
667 curveInc_.ApproximationScale(scale);
668 curveDiv_.ApproximationScale(scale);
669 }
ApproximationScale()670 float ApproximationScale() const
671 {
672 return curveInc_.ApproximationScale();
673 }
674
AngleTolerance(float angleValue)675 void AngleTolerance(float angleValue)
676 {
677 curveDiv_.AngleTolerance(angleValue);
678 }
679
AngleTolerance()680 float AngleTolerance() const
681 {
682 return curveDiv_.AngleTolerance();
683 }
684
CuspLimit(float angleValue)685 void CuspLimit(float angleValue)
686 {
687 curveDiv_.CuspLimit(angleValue);
688 }
689
CuspLimit()690 float CuspLimit() const
691 {
692 return curveDiv_.CuspLimit();
693 }
694
Rewind(uint32_t pathId)695 void Rewind(uint32_t pathId)
696 {
697 if (approximationMethod_ == CURVEINCREMENT) {
698 curveInc_.Rewind(pathId);
699 } else {
700 curveDiv_.Rewind(pathId);
701 }
702 }
703
GenerateVertex(float * x,float * y)704 uint32_t GenerateVertex(float* x, float* y)
705 {
706 if (approximationMethod_ == CURVEINCREMENT) {
707 return curveInc_.GenerateVertex(x, y);
708 }
709 return curveDiv_.GenerateVertex(x, y);
710 }
711
712 private:
713 CubicBezierCurveIncrement curveInc_;
714 CubicBezierCurveDividOperate curveDiv_;
715 CurveApproximationMethod approximationMethod_;
716 };
717 } // namespace OHOS
718 #endif
719