
// LineShape.java
// Andrew Davison, Jan 2023, ad@coe.psu.ac.th

/* Represents a line. 
   Implements the Shape class by defining drawShape().

   This class corresponds to the LineShape class in the 
   Java SimplePaint application.

*/ 

package com.mygdx.game;


// import java.awt.*;
import com.badlogic.gdx.graphics.*;
import com.badlogic.gdx.math.*;    // Point --> Vector2

import com.badlogic.gdx.graphics.glutils.*;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType;


public class LineShape extends Shape 
{
  private float thickness;


  public LineShape(float x1, float y1, float x2, float y2, 
                   Color col, float thickness) 
  {  
    super(x1, y1, x2, y2, true, col); 
    this.thickness = thickness;
  } // end of LineShape()
  

  public void drawShape(ShapeRenderer sr) 
  // draw a line
  {
    sr.setColor(shapeColor);

    if (thickness == 1f) {
      sr.begin(ShapeType.Line);
      sr.line(startPt, endPt);
    }
    else {
      sr.begin(ShapeType.Filled);
      sr.rectLine(startPt, endPt, thickness);
    }
    sr.end();
  } // end of drawShape()
  
} // end of LineShape class
