|
PulpCore | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object pulpcore.sprite.Sprite pulpcore.sprite.ImageSprite pulpcore.sprite.StretchableSprite
public class StretchableSprite
Stretchable sprites are sprites that, when scaled, draw the "static" sections normally and scale the "stretchable" sections. Typically, corners are drawn normally while the inside is scaled. The format used is identical to Android's nine-patch format.
Example:
import pulpcore.image.Colors; import pulpcore.scene.Scene2D; import pulpcore.sprite.FilledSprite; import pulpcore.sprite.StretchableSprite; public class StretchableSpriteTest extends Scene2D { public void load() { add(new FilledSprite(Colors.BLUE)); add(new StretchableSprite("button.9.png", 5, 5, 200, 200)); } }
Field Summary |
---|
Fields inherited from class pulpcore.sprite.ImageSprite |
---|
antiAlias |
Fields inherited from class pulpcore.sprite.Sprite |
---|
alpha, anchorX, anchorY, angle, CENTER, DEFAULT, EAST, enabled, height, NORTH, NORTH_EAST, NORTH_WEST, pixelSnapping, SOUTH, SOUTH_EAST, SOUTH_WEST, visible, WEST, width, x, y |
Constructor Summary | |
---|---|
StretchableSprite(CoreImage image,
double x,
double y)
Creates a StretchableSprite from an image with defined stretchable sections. |
|
StretchableSprite(CoreImage image,
double x,
double y,
double w,
double h)
Creates a StretchableSprite from an image with defined stretchable sections. |
|
StretchableSprite(CoreImage image,
int capWidth,
int capHeight,
double x,
double y,
double w,
double h)
Creates a StretchableSprite with the specified cap size. |
|
StretchableSprite(String imageName,
double x,
double y)
Creates a StretchableSprite from an image with defined stretchable sections. |
|
StretchableSprite(String imageName,
double x,
double y,
double w,
double h)
Creates a StretchableSprite from an image with defined stretchable sections. |
|
StretchableSprite(String imageName,
int capWidth,
int capHeight,
double x,
double y,
double w,
double h)
Creates a StretchableSprite with the specified cap size. |
Method Summary | |
---|---|
protected void |
drawSprite(CoreGraphics g)
Draws the sprite. |
protected int |
getNaturalHeight()
Gets the fixed-point value of the Sprite's natural height. |
protected int |
getNaturalWidth()
Gets the fixed-point value of the Sprite's natural width. |
int |
getPaddingBottom()
|
int |
getPaddingLeft()
|
int |
getPaddingRight()
|
int |
getPaddingTop()
|
protected boolean |
isTransparent(int localX,
int localY)
Checks if the pixel at the specified integer location is transparent. |
CoreImage |
render()
Creates a rendered version of this StretchableSprite at the current dimensions. |
CoreImage |
render(int width,
int height)
Creates a rendered version of this StretchableSprite with the specified dimensions. |
void |
setAnchorToHotSpot()
Sets the anchor to the underlying image's hotspot. |
void |
setImage(CoreImage image)
Sets this ImageSprite's internal image. |
Methods inherited from class pulpcore.sprite.ImageSprite |
---|
getImage, getPixelLevelChecks, isOpaque, propertyChange, setAnchor, setImage, setPixelLevelChecks, update |
Methods inherited from class pulpcore.sprite.Sprite |
---|
bindLocationTo, bindSizeTo, clearCursor, clearDirtyRect, contains, draw, getBlendMode, getCursor, getDirtyRect, getFilter, getLocalX, getLocalY, getParent, getRoot, getScene2D, getTag, getViewX, getViewX, getViewY, getViewY, intersects, isDirty, isEnabled, isEnabledAndVisible, isMouseDoubleClicked, isMouseDown, isMouseHover, isMouseOver, isMousePressed, isMouseReleased, isMouseTripleClicked, isMouseWheelRotated, isPick, isPickEnabledAndVisible, move, move, move, move, move, move, moveTo, moveTo, moveTo, moveTo, moveTo, moveTo, removeFromParent, scale, scale, scale, scale, scale, scale, scaleTo, scaleTo, scaleTo, scaleTo, scaleTo, scaleTo, setAnchor, setBlendMode, setCursor, setDirty, setFilter, setLocation, setLocation, setSize, setSize, setTag, translate, translate, updateDirtyRect |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public StretchableSprite(String imageName, double x, double y)
public StretchableSprite(String imageName, double x, double y, double w, double h)
public StretchableSprite(CoreImage image, double x, double y)
public StretchableSprite(CoreImage image, double x, double y, double w, double h)
public StretchableSprite(String imageName, int capWidth, int capHeight, double x, double y, double w, double h)
public StretchableSprite(CoreImage image, int capWidth, int capHeight, double x, double y, double w, double h)
Method Detail |
---|
public void setImage(CoreImage image)
ImageSprite
setImage
in class ImageSprite
public CoreImage render()
public CoreImage render(int width, int height)
public int getPaddingTop()
public int getPaddingRight()
public int getPaddingBottom()
public int getPaddingLeft()
public void setAnchorToHotSpot()
ImageSprite
setAnchorToHotSpot
in class ImageSprite
protected boolean isTransparent(int localX, int localY)
Sprite
The default implementation always returns false. Subclasses of this class may need to override this method to return accurate results.
This method is called from Sprite.contains(int,int)
.
isTransparent
in class ImageSprite
localX
- integer x-coordinate in local spacelocalY
- integer y-coordinate in local spaceprotected int getNaturalWidth()
Sprite
ImageSprite
, the natural width is the
width of the image.
getNaturalWidth
in class ImageSprite
protected int getNaturalHeight()
Sprite
ImageSprite
, the natural height is the
height of the image.
getNaturalHeight
in class ImageSprite
protected void drawSprite(CoreGraphics g)
Sprite
This method may be called multiple times for each dirty rectangle. The clip of the graphics context will be set to the current dirty rectangle.
When the contents of this sprite change (in another words, the graphic output of this method
will be different from the last time it is called), subclasses should call
setDirty(true)
.
Implementors should not save a reference to the graphics context as it can change between calls to this method.
drawSprite
in class ImageSprite
|
PulpCore | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |