package net.tlahmann.gdg.creation.object;

import net.tlahmann.gdg.creation.Patterizer;
import processing.core.PApplet;
import processing.core.PVector;

public class PShape {
	private Patterizer parent;
	private PVector[] points;
	private PVector center;

	public PShape(Patterizer p, float[] pos, float radius, float rotation, float ends) {
		parent = p;

		center = new PVector(pos[0], pos[1], 0);
		points = new PVector[(int) Math.ceil(ends)];
		for (int i = 0; i < ends; i++) {
			float d = PApplet.map(i, 0, ends, 0, PApplet.TWO_PI) - PApplet.HALF_PI;
			points[i] = new PVector(center.x + PApplet.cos(d + rotation) * radius,
					center.y + PApplet.sin(d + rotation) * radius);
		}
	}

	public void display() {
		parent.stroke(parent.gui.colors[0]);
		parent.strokeWeight(parent.gui.thickness.y);
		if (!parent.gui.outline) {
			parent.strokeCap(PApplet.SQUARE);
			for (int i = 0; i < points.length; i++) {
				parent.line(center.x, center.y, points[i].x, points[i].y);
			}
		} else {
			parent.strokeCap(PApplet.ROUND);
			int i;
			for (i = 0; i < points.length - 1; i++) {
				parent.line(points[i].x, points[i].y, points[i + 1].x, points[i + 1].y);
			}
			parent.line(points[i].x, points[i].y, points[0].x, points[0].y);
		}
	}
}

@@ -150,110 +150,870 @@
 r;%0A%0A
-public class PShape %7B%0A%09private Patterizer parent;%0A%09private PVector%5B%5D points;%0A%09private PVector center;%0A
+/**%0A * %3Ch1%3EPShape%3C/h1%3E%0A * %3Cp%3E%0A * The %3Cb%3EPShape%3C/b%3E class represents an elements. Element parameters can be%0A * modified within the %3Cb%3Egui%3C/b%3E class.%0A * %3C/p%3E%0A * %0A * @author Tobias Lahmann%0A * @version 1.0%0A * @since 2016-10-05%0A * %0A * @see net.tlahmann.gdg.creation.Gui%0A */%0Apublic class PShape %7B%0A%09/*%0A%09 * private variables not to be modified%0A%09 */%0A%09private Patterizer parent;%0A%09private PVector%5B%5D points;%0A%09private PVector center;%0A%0A%09/**%0A%09 * %3Cp%3E%0A%09 * Constructor used to create one PShape of a specific form and position.%0A%09 * %3C/p%3E%0A%09 * %0A%09 * @since 2016-10-05%0A%09 * %0A%09 * @param p the parent element of type Patterizer. Used to hold the instance%0A%09 *            to be drawn on%0A%09 * @param pos the position of the center point%0A%09 * @param radius the expansion of the PShape%0A%09 * @param rotation used to rotate around the center%0A%09 * @param ends number of end points in this PShape%0A%09 */
 %0A%09pu
@@ -1445,16 +1445,215 @@
 %09%09%7D%0A%09%7D%0A%0A
+%09/**%0A%09 * %3Cp%3E%0A%09 * The display method is used to draw the PShape onto a canvas provided by%0A%09 * its parent. The parent needs to extend the %3Cb%3EPApplet%3C/b%3E class.%0A%09 * %3C/p%3E%0A%09 * %0A%09 * @since 2016-10-05%0A%09 */%0A
 %09public 

Write javadoc comments