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

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

   This class corresponds to the RectangleShape 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 RectangleShape extends Shape 
{
  public RectangleShape(float x1, float y1, float x2, float y2,
	                        boolean isFilled, Color color) 
  {  super(x1, y1, x2, y2, isFilled, color);  }
  

  public void drawShape(ShapeRenderer sr) 
  // draw a rectangle
  {
    sr.setColor(shapeColor);
    float width = endPt.x - startPt.x;
    float height = endPt.y - startPt.y;

    if (!isFilled) {
      sr.begin(ShapeType.Line);
      sr.rect(startPt.x, startPt.y, width, height);
    }
    else {
      sr.begin(ShapeType.Filled);
      sr.rect(startPt.x, startPt.y, width, height);
    }
    sr.end();
  } // end of drawShape()
  
} // end of RectangleShape class
