|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectnet.paulhertz.aifile.DisplayComponent
net.paulhertz.aifile.BezShape
net.paulhertz.aifile.BezRectangle
public class BezRectangle
Provides factory methods to create and operate on closed rectangular shapes.
In methods that do not include a reference to a PApplet in the signature,
the PApplet used for calls to the Processing environment is obtained from
IgnoCodeLib, which must be correctly initialized in setup.
If IgnoCodeLib does not have a reference to a PApplet, it throws a NullPointerException.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class net.paulhertz.aifile.BezShape |
|---|
BezShape.BezType |
| Field Summary |
|---|
| Fields inherited from class net.paulhertz.aifile.BezShape |
|---|
bezType, CURVE_SEGMENT, KAPPA, LINE_SEGMENT |
| Method Summary | |
|---|---|
boolean |
contains(BezRectangle r)
Determines if this rectangle contains a specified rectangle. |
static boolean |
contains(BezRectangle one,
BezRectangle another)
Determines if one rectangle contains another rectangle |
boolean |
containsPoint(float x,
float y)
|
static boolean |
containsPoint(float x,
float y,
BezRectangle r)
|
float |
getArea()
|
float |
getBottom()
|
Vertex2DINF |
getBottomRight()
|
LineVertex |
getCenterPoint()
|
float[] |
getCoords()
Returns an array of all vertex coordinates. |
double |
getDiagonalLength()
|
float |
getHeight()
|
float |
getLeft()
|
float |
getRight()
|
float |
getTop()
|
LineVertex |
getTopLeft()
|
float |
getWidth()
|
BezRectangle |
inset(float insetWidth,
float insetHeight)
Returns a rectangle inset by the specified values. |
BezRectangle |
intersect(BezRectangle r)
Calculates the intersection of this rectangle with a supplied rectangle, returns the result as a rectangle. |
boolean |
isAligned()
|
boolean |
isNeedsUpdate()
convenience method to allow you to check the need for an update, which you set earlier |
static double |
lerp(double a,
double l,
double h)
Interpolates a value within a range. |
static BezRectangle |
makeCenterWidthHeight(float xctr,
float yctr,
float width,
float height)
|
static BezRectangle |
makeCenterWidthHeight(PApplet parent,
float xctr,
float yctr,
float width,
float height)
|
static BezRectangle |
makeLeftTopRightBottom(float left,
float top,
float right,
float bottom)
|
static BezRectangle |
makeLeftTopRightBottom(PApplet parent,
float left,
float top,
float right,
float bottom)
|
static BezRectangle |
makeLeftTopWidthHeight(float left,
float top,
float width,
float height)
|
static BezRectangle |
makeLeftTopWidthHeight(PApplet parent,
float left,
float top,
float width,
float height)
|
static BezRectangle |
makeRectangle(BezRectangle r)
|
static double |
map(double v,
double vlo,
double vhi,
double dlo,
double dhi)
Maps a value from one range to another. |
Vertex2DINF |
map(Vertex2DINF vt1,
BezRectangle r2)
|
static Vertex2DINF |
map(Vertex2DINF vt1,
BezRectangle r1,
BezRectangle r2)
|
int |
overlapOutcode(BezRectangle lim)
|
static int |
overlapOutcode(BezRectangle targ,
BezRectangle lim)
|
boolean |
overlaps(BezRectangle r)
Determines if this rectangle overlaps a specified rectangle |
static boolean |
overlaps(BezRectangle one,
BezRectangle another)
Determines if one rectangle overlaps another rectangle |
BezRectangle |
pin(BezRectangle r)
Clip the supplied rectangle to this rectangle; both rectangles should be aligned to x and y axes. |
void |
rotateShape(float theta)
Rotates this shape around its center point. |
BezRectangle |
roundCoordinates()
|
void |
scaleShape(float xyScale)
Uniformly scales this shape around its center point. |
void |
scaleShape(float xScale,
float yScale)
Scales this shape around its center point. |
void |
scaleShape(float xyScale,
float x0,
float y0)
Uniformly scales this shape around a given point. |
void |
scaleShape(float xScale,
float yScale,
float x0,
float y0)
Scales this shape around a given point. |
void |
setLeftTopRightBottom(float left,
float top,
float right,
float bottom)
Updates rectangle coordinates, width and height. |
void |
setLeftTopWidthHeight(float left,
float top,
float width,
float height)
Updates rectangle coordinates, width and height. |
void |
setNeedsUpdate(boolean needsUpdate)
convenience method to allow you to flag the need for an update |
BezRectangle |
stick(BezRectangle r)
Stick the nearest edge of this rectangle to limitRect, if it doesn't overlap. |
void |
transform(Matrix3 matx)
Performs an affine geometric transformation on this shape using 3x3 matrix multiplication. |
void |
translateShape(float xTrans,
float yTrans)
Translates this shape. |
void |
update()
Updates local tracking of rectangle top, left, bottom, right, width and height. |
BezRectangle |
wrap(BezRectangle r)
Wrap supplied rectangle in the smallest rectangle that contains it and this rectangle; Both rectangles should be aligned. |
| Methods inherited from class net.paulhertz.aifile.DisplayComponent |
|---|
hide, id, isLocked, isVisible, parentComponent, setLocked, setParentComponent, setVisible, show |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static BezRectangle makeLeftTopWidthHeight(PApplet parent,
float left,
float top,
float width,
float height)
public static BezRectangle makeLeftTopWidthHeight(float left,
float top,
float width,
float height)
public static BezRectangle makeCenterWidthHeight(PApplet parent,
float xctr,
float yctr,
float width,
float height)
public static BezRectangle makeCenterWidthHeight(float xctr,
float yctr,
float width,
float height)
public static BezRectangle makeLeftTopRightBottom(PApplet parent,
float left,
float top,
float right,
float bottom)
public static BezRectangle makeLeftTopRightBottom(float left,
float top,
float right,
float bottom)
public static BezRectangle makeRectangle(BezRectangle r)
public void setLeftTopWidthHeight(float left,
float top,
float width,
float height)
left - top - width - height -
public void setLeftTopRightBottom(float left,
float top,
float right,
float bottom)
left - top - right - bottom - public float[] getCoords()
BezShapeLineVertex adds two values to the array
and a BezVertex adds six values (two control points and an anchor point). There is no
inherent way to distinguish which values represent control points and which represent anchor points.
getCoords in class BezShapefloat generated from the vertices of this shape.BezShape.asPolygon(PApplet, int).public float getLeft()
public float getTop()
public float getRight()
public float getBottom()
public float getWidth()
public float getHeight()
public LineVertex getTopLeft()
public Vertex2DINF getBottomRight()
public LineVertex getCenterPoint()
public float getArea()
public double getDiagonalLength()
public static boolean contains(BezRectangle one,
BezRectangle another)
one - the possibly containing rectangleanother - the rectangle to check for containment
true if one rectangle contains another, false otherwisepublic boolean contains(BezRectangle r)
r - the rectangle to check
true if this rectangle contains r, false otherwise
public static boolean overlaps(BezRectangle one,
BezRectangle another)
one - one rectangle to check for overlapanother - another rectangle to check for overlap
true if one rectangle overlaps another, false otherwisepublic boolean overlaps(BezRectangle r)
r - the rectangle to check against this one
true if this rectangle overlaps r, false otherwisepublic int overlapOutcode(BezRectangle lim)
lim - the limiting rectangle
public static int overlapOutcode(BezRectangle targ,
BezRectangle lim)
targ - rectangle to test against a limiting rectanglelim - the limiting rectangle
public static boolean containsPoint(float x,
float y,
BezRectangle r)
x - x-coordinate of point to testy - y-coordinate of point to testr - rectangle to test
true if r contains the specified point
public boolean containsPoint(float x,
float y)
containsPoint in class BezShapepublic void update()
BezShape.bounds(PApplet) of this BezRectangle
no longer corresponds to the top, left, bottom and right, isAligned will
be set to false to flag that the rectangle has been transformed out of alignment with
the x and y axes of the world system.
Call after any geometric transformation of the points of this rectangle by your code.
Methods in this class that change geometry will call update for you.
public boolean isNeedsUpdate()
public void setNeedsUpdate(boolean needsUpdate)
needsUpdate - the needsUpdate to setpublic boolean isAligned()
public void rotateShape(float theta)
BezShapesetCenter or calculateCenter.
Sets xcoords and ycoords arrays to null: they will have to be recalculated after a transform,
which will be done through lazy initialization when xcoords() or ycoords() are called.
rotateShape in class BezShapetheta - degrees to rotate (in radians)
TODO for theta very near PI, 0, or TWO_PI, insure correct rotation.
public void scaleShape(float xScale,
float yScale)
BezShapesetCenter or calculateCenter.
Sets xcoords and ycoords arrays to null: they will have to be recalculated after a transform,
which will be done through lazy initialization when xcoords() or ycoords() are called.
scaleShape in class BezShapexScale - scaling on x-axisyScale - scaling on y-axispublic void scaleShape(float xyScale)
BezShapesetCenter or calculateCenter.
Sets xcoords and ycoords arrays to null: they will have to be recalculated after a transform,
which will be done through lazy initialization when xcoords() or ycoords() are called.
scaleShape in class BezShapexyScale - uniform scaling on x-axis and y-axis
public void scaleShape(float xScale,
float yScale,
float x0,
float y0)
BezShapexcoords() or ycoords() are called.
scaleShape in class BezShapexScale - scaling on x-axisyScale - scaling on y-axis
public void scaleShape(float xyScale,
float x0,
float y0)
BezShape
scaleShape in class BezShapexyScale - uniform scaling on x-axis and y-axispublic void transform(Matrix3 matx)
BezShapexcoords() or ycoords() are called.
transform in class BezShapematx - a 3x3 matrix see Matrix3 class for methods of loading transforms
public void translateShape(float xTrans,
float yTrans)
BezShapexcoords() or ycoords() are called.
translateShape in class BezShapexTrans - translation on x-axisyTrans - translation on y-axispublic BezRectangle roundCoordinates()
public BezRectangle inset(float insetWidth,
float insetHeight)
insetWidth - insetHeight -
public BezRectangle intersect(BezRectangle r)
isAligned == true.
r -
public BezRectangle pin(BezRectangle r)
r - rectangle to clip
public BezRectangle stick(BezRectangle r)
r - the "sticky" rectangle
public BezRectangle wrap(BezRectangle r)
r -
public static double lerp(double a,
double l,
double h)
public static double map(double v,
double vlo,
double vhi,
double dlo,
double dhi)
v - value to interpolagevlo - low value of source rangevhi - high value of source rangedlo - low value of destination rangedhi - high value of destination range
public Vertex2DINF map(Vertex2DINF vt1,
BezRectangle r2)
vt1 - a LineVertex for mapping from this rectangle to anotherr2 - the destination rectangle
public static Vertex2DINF map(Vertex2DINF vt1,
BezRectangle r1,
BezRectangle r2)
vt1 - a LineVertex for interpolationr1 - a source rectangle for mappingr2 - a destination rectangle for mapping
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||