|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.gicentre.utils.move.Clipper
public class Clipper
Class for limiting drawing to a fixed rectangular area.
Simple usage example:
import org.gicentre.utils.gui.Clipper;
Clipper clipper;
void setup() {
//...
size(600, 400);
clipper = new Clipper(this, 100, 100, 300, 200); // x, y, width, height
//...
}
void draw() {
drawSomeStuffAsUsual();
clipper.startClipping();
drawStuffYouWantToClip();
clipper.stopClipping();
drawSomeOtherStuffAsUsual();
}
Limitations:
| Field Summary | |
|---|---|
protected processing.core.PApplet |
applet
|
protected java.awt.geom.Rectangle2D |
clippingRect
|
protected boolean |
enabled
|
protected processing.core.PGraphicsJava2D |
pGraphics2D
|
| Constructor Summary | |
|---|---|
Clipper(processing.core.PApplet applet)
Creates a new clipper set to the bounds of the given sketch. |
|
Clipper(processing.core.PApplet applet,
float x,
float y,
float width,
float height)
Creates a new Clipper instance capable of limiting all drawing to within the given rectangular bounds. |
|
Clipper(processing.core.PApplet applet,
java.awt.geom.Rectangle2D clippingRect)
Creates a new Clipper instance capable of limiting all drawing to within the given rectangular bounds. |
|
| Method Summary | |
|---|---|
boolean |
contains(float x,
float y)
Reports whether or not the given point lies within the clipping rectangle. |
boolean |
contains(processing.core.PVector p)
Reports whether or not the given point lies within the clipping rectangle. |
java.awt.geom.Rectangle2D |
getClippingRect()
Reports the clipping rectangle, whether or not is is currently active. |
boolean |
isClipping()
Reports whether or not clipping mode is currently active. |
boolean |
isEnabled()
Reports whether or not clipping is enabled. |
void |
setClippingRect(float x,
float y,
float width,
float height)
Sets the clipping rectangle and applies it if currently clipping |
void |
setClippingRect(java.awt.geom.Rectangle2D clippingRect)
Sets the clipping rectangle and applies it if currently clipping |
void |
setEnabled(boolean enabled)
Determines whether or not clipping is enabled. |
void |
startClipping()
Starts clipping all drawn content to the screen bounds of the current clip area. |
void |
stopClipping()
Stops any active clipping. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected processing.core.PApplet applet
protected processing.core.PGraphicsJava2D pGraphics2D
protected java.awt.geom.Rectangle2D clippingRect
protected boolean enabled
| Constructor Detail |
|---|
public Clipper(processing.core.PApplet applet)
applet - Sketch in which to enable clipping.
public Clipper(processing.core.PApplet applet,
float x,
float y,
float width,
float height)
applet - Sketch in which to enable clipping.x - x coordinate of the top-left of the clipping rectangle.y - y coordinate of the top-left of the clipping rectangle.width - Width of the clipping rectangle.height - Height of the clipping rectangle.startClipping(),
stopClipping(),
setEnabled(boolean)
public Clipper(processing.core.PApplet applet,
java.awt.geom.Rectangle2D clippingRect)
applet - Sketch in which to enable clipping.clippingRect - Bounds of the rectangle within which clipping is to be applied.startClipping(),
stopClipping(),
setEnabled(boolean)| Method Detail |
|---|
public void startClipping()
public void stopClipping()
public void setClippingRect(float x,
float y,
float width,
float height)
x - x coordinate of the top-left of the clipping rectangle.y - y coordinate of the top-left of the clipping rectangle.width - Width of the clipping rectangle.height - Height of the clipping rectangle.public void setClippingRect(java.awt.geom.Rectangle2D clippingRect)
clippingRect - The clipping rectangle to apply.public java.awt.geom.Rectangle2D getClippingRect()
public boolean contains(float x,
float y)
x - x coordinate of the point to test.y - y coordinate of the point to test.
public boolean contains(processing.core.PVector p)
p - Point to test.
public boolean isClipping()
startClipping() and stopClipping() method calls.
isEnabled()public boolean isEnabled()
isClipping(), this returns true even before
startClipping() and after stopClipping().
isClipping(),
setEnabled(boolean)public void setEnabled(boolean enabled)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||