@@ -15,6 +15,8 @@ namespace FreeFrame.Components.Shapes.Path
1515 /// </summary>
1616 public abstract class DrawAttribute
1717 {
18+ public const int CURVE_ACCURACY = 100 ;
19+
1820 int _x , _y , _x1 , _y1 = 0 ;
1921
2022 private bool _isRelative ;
@@ -135,7 +137,7 @@ public override float[] GetVertices()
135137
136138 return vertices ;
137139 }
138- public override uint [ ] GetVerticesIndexes ( ) => new uint [ ] { 0 , 1 } ; // TODO: Please dont hardcode this
140+ public override uint [ ] GetVerticesIndexes ( ) => new uint [ ] { 0 , 1 } ;
139141
140142 public override string ToString ( ) => String . Format ( "{0} {1},{2}" , IsRelative ? 'l' : 'L' , X , Y ) ;
141143
@@ -214,7 +216,7 @@ public override float[] GetVertices()
214216 return vertices ;
215217 }
216218
217- public override uint [ ] GetVerticesIndexes ( ) => new uint [ ] { 0 , 1 } ; // TODO: Please dont hardcode this
219+ public override uint [ ] GetVerticesIndexes ( ) => new uint [ ] { 0 , 1 } ;
218220
219221 public override string ToString ( ) => String . Format ( "{0} {1}" , IsRelative ? 'h' : 'H' , X ) ;
220222
@@ -285,7 +287,7 @@ public override float[] GetVertices()
285287
286288 return vertices ;
287289 }
288- public override uint [ ] GetVerticesIndexes ( ) => new uint [ ] { 0 , 1 } ; // TODO: Please dont hardcode this
290+ public override uint [ ] GetVerticesIndexes ( ) => new uint [ ] { 0 , 1 } ;
289291
290292 public override List < Vector2i > GetSelectablePoints ( )
291293 {
@@ -378,9 +380,9 @@ public override float[] GetVertices()
378380 // Only edges
379381 if ( IsRelative )
380382 {
381- for ( int i = 0 ; i < 100 ; i ++ ) // TODO: Magic value please dont hard code this
383+ for ( int i = 0 ; i < CURVE_ACCURACY ; i ++ )
382384 {
383- t = i / 100.0f ;
385+ t = i / CURVE_ACCURACY ;
384386
385387 x = ( float ) ( Math . Pow ( ( 1 - t ) , 3 ) * Last . X + 3 * Math . Pow ( ( 1 - t ) , 2 ) * t * ( Last . X + X1 ) + 3 * ( 1 - t ) * Math . Pow ( t , 2 ) * ( Last . X + X2 ) + Math . Pow ( t , 3 ) * ( Last . X + X ) ) ;
386388 y = ( float ) ( Math . Pow ( ( 1 - t ) , 3 ) * Last . Y + 3 * Math . Pow ( ( 1 - t ) , 2 ) * t * ( Last . Y + Y1 ) + 3 * ( 1 - t ) * Math . Pow ( t , 2 ) * ( Last . Y + Y2 ) + Math . Pow ( t , 3 ) * ( Last . Y + Y ) ) ;
@@ -390,9 +392,9 @@ public override float[] GetVertices()
390392 }
391393 else
392394 {
393- for ( int i = 0 ; i < 100 ; i ++ ) // TODO: Magic value please dont hard code this
395+ for ( int i = 0 ; i < CURVE_ACCURACY ; i ++ )
394396 {
395- t = i / 100.0f ;
397+ t = i / CURVE_ACCURACY ;
396398
397399 x = ( float ) ( Math . Pow ( ( 1 - t ) , 3 ) * Last . X + 3 * Math . Pow ( ( 1 - t ) , 2 ) * t * X1 + 3 * ( 1 - t ) * Math . Pow ( t , 2 ) * X2 + Math . Pow ( t , 3 ) * X ) ;
398400 y = ( float ) ( Math . Pow ( ( 1 - t ) , 3 ) * Last . Y + 3 * Math . Pow ( ( 1 - t ) , 2 ) * t * Y1 + 3 * ( 1 - t ) * Math . Pow ( t , 2 ) * Y2 + Math . Pow ( t , 3 ) * Y ) ;
@@ -530,9 +532,9 @@ public override float[] GetVertices()
530532 // Only edges
531533 if ( IsRelative )
532534 {
533- for ( int i = 0 ; i < 100 ; i ++ ) // TODO: Magic value please dont hard code this
535+ for ( int i = 0 ; i < CURVE_ACCURACY ; i ++ )
534536 {
535- t = i / 100.0f ;
537+ t = i / CURVE_ACCURACY ;
536538
537539 x = ( float ) ( Math . Pow ( ( 1 - t ) , 3 ) * Last . X + 3 * Math . Pow ( ( 1 - t ) , 2 ) * t * ( Last . X + Last . X1 ) + 3 * ( 1 - t ) * Math . Pow ( t , 2 ) * ( Last . X + X2 ) + Math . Pow ( t , 3 ) * ( Last . X + X ) ) ;
538540 y = ( float ) ( Math . Pow ( ( 1 - t ) , 3 ) * Last . Y + 3 * Math . Pow ( ( 1 - t ) , 2 ) * t * ( Last . Y + Last . Y1 ) + 3 * ( 1 - t ) * Math . Pow ( t , 2 ) * ( Last . Y + Y2 ) + Math . Pow ( t , 3 ) * ( Last . Y + Y ) ) ;
@@ -542,9 +544,9 @@ public override float[] GetVertices()
542544 }
543545 else
544546 {
545- for ( int i = 0 ; i < 100 ; i ++ ) // TODO: Magic value please dont hard code this
547+ for ( int i = 0 ; i < CURVE_ACCURACY ; i ++ )
546548 {
547- t = i / 100.0f ;
549+ t = i / CURVE_ACCURACY ;
548550
549551 x = ( float ) ( Math . Pow ( ( 1 - t ) , 3 ) * Last . X + 3 * Math . Pow ( ( 1 - t ) , 2 ) * t * Last . X1 + 3 * ( 1 - t ) * Math . Pow ( t , 2 ) * X2 + Math . Pow ( t , 3 ) * X ) ;
550552 y = ( float ) ( Math . Pow ( ( 1 - t ) , 3 ) * Last . Y + 3 * Math . Pow ( ( 1 - t ) , 2 ) * t * Last . Y1 + 3 * ( 1 - t ) * Math . Pow ( t , 2 ) * Y2 + Math . Pow ( t , 3 ) * Y ) ;
@@ -672,9 +674,9 @@ public override float[] GetVertices()
672674 // Only edges
673675 if ( IsRelative )
674676 {
675- for ( int i = 0 ; i < 100 ; i ++ ) // TODO: Magic value please dont hard code this
677+ for ( int i = 0 ; i < CURVE_ACCURACY ; i ++ )
676678 {
677- t = i / 100.0f ;
679+ t = i / CURVE_ACCURACY ;
678680
679681 x = ( float ) ( Math . Pow ( ( 1 - t ) , 2 ) * Last . X + 2 * ( 1 - t ) * t * ( Last . X + X1 ) + Math . Pow ( t , 2 ) * ( Last . X + X ) ) ;
680682 y = ( float ) ( Math . Pow ( ( 1 - t ) , 2 ) * Last . Y + 2 * ( 1 - t ) * t * ( Last . Y + Y1 ) + Math . Pow ( t , 2 ) * ( Last . Y + Y ) ) ;
@@ -684,9 +686,9 @@ public override float[] GetVertices()
684686 }
685687 else
686688 {
687- for ( int i = 0 ; i < 100 ; i ++ ) // TODO: Magic value please dont hard code this
689+ for ( int i = 0 ; i < CURVE_ACCURACY ; i ++ )
688690 {
689- t = i / 100.0f ;
691+ t = i / CURVE_ACCURACY ;
690692
691693 x = ( float ) ( Math . Pow ( ( 1 - t ) , 2 ) * Last . X + 2 * ( 1 - t ) * t * X1 + Math . Pow ( t , 2 ) * X ) ;
692694 y = ( float ) ( Math . Pow ( ( 1 - t ) , 2 ) * Last . Y + 2 * ( 1 - t ) * t * Y1 + Math . Pow ( t , 2 ) * Y ) ;
@@ -791,9 +793,9 @@ public override float[] GetVertices()
791793 // Only edges
792794 if ( IsRelative )
793795 {
794- for ( int i = 0 ; i < 100 ; i ++ ) // TODO: Magic value please dont hard code this
796+ for ( int i = 0 ; i < CURVE_ACCURACY ; i ++ )
795797 {
796- t = i / 100.0f ;
798+ t = i / CURVE_ACCURACY ;
797799
798800 x = ( float ) ( Math . Pow ( ( 1 - t ) , 2 ) * Last . X + 2 * ( 1 - t ) * t * ( Last . X + Last . X1 ) + Math . Pow ( t , 2 ) * ( Last . X + X ) ) ;
799801 y = ( float ) ( Math . Pow ( ( 1 - t ) , 2 ) * Last . Y + 2 * ( 1 - t ) * t * ( Last . Y + Last . Y1 ) + Math . Pow ( t , 2 ) * ( Last . Y + Y ) ) ;
@@ -803,9 +805,9 @@ public override float[] GetVertices()
803805 }
804806 else
805807 {
806- for ( int i = 0 ; i < 100 ; i ++ ) // TODO: Magic value please dont hard code this
808+ for ( int i = 0 ; i < CURVE_ACCURACY ; i ++ )
807809 {
808- t = i / 100.0f ;
810+ t = i / CURVE_ACCURACY ;
809811
810812 x = ( float ) ( Math . Pow ( ( 1 - t ) , 2 ) * Last . X + 2 * ( 1 - t ) * t * Last . X1 + Math . Pow ( t , 2 ) * X ) ;
811813 y = ( float ) ( Math . Pow ( ( 1 - t ) , 2 ) * Last . Y + 2 * ( 1 - t ) * t * Last . Y1 + Math . Pow ( t , 2 ) * Y ) ;
0 commit comments