All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.codingame.gameengine.module.entities.Shape Maven / Gradle / Ivy

Go to download

Entity Manager module for the CodinGame engine toolkit. Simplify the management of shapes and drawings.

There is a newer version: 4.5.0
Show newest version
package com.codingame.gameengine.module.entities;

/**
 * A Shape represents a graphical entity with a fill and a line, both of which have an alpha and color. You may also set the line's
 * width in world units.
 * 
 * @param 
 *            a subclass inheriting Entity, used in order to return this as a T instead of a Shape.
 */
public abstract class Shape> extends BlendableEntity implements Mask {

    private int lineColor = 0x0, fillColor = 0xffffff;
    private double fillAlpha = 1, lineAlpha = 1, lineWidth = 0;

    Shape() {
        super();
    }

    /**
     * Sets the color of the fill of this Shape as an RGB integer. If the fill should not be drawn, use setFillAlpha(0).
     * 

* Default is 0xFFFFFF (white). *

* * @param color * the color of the fill of this Shape. * @return this Shape. * @exception IllegalArgumentException * if color isn't a valid RGB integer */ public T setFillColor(int color) { return setFillColor(color, null); } /** * Sets the color of the fill of this Shape as an RGB integer. If the fill should not be drawn, use setFillAlpha(0). *

* Default is 0xFFFFFF (white). *

* * @param color * the color of the fill of this Shape. * @param curve * the transition to animate between values of this property. * @return this Shape. * @exception IllegalArgumentException * if color isn't a valid RGB integer */ public T setFillColor(int color, Curve curve) { requireValidColor(color); this.fillColor = color; set("fillColor", color, curve); return self(); } /** * Returns the color of the fill of this Shape as an RGB integer. *

* Default is 0xFFFFFF (white). *

* * @return the color of the fill of this Shape. */ public Integer getFillColor() { return fillColor; } /** * Sets the alpha of the fill of this Shape as a percentage. *

* Default is 1. *

* * @param alpha * the alpha of the fill of this Shape. * @return this Shape. * @exception IllegalArgumentException * if alpha < 0 or alpha > 1 */ public T setFillAlpha(double alpha) { return setFillAlpha(alpha, null); } /** * Sets the alpha of the fill of this Shape as a percentage. *

* Default is 1. *

* * @param alpha * the alpha of the fill of this Shape. * @param curve * the transition to animate between values of this property. * @return this Shape. * @exception IllegalArgumentException * if alpha < 0 or alpha > 1 */ public T setFillAlpha(double alpha, Curve curve) { requireValidAlpha(alpha); this.fillAlpha = alpha; set("fillAlpha", alpha, curve); return self(); } /** * Returns the alpha of the fill of this Shape as a percentage. *

* Default is 1. * * @return the alpha of the fill of this Shape. */ public double getFillAlpha() { return fillAlpha; } /** * Sets the alpha of the border of this Shape as a percentage. *

* Default is 1. *

* * @param alpha * the alpha for the border of this Shape. * @return this Shape. * @exception IllegalArgumentException * if alpha < 0 or alpha > 1 */ public T setLineAlpha(double alpha) { return setLineAlpha(alpha, null); } /** * Sets the alpha of the border of this Shape as a percentage. *

* Default is 1. *

* * @param alpha * the alpha for the border of this Shape. * @param curve * the transition to animate between values of this property. * @return this Shape. * @exception IllegalArgumentException * if alpha < 0 or alpha > 1 */ public T setLineAlpha(double alpha, Curve curve) { requireValidAlpha(alpha); this.lineAlpha = alpha; set("lineAlpha", alpha, curve); return self(); } /** * Returns the alpha of the border of this Shape as a percentage. *

* Default is 1. * * @return the alpha for the border of this Shape. */ public double getLineAlpha() { return lineAlpha; } /** * Sets the width of the border of this Shape in world units. *

* Default is 0. *

* * @param lineWidth * the width for the border of this Shape. * @return this Shape. */ public T setLineWidth(double lineWidth) { return setLineWidth(lineWidth, null); } /** * Sets the width of the border of this Shape in world units. *

* Default is 0. *

* * @param lineWidth * the width for the border of this Shape. * @param curve * the transition to animate between values of this property. * @return this Shape. */ public T setLineWidth(double lineWidth, Curve curve) { this.lineWidth = lineWidth; set("lineWidth", lineWidth, curve); return self(); } /** * Returns the width of the border of this Shape in world units. *

* Default is 0. * * @return the width of the border of this Shape. */ public double getLineWidth() { return lineWidth; } /** * Sets the color of the border of this Shape as an RGB integer. *

* Default is 0xFFFFFF (white). *

* * @param lineColor * the color for the border of this Shape. * @return this Shape. * @exception IllegalArgumentException * if lineColor isn't a valid RGB integer */ public T setLineColor(int lineColor) { return setLineColor(lineColor, null); } /** * Sets the color of the border of this Shape as an RGB integer. *

* Default is 0xFFFFFF (white). *

* * @param lineColor * the color for the border of this Shape. * @param curve * the transition to animate between values of this property. * @return this Shape. * @exception IllegalArgumentException * if lineColor isn't a valid RGB integer */ public T setLineColor(int lineColor, Curve curve) { requireValidColor(lineColor); this.lineColor = lineColor; set("lineColor", lineColor, curve); return self(); } /** * Returns the color of the border of this Shape as an RGB integer. *

* Default is 0xFFFFFF (white). * * @return the color of the border of this Shape. */ public int getLineColor() { return lineColor; } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy