Class Circle

java.lang.Object
frc.spectrumLib.sim.Circle

public class Circle extends Object
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 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 circle
      diameterInches - diameter of the circle in inches
      name - label prefix for Mechanism2d element names
      root - the Mechanism2d root the circle is attached to
      mech - 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 canvas
      backgroundLines - number of evenly-spaced radial lines used to approximate the circle
      diameterInches - diameter of the circle in inches
      name - label prefix for Mechanism2d element names
      root - the Mechanism2d root the circle is attached to
      color - 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

      public void setBackgroundColor(Color8Bit color)
      Sets all background radial lines to the same color.
      Parameters:
      color - the color to apply to every background line
    • setHalfBackground

      public void setHalfBackground(Color8Bit color8Bit, Color8Bit color8Bit2)
      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 lines
      color8Bit2 - color applied to odd-indexed background lines
    • getCircleBackground

      public MechanismLigament2d[] 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

      public void setColor(Color8Bit color)
      Color applied to all background lines when the circle is drawn.
    • setName

      public void setName(String name)
      Label prefix used when naming Mechanism2d elements.