com.codingame.gameengine.module.entities.RoundedRectangle Maven / Gradle / Ivy
package com.codingame.gameengine.module.entities;
/**
* A RoundedRectangle specifies an area in a the world
enclosed by the Rectangle's upper-left point (x,y), its width, and its height.
*
* The rectangle on screen will have rounded corners
*
* The coordinates, width and height are in world units.
*/
public class RoundedRectangle extends Shape {
private int width = 100;
private int height = 100;
private int radius = 20;
RoundedRectangle() {
super();
}
/**
* Sets the width of this RoundedRectangle
in world units.
*
* @param width
* the width for this RoundedRectangle
.
* @return this RoundedRectangle
*/
public RoundedRectangle setWidth(int width) {
return setWidth(width, null);
}
/**
* Sets the width of this RoundedRectangle
in world units.
*
* @param width
* the width for this RoundedRectangle
.
* @param curve
* the transition to animate between values of this property.
* @return this RoundedRectangle
*/
public RoundedRectangle setWidth(int width, Curve curve) {
this.width = width;
set("width", width, curve);
return this;
}
/**
* Returns the width of this RoundedRectangle
in world units.
*
* Default is 100.
*
* @return the width of this RoundedRectangle
.
*/
public int getWidth() {
return width;
}
/**
* Sets the height of this RoundedRectangle
in world units.
*
* @param height
* the height for this RoundedRectangle
.
* @return this RoundedRectangle
*/
public RoundedRectangle setHeight(int height) {
return setHeight(height, null);
}
/**
* Sets the height of this RoundedRectangle
in world units.
*
* @param height
* the height for this RoundedRectangle
.
* @param curve
* the transition to animate between values of this property.
* @return this RoundedRectangle
*/
public RoundedRectangle setHeight(int height, Curve curve) {
this.height = height;
set("height", height, curve);
return this;
}
/**
* Returns the height of this RoundedRectangle
in world units.
*
* Default is 100.
*
* @return the height of this RoundedRectangle
.
*/
public int getHeight() {
return height;
}
/**
* Sets the radius of this RoundedRectangle
's corners in world units.
*
* @param radius
* the radius for the corners of this RoundedRectangle
.
* @param curve
* the transition to animate between values of this property.
* @return this RoundedRectangle
*/
public RoundedRectangle setRadius(int radius, Curve curve) {
this.radius = radius;
set("radius", radius, curve);
return this;
}
/**
* Sets the radius of this RoundedRectangle
's corners in world units.
*
* @param radius
* the radius for the corners of this RoundedRectangle
.
* @return this RoundedRectangle
*/
public RoundedRectangle setRadius(int radius) {
return setRadius(radius,null);
}
/**
* Returns the radius of this RoundedRectangle
's corners in world units.
*
* Default is 20.
*
*
* @return the radius of the corners of this RoundedRectangle
.
*/
public int getRadius() {
return radius;
}
@Override
Entity.Type getType() {
return Entity.Type.ROUNDED_RECTANGLE;
}
}