Created
August 10, 2022 00:39
-
-
Save cr4yz/c711fd84ba51d29359589868d190ac0d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Sandbox; | |
using Sandbox.UI; | |
internal class RadialFill : Panel | |
{ | |
public float BorderWidth { get; set; } = 20; | |
public float EdgeGap { get; set; } = 2; | |
public int Points { get; set; } = 64; | |
public float FillStart { get; set; } = .5f; | |
public float FillAmount { get; set; } = 0.37f; | |
public Color TrackColor { get; set; } = Color.White; | |
public Color FillColor { get; set; } = Color.Blue; | |
public override void DrawBackground( ref RenderState state ) | |
{ | |
base.DrawBackground( ref state ); | |
var center = Box.Rect.Center; | |
var radius = Box.Rect.width * .5f; | |
var draw = Render.Draw2D; | |
draw.Color = TrackColor; | |
draw.CircleEx( center, radius, radius - BorderWidth, Points ); | |
draw.Color = FillColor; | |
draw.CircleEx( center, radius - EdgeGap, radius - BorderWidth + EdgeGap, Points, FillStart * 360, ( FillStart + FillAmount ) * 360 ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment