Formatting.

This commit is contained in:
Jeff Young 2024-08-22 13:44:27 -06:00
parent b549c4feec
commit 0ec445e7cb

View File

@ -174,64 +174,65 @@ void STROKE_PARAMS::Stroke( const SHAPE* aShape, LINE_STYLE aLineStyle, int aWid
for( size_t i = 0; i < 10000 && startAngle < arcEndAngle; ++i ) for( size_t i = 0; i < 10000 && startAngle < arcEndAngle; ++i )
{ {
EDA_ANGLE theta = ANGLE_360 * strokes[ i % wrapAround ] / C; EDA_ANGLE theta = ANGLE_360 * strokes[ i % wrapAround ] / C;
EDA_ANGLE endAngle = std::min( startAngle + theta, arcEndAngle ); EDA_ANGLE endAngle = std::min( startAngle + theta, arcEndAngle );
if( i % 2 == 0 ) if( i % 2 == 0 )
{ {
// Calculate the remaining arc length from the current startAngle to the arcEndAngle // Calculate the remaining arc length from the current startAngle to the arcEndAngle
EDA_ANGLE remainingArcLength = arcEndAngle - startAngle; EDA_ANGLE remainingArcLength = arcEndAngle - startAngle;
if( remainingArcLength < theta ) if( remainingArcLength < theta )
{ {
// If the remaining arc length is less than the current segment length (theta), // If the remaining arc length is less than the current segment length (theta),
// we need to adjust the segment length to fit within the remaining arc. // we need to adjust the segment length to fit within the remaining arc.
// Check if the remaining arc length is greater than the gap length (strokes[1]). // Check if the remaining arc length is greater than the gap length (strokes[1]).
// strokes[1] represents the gap between dashes/dots in the pattern. // strokes[1] represents the gap between dashes/dots in the pattern.
if( remainingArcLength > ( ANGLE_360 * strokes[1] / C ) ) if( remainingArcLength > ( ANGLE_360 * strokes[1] / C ) )
{ {
// If the remaining arc length is greater than the gap length, // If the remaining arc length is greater than the gap length,
// adjust the segment length (theta) to leave space for the final gap. // adjust the segment length (theta) to leave space for the final gap.
theta = remainingArcLength - ( ANGLE_360 * strokes[1] / C ); theta = remainingArcLength - ( ANGLE_360 * strokes[1] / C );
// Ensure that the adjusted segment length does not exceed the arcEndAngle. // Ensure that the adjusted segment length does not exceed the arcEndAngle.
endAngle = startAngle + theta; endAngle = startAngle + theta;
} }
else else
{ {
// If the remaining arc length is less than or equal to the gap length, // If the remaining arc length is less than or equal to the gap length,
// simply set the endAngle to the arcEndAngle to complete the arc. // simply set the endAngle to the arcEndAngle to complete the arc.
endAngle = arcEndAngle; endAngle = arcEndAngle;
} }
} }
if( aLineStyle == LINE_STYLE::DASH if( aLineStyle == LINE_STYLE::DASH
|| (( aLineStyle == LINE_STYLE::DASHDOT || aLineStyle == LINE_STYLE::DASHDOTDOT ) && i % wrapAround == 0)) || ( ( aLineStyle == LINE_STYLE::DASHDOT || aLineStyle == LINE_STYLE::DASHDOTDOT )
{ && ( i % wrapAround ) == 0 ) )
for( EDA_ANGLE currentAngle = startAngle; currentAngle < endAngle; {
currentAngle += angleIncrementInRadians ) for( EDA_ANGLE currentAngle = startAngle; currentAngle < endAngle;
{ currentAngle += angleIncrementInRadians )
VECTOR2I a( center.x + KiROUND( r * currentAngle.Cos() ), {
center.y + KiROUND( r * currentAngle.Sin() ) ); VECTOR2I a( center.x + KiROUND( r * currentAngle.Cos() ),
VECTOR2I b( center.x + KiROUND( r * ( currentAngle + angleIncrementInRadians ).Cos() ), center.y + KiROUND( r * currentAngle.Sin() ) );
center.y + KiROUND( r * ( currentAngle + angleIncrementInRadians ).Sin() ) ); VECTOR2I b( center.x + KiROUND( r * ( currentAngle + angleIncrementInRadians ).Cos() ),
center.y + KiROUND( r * ( currentAngle + angleIncrementInRadians ).Sin() ) );
aStroker( a, b ); // Draw the segment as an arc aStroker( a, b ); // Draw the segment as an arc
} }
} }
else else
{ {
VECTOR2I a( center.x + KiROUND( r * startAngle.Cos() ), VECTOR2I a( center.x + KiROUND( r * startAngle.Cos() ),
center.y + KiROUND( r * startAngle.Sin() ) ); center.y + KiROUND( r * startAngle.Sin() ) );
VECTOR2I b( center.x + KiROUND( r * endAngle.Cos() ), VECTOR2I b( center.x + KiROUND( r * endAngle.Cos() ),
center.y + KiROUND( r * endAngle.Sin() ) ); center.y + KiROUND( r * endAngle.Sin() ) );
aStroker( a, b ); aStroker( a, b );
} }
} }
startAngle = endAngle; startAngle = endAngle;
} }
break; break;