|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectSpritePixels
public class SpritePixels
SpritePixels is an abstract class that another class extends when it wants to provide the pixels that make up the image of a Sprite.
Field Summary | |
---|---|
static int |
BLACK_OPAQUE_PIXEL
Value of a pixel which is solid black. |
static java.lang.String |
CLASS_NAME
Class name as a String. |
static int |
MAX_SPRITE_HEIGHT
Default maximum sprite image height. |
static int |
MAX_SPRITE_WIDTH
Default maximum sprite image width. |
static int |
MIN_SPRITE_HEIGHT
Default minimum sprite image height. |
static int |
MIN_SPRITE_WIDTH
Default minimum sprite image width. |
static int |
ROTATE_LEFT_RIGHT
Symbolic constant for rotation style where initial image faces left and remains facing left for headings 181-359 degrees, but flips to facing right for headings 0-180 degrees. |
static int |
ROTATE_OFF
Symbolic constant for no rotation of the turtle's shape. |
static int |
ROTATE_ON
Symbolic constant for standard 360 degree rotation style of turtle's shape, its Sprite. |
static int |
ROTATE_RIGHT_LEFT
Symbolic constant for rotation style where initial image faces right and remains facing right for headings 0-180 degrees, but flips to facing left for headings 181-359. |
Constructor Summary | |
---|---|
SpritePixels(int width,
int height,
java.awt.Color color,
double heading)
Instantiate a Sprite's Image given its dimensions, color, and an implementation of the initSpritePixels() method. |
|
SpritePixels(PixelRectangle pixRect)
Instantiate the pixels that make up a Sprite's Image given an array of pixels. |
|
SpritePixels(PixelRectangle pixRect,
int rotationStyle)
Instantiate the pixels that make up a Sprite's Image given an array of pixels. |
Method Summary | |
---|---|
int |
getHeight()
Return the current height of this Sprite's image. |
protected int |
getMinimumHeight()
Return the default minimum height of this Sprite's image. |
protected int |
getMinimumWidth()
Return the default minimum width of this Sprite's image. |
int[] |
getPixels()
Return a copy of this Sprite's pixels. |
int |
getSideSize()
Return the length of a side of this Sprite's square array of pixels. |
int |
getWidth()
Return the current width of this Sprite's image. |
protected void |
initSpritePixels(int spriteSideSize)
Initializes the pixels that make up the turtle's image. |
protected void |
setCirclePixels(int ctrX,
int ctrY,
int radius,
int rgbVal)
Set the value of pixels along an approximation of the circumference of a circle. |
protected void |
setLinePixels(int x0,
int y0,
int x1,
int y1,
int rgbVal)
Set the value of pixels along an approximation of a line. |
protected void |
setPixel(int x,
int y,
int rgbVal)
Fill the specified (x,y) pixel in the Sprite's image with an RGB value. |
boolean |
setSpriteColor(java.awt.Color newColor)
Fill inner pixels of the turtle with the specified color. |
boolean |
setSpriteHeading(double newHeading)
Rotate the turtle to a specified heading (radians). |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String CLASS_NAME
public static final int MAX_SPRITE_HEIGHT
public static final int MAX_SPRITE_WIDTH
public static final int MIN_SPRITE_HEIGHT
public static final int MIN_SPRITE_WIDTH
public static final int BLACK_OPAQUE_PIXEL
public static final int ROTATE_ON
public static final int ROTATE_OFF
public static final int ROTATE_LEFT_RIGHT
public static final int ROTATE_RIGHT_LEFT
Constructor Detail |
---|
public SpritePixels(PixelRectangle pixRect)
public SpritePixels(PixelRectangle pixRect, int rotationStyle)
public SpritePixels(int width, int height, java.awt.Color color, double heading)
Method Detail |
---|
protected int getMinimumHeight()
protected int getMinimumWidth()
protected void initSpritePixels(int spriteSideSize)
protected void setCirclePixels(int ctrX, int ctrY, int radius, int rgbVal)
This is an implementation of the simplest form of the midpoint algorithm as described in Computer Graphics, Foley and van Dam
ctrX
- the X coordinate of center of the circle.ctrY
- the Y coordinate of center of the circle.radius
- the distance from the center to pixels painted.rgbVal
- the RGB value of the pixels effected.protected void setLinePixels(int x0, int y0, int x1, int y1, int rgbVal)
x0
- the X coordinate of one end of the line.y0
- the Y coordinate of one end of the line.x1
- the X coordinate of the other end of the line.y1
- the Y coordinate of the other end of the line.rgbVal
- the RGB value of the pixels effected.protected void setPixel(int x, int y, int rgbVal)
The origin for the coordinate system used is the top-left corner with X values increasing left to right and Y values increasing top to bottom.
x
- the X coordinate of the pixel.y
- the Y coordinate of the pixel.rgbVal
- the new RGB value of the pixel.public int[] getPixels()
public int getSideSize()
public int getHeight()
public int getWidth()
public boolean setSpriteColor(java.awt.Color newColor)
public boolean setSpriteHeading(double newHeading)
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |