/* --------------------------------------------------------- *
* __________ D E L T A S C R I P T *
* (_________() *
* / === / - A fast, dynamic scripting language *
* | == | - Version 4.13.11.0 *
* / === / - Developed by Adam R. Nelson *
* | = = | - 2011-2013 *
* / === / - Distributed under GNU LGPL v3 *
* (________() - http://github.com/ar-nelson/deltascript *
* *
* --------------------------------------------------------- */
package com.sector91.delta.script.objects.geom;
import com.sector91.delta.script.annotations.DSDynamicField;
import com.sector91.delta.script.annotations.DSInaccessible;
import com.sector91.delta.script.annotations.DSName;
import com.sector91.delta.script.annotations.DSType;
import com.sector91.delta.script.objects.DS_Object;
import com.sector91.delta.script.objects.DS_Vector;
import com.sector91.delta.script.objects.reflect.DS_JavaClass;
import com.sector91.geom.Vector;
@DSType("QuadCurve")
public class DS_QuadCurve extends DS_AbstractCurve2D
{
public static final String TYPE_NAME = "QuadCurve";
private static final DS_JavaClass DSCLASS = DS_JavaClass.fromClass(
DS_QuadCurve.class);
private final float x1, y1, xc, yc, x2, y2;
@DSInaccessible
public DS_QuadCurve(DeltaScriptGeometry geom, float x1, float y1, float xc,
float yc, float x2, float y2)
{
super(geom);
this.x1 = x1;
this.y1 = y1;
this.xc = xc;
this.yc = yc;
this.x2 = x2;
this.y2 = y2;
}
@DSName("transform")
public DS_Curve2D transform(Vector matrix)
{
final Vector start = geom.vec(x1, y1).transform(matrix);
final Vector ctrl = geom.vec(xc, yc).transform(matrix);
final Vector end = geom.vec(x2, y2).transform(matrix);
return geom.quadCurve(start, ctrl, end);
}
@DSName({"boundingBox", "bbox"}) @DSDynamicField
@Override public DS_Rect boundingBox()
{return geom.boundingRect(start(), controlPoint(), end());}
@DSName("curveComplexity") @DSDynamicField
public final int curveComplexity()
{return 2;}
@DSName("start") @DSDynamicField
@Override public DS_Vector start()
{return geom.vec(x1, y1);}
@DSName("end") @DSDynamicField
@Override public DS_Vector end()
{return geom.vec(x2, y2);}
@DSName("controlPoint") @DSDynamicField
public DS_Vector controlPoint()
{return geom.vec(xc, yc);}
@DSName("controlPoints") @DSDynamicField
@Override public DS_Vector[] controlPoints()
{return new DS_Vector[] {controlPoint()};}
@DSName("curves") @DSDynamicField
@Override public DS_QuadCurve[] curves()
{return new DS_QuadCurve[] {this};}
public boolean equals(DS_Object other)
{
if (other == this) return true;
if (other == null) return false;
if (other.getClass() == getClass())
{
final DS_QuadCurve curve = (DS_QuadCurve)other;
return start().equals(curve.start()) &&
controlPoint().equals(curve.controlPoint()) &&
end().equals(curve.end());
}
return false;
}
public String getTypeName()
{return TYPE_NAME;}
@Override protected DS_JavaClass getDeltaScriptClass()
{return DSCLASS;}
}