/*
 * StartPiece - the starting piece
 *
 * by Adam Doppelt
 * http://www.cs.brown.edu/people/amd/
 */
import java.awt.*;

public class StartPiece extends Piece {
    final static double HALF_CIRCLE = PIPE_WIDTH / 2.0;
    final static double TOTAL_LENGTH = HALF_CIRCLE + 0.5;

    static PieceType type_;

    static public void SetupStatics(Component c, Image image) {
	type_ = new PieceType(c);
	for (int loop = 0; loop < SLICES; ++loop) {
            double x = ((double)loop / (double)DIV_SLICES) * TOTAL_LENGTH;
            double y;
            if (x < HALF_CIRCLE)
                y = Math.sqrt(Math.abs(x * (2 * HALF_CIRCLE - x)));
            else
                y = HALF_CIRCLE;
            type_.x1_[loop] = PercentPixel(NEG_EDGE + x);
            type_.y1_[loop] = PercentPixel(CENTER - y);
            type_.x2_[loop] = PercentPixel(NEG_EDGE + x);
            type_.y2_[loop] = PercentPixel(CENTER + y);

	    type_.visible_[loop] = true;
	}
	type_.red_ = false;
	type_.green_ = false;
	type_.blue_ = true;
	
	type_.legalDirections_ = 0;
	type_.flipDirections_ = 0;
	if (image == null)
	    type_.GenerateImage();
	else
	    type_.stamp_ = image;
    }

    public StartPiece() {
	super(type_);
	contains_ = true;
    }
}
