@@ -185,38 +185,28 @@ public override void Draw(Vector2 pos, Vector2? parentSize = null, bool parentVi
185185 style . Position = localPos - pos ;
186186 }
187187 }
188-
189- // controls how smooth the arc looks
188+
190189 const int segments = 100 ;
191190 float startAngle = ( float ) ( - Math . PI / 2f + style . StartAngle * ( Math . PI / 180f ) ) ;
192191 float endAngle = ( float ) ( - Math . PI / 2f + style . EndAngle * ( Math . PI / 180f ) ) ;
193192
194- List < CircleData > circles ;
195- circles = new List < CircleData > ( ) { CalculateCircle ( startAngle , endAngle , progressValue , progressMaxValue , style . Direction ) } ;
193+ CircleData circle = CalculateCircle ( startAngle , endAngle , progressValue , progressMaxValue , style . Direction ) ;
196194
197- foreach ( CircleData circle in circles )
198- {
199- // fill
200- ConfigColor fillColor = circle . FillColor ?? style . FillColor ;
195+ ConfigColor fillColor = circle . FillColor ?? style . FillColor ;
201196
202- // Draw background arc first
203- if ( circle . EndAngle != startAngle )
204- {
205- drawList . PathArcTo ( localPos , style . Radius , circle . StartAngle , endAngle , segments ) ;
206- drawList . PathStroke ( ImGui . ColorConvertFloat4ToU32 ( style . BackgroundColor . Vector ) , ImDrawFlags . None , style . Thickness ) ;
207- }
197+ // Draw the background arc
198+ drawList . PathArcTo ( localPos , style . Radius , startAngle , endAngle , segments ) ;
199+ drawList . PathStroke ( ImGui . ColorConvertFloat4ToU32 ( style . BackgroundColor . Vector ) , ImDrawFlags . None , style . Thickness ) ;
208200
209- // Draw fill arc on top
210- drawList . PathArcTo ( localPos , style . Radius , circle . StartAngle , circle . EndAngle , segments ) ;
211- drawList . PathStroke ( ImGui . ColorConvertFloat4ToU32 ( fillColor . Vector ) , ImDrawFlags . None , style . Thickness ) ;
212-
213-
214- if ( style . Glow )
215- {
216- DrawHelpers . DrawGlowCircle ( localPos , style . Radius , style . Thickness , style . GlowPadding , style . GlowSegments , style . GlowSpeed , style . GlowColor , style . GlowColor2 , drawList ) ;
217- }
218-
201+ // Draw the filled arc
202+ drawList . PathArcTo ( localPos , style . Radius , circle . StartAngle , circle . EndAngle , segments ) ;
203+ drawList . PathStroke ( ImGui . ColorConvertFloat4ToU32 ( fillColor . Vector ) , ImDrawFlags . None , style . Thickness ) ;
204+
205+ if ( style . Glow )
206+ {
207+ DrawHelpers . DrawGlowCircle ( localPos , style . Radius , style . Thickness , style . GlowPadding , style . GlowSegments , style . GlowSpeed , style . GlowColor , style . GlowColor2 , drawList ) ;
219208 }
209+
220210 if ( style . ShowBorder )
221211 {
222212 drawList . PathArcTo ( localPos , style . Radius - style . Thickness / 2f , startAngle , endAngle , segments ) ;
@@ -245,6 +235,7 @@ public override void Draw(Vector2 pos, Vector2? parentSize = null, bool parentVi
245235 }
246236 }
247237 }
238+
248239
249240 private CircleData CalculateCircle ( float startAngle , float endAngle , float progress , float max , CircleDirection direction )
250241 {
@@ -253,28 +244,19 @@ private CircleData CalculateCircle(float startAngle, float endAngle, float progr
253244 float fillPercent = max == 0 ? 1f : Math . Clamp ( progress / max , 0f , 1f ) ;
254245 float angleRange = endAngle - startAngle ;
255246
256- if ( direction == CircleDirection . AntiClockwise )
257- {
258- // If anticlockwise, the angle range needs to be reversed
259- angleRange = startAngle - endAngle ;
260- }
261-
262247 float fillAngle = angleRange * fillPercent ;
263248
264- // Adjusting for direction
265- float relativeAngle ;
266249 if ( direction == CircleDirection . Clockwise )
267250 {
268- relativeAngle = startAngle + fillAngle ;
251+ circle . StartAngle = startAngle ;
252+ circle . EndAngle = startAngle + fillAngle ;
269253 }
270- else // Anticlockwise
254+ else
271255 {
272- relativeAngle = startAngle - fillAngle ;
256+ circle . StartAngle = - ( startAngle + ( float ) Math . PI ) ;
257+ circle . EndAngle = - ( startAngle + ( float ) Math . PI ) ;
273258 }
274259
275- circle . StartAngle = startAngle ;
276- circle . EndAngle = relativeAngle ;
277-
278260 return circle ;
279261 }
280262
@@ -323,7 +305,6 @@ internal struct CircleData
323305 {
324306 public float StartAngle ;
325307 public float EndAngle ;
326- public Vector2 FillSize ;
327308
328309 public ConfigColor ? FillColor ;
329310 }
0 commit comments