|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface WorldImage
The API for an image.
Field Summary | |
---|---|
static tester.Equivalence<WorldImage> |
LOOKS_SAME
The equivalence operator that actually carries out pixel-for-pixel comparisons. |
Method Summary | |
---|---|
WorldImage |
above(WorldImage... others)
Concatenate two or more images vertically. |
WorldImage |
aboveCentered(WorldImage... others)
Concatenate two or more images vertically. |
WorldImage |
beside(WorldImage... others)
Concatenate two or more images horizontally. |
WorldImage |
besideCentered(WorldImage... others)
Concatenate two or more images horizontally. |
WorldImage |
centerMoved(int x,
int y)
Produce the image with its center translated to the specified (x,y) |
WorldImage |
centerMoved(Posn xy)
Produce the image with its center translated to the specified (x,y) |
WorldImage |
cropped(int left,
int right,
int top,
int bottom)
Get a new WorldImage by cropping this one to a rectangular window. |
void |
draw(Graphics2D g)
Draw this image in the provided Graphics2D context. |
boolean |
equals(Object other)
Is this the same as another WorldImage, as expression trees? Define this at every level that has instance variables. |
RasterImage |
frozen()
Get a WorldImage just like this one, but with a memoized raster rendering. |
int |
getBottom()
Produce the bottom of the bounding box. |
Posn |
getCenter()
Find the approximate center of this image. |
int |
getHeight()
Produce the height of this image |
int |
getLeft()
Produce the left edge of the bounding box. |
Color |
getPixelColor(int x,
int y)
Get the color of a specified pixel of an image. |
int |
getRight()
Produce the bottom of the bounding box. |
int |
getTop()
Produce the top of the bounding box. |
int |
getWidth()
Produce the width of this image |
int |
hashCode()
Get a hash code for the WorldImage. |
WorldImage |
map(ImageMap map)
Create a rectangular image pixel by pixel from an existing image. |
WorldImage |
map(ImageMap map,
Object extra)
Create a rectangular image pixel by pixel from an existing image. |
WorldImage |
moved(int dx,
int dy)
Produce the image translated by the given (dx, dy). |
WorldImage |
moved(Posn dxdy)
Produce the image translated by the given (dx, dy). |
WorldImage |
normalized()
Produce a "normalized" version of this image, with top-left corner at (0,0). |
WorldImage |
overlay(WorldImage... others)
Overlay other images on this one, retaining their locations. |
WorldImage |
overlayCentered(WorldImage... others)
Overlay other images on this one, ignoring location of all but centering them. |
WorldImage |
overlayXY(WorldImage front,
int dx,
int dy)
Overlay another image on this one, retaining locations and translating the other image. |
WorldImage |
place(WorldImage front,
int x,
int y)
Place another image onto this one, retaining the location of this one but translating the foreground so its center is at the specified location. |
WorldImage |
rotated(double degrees)
Get a version of this image rotated by a specified number of degrees around (0,0). |
WorldImage |
rotated(int degrees)
Get a version of this image rotated by a specified number of degrees around (0,0). |
WorldImage |
rotatedAround(double degrees,
Posn anchor)
Get a version of this image rotated by a specified number of degrees around a specified point. |
WorldImage |
rotatedAround(int degrees,
Posn anchor)
Get a version of this image rotated by a specified number of degrees around a specified point. |
WorldImage |
rotatedInPlace(double degrees)
Get a version of this image rotated by a specified number of degrees around its center. |
WorldImage |
rotatedInPlace(int degrees)
Get a version of this image rotated by a specified number of degrees around its center. |
boolean |
same(WorldImage other)
Is this the same as another WorldImage, in the sense that they render the same? |
boolean |
save(String filename)
Save a WorldImage to a .png file. |
WorldImage |
scaled(double factor)
get a uniformly scaled copy of the image. |
WorldImage |
scaled(double xFactor,
double yFactor)
get a non-uniformly scaled copy of the image. |
void |
show()
Display an image in a canvas. |
String |
toIndentedString(String indent)
Produce a String that represents this image, indented by the given indent . |
String |
toString()
Produce a String that represents this image. |
WorldImage |
xReflected()
get a horizontally-reflected copy of the image. |
WorldImage |
yReflected()
get a vertically-reflected copy of the image. |
Methods inherited from interface javalib.worldimages.Drawable |
---|
makeImage |
Field Detail |
---|
static final tester.Equivalence<WorldImage> LOOKS_SAME
Method Detail |
---|
WorldImage above(WorldImage... others)
others
- the images to concatenate below this, starting from the top
WorldImage aboveCentered(WorldImage... others)
others
- the images to concatenate below this, starting from the top
WorldImage beside(WorldImage... others)
others
- zero or more WorldImages
WorldImage besideCentered(WorldImage... others)
others
- the images to concatenate to the right of this, starting from the left
WorldImage centerMoved(int x, int y)
x
- the new x coordinate of the centery
- the new y coordinate of the center
WorldImage centerMoved(Posn xy)
xy
- the new center
WorldImage cropped(int left, int right, int top, int bottom)
left
- top
- right
- bottom
-
void draw(Graphics2D g)
Graphics2D
context.
g
- the provided Graphics2D
contextboolean equals(Object other)
equals
in class Object
other
- the object to compare with this
RasterImage frozen()
int getBottom()
Posn getCenter()
int getHeight()
int getLeft()
Color getPixelColor(int x, int y)
x
- the x coordinatey
- the y coordinate
int getRight()
int getTop()
int getWidth()
int hashCode()
hashCode
in class Object
WorldImage map(ImageMap map)
map
- an ImageMap encapsulating a function from Color to
Color
WorldImage map(ImageMap map, Object extra)
map
- an ImageMap encapsulating a function from Color to
Colorextra
- an arbitrary addtional argument to pass to the function
WorldImage moved(int dx, int dy)
dx
- the horizontal offsetdy
- the vertical offset
WorldImage moved(Posn dxdy)
dxdy
-
WorldImage normalized()
WorldImage overlay(WorldImage... others)
others
- one or more images to overlay on this one.
WorldImage overlayCentered(WorldImage... others)
others
- one or more images to overlay on this one.
WorldImage overlayXY(WorldImage front, int dx, int dy)
front
- the foreground image (to be translated)dx
- how much to move the foreground image horizontallydy
- how much to move the foreground image vertically
WorldImage place(WorldImage front, int x, int y)
front
- the foreground image (to be translated)x
- where to put the center of the foreground imagey
- where to put the center of the foreground image
WorldImage rotated(double degrees)
degrees
- a double, in this version
WorldImage rotated(int degrees)
degrees
-
WorldImage rotatedAround(double degrees, Posn anchor)
degrees
- anchor
- the fixpoint of the rotation
WorldImage rotatedAround(int degrees, Posn anchor)
degrees
- anchor
- the fixpoint of the rotation
WorldImage rotatedInPlace(double degrees)
degrees
- a double, in this version.
WorldImage rotatedInPlace(int degrees)
degrees
- an int, in this version
boolean same(WorldImage other)
This is a weaker condition than equals()
: it's quite possible for two
distinct expression trees to render the same (e.g. two solid rectangles of
the same color and width, stacked on top of one another, are same()
as
a single rectangle of that color and width and total height). Note also that
same()
does not imply substitutability: two distinct expression trees
can be same()
, but scaling them both up by a factor of 3 might not
be same()
.
same
in interface tester.ISame<WorldImage>
other
- the WorldImage to compare with this
boolean save(String filename)
filename
-
WorldImage scaled(double factor)
factor
-
WorldImage scaled(double xFactor, double yFactor)
xFactor
- yFactor
-
void show()
String toIndentedString(String indent)
String
that represents this image, indented by the given indent
.
Define this in all concrete subclasses.
Convention: The result of toIndentedString() will neither begin nor end with a newline; the specified indent will immediately follow each internal newline.
indent
- the given prefix representing the desired indentation
String
representation of this imageString toString()
String
that represents this image.
Define this in all concrete subclasses.
Convention: The result of toString() will neither begin nor end with a newline, although there may be newlines in the middle.
toString
in class Object
String
representation of this imageWorldImage xReflected()
WorldImage yReflected()
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |