Package frc.spectrumLib.sim
Class Circle
java.lang.Object
frc.spectrumLib.sim.Circle
Renders a filled circle in a
Mechanism2d canvas using evenly-spaced radial ligaments.
Used by RollerSim to visualise the roller's spin state and color.-
Constructor Summary
ConstructorsConstructorDescriptionCircle(int backgroundLines, double diameterInches, String name, MechanismRoot2d root, Mechanism2d mech) Creates a Circle and immediately draws the radial background lines.Circle(Mechanism2d mech, int backgroundLines, double diameterInches, String name, MechanismRoot2d root, Color8Bit color) Creates a Circle with a specified color and immediately draws the radial background lines. -
Method Summary
Modifier and TypeMethodDescriptionvoidCreates and attaches all radial background ligaments that form the circle, distributing them evenly around 360 degrees.voiddrawViz()Appends a short white indicator line to the roller axle so rotation direction is visible in the Mechanism2d canvas.intNumber of radial lines used to approximate the circle.Array of radial ligaments that together form the circle outline.voidsetBackgroundColor(Color8Bit color) Sets all background radial lines to the same color.voidColor applied to all background lines when the circle is drawn.voidsetHalfBackground(Color8Bit color8Bit, Color8Bit color8Bit2) Alternates two colors across the background lines, giving the circle a two-tone appearance (useful for indicating reverse spin direction).voidLabel prefix used when naming Mechanism2d elements.
-
Constructor Details
-
Circle
public Circle(int backgroundLines, double diameterInches, String name, MechanismRoot2d root, Mechanism2d mech) Creates a Circle and immediately draws the radial background lines.- Parameters:
backgroundLines- number of evenly-spaced radial lines used to approximate the circlediameterInches- diameter of the circle in inchesname- label prefix for Mechanism2d element namesroot- the Mechanism2d root the circle is attached tomech- the parent Mechanism2d canvas
-
Circle
public Circle(Mechanism2d mech, int backgroundLines, double diameterInches, String name, MechanismRoot2d root, Color8Bit color) Creates a Circle with a specified color and immediately draws the radial background lines.- Parameters:
mech- the parent Mechanism2d canvasbackgroundLines- number of evenly-spaced radial lines used to approximate the circlediameterInches- diameter of the circle in inchesname- label prefix for Mechanism2d element namesroot- the Mechanism2d root the circle is attached tocolor- the initial color applied to every background line
-
-
Method Details
-
drawCircle
public void drawCircle()Creates and attaches all radial background ligaments that form the circle, distributing them evenly around 360 degrees. -
drawViz
public void drawViz()Appends a short white indicator line to the roller axle so rotation direction is visible in the Mechanism2d canvas. -
setBackgroundColor
Sets all background radial lines to the same color.- Parameters:
color- the color to apply to every background line
-
setHalfBackground
Alternates two colors across the background lines, giving the circle a two-tone appearance (useful for indicating reverse spin direction).- Parameters:
color8Bit- color applied to even-indexed background linescolor8Bit2- color applied to odd-indexed background lines
-
getCircleBackground
Array of radial ligaments that together form the circle outline. -
getBackgroundLines
public int getBackgroundLines()Number of radial lines used to approximate the circle. -
setColor
Color applied to all background lines when the circle is drawn. -
setName
Label prefix used when naming Mechanism2d elements.
-