|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavalib.worldimages.AImage
public abstract class AImage
The most important class in the worldimages package.
Most of the methods you'll call on images live here: makeCircle
,
makeFromURL
, above
, scaled
, rotated
,
place
, show
, etc.
All images have a bounding box, which you can get with getLeft()
,
getTop()
, getRight()
, getBottom()
.
Most of this class is factory methods for various kinds of images. In many case, a factory method has to be written six times, with different combinations of Color and Mode arguments. Sometimes Java really annoys me....
Convention: the "makeWhatever" methods in AImage are public, and there's a version for each reasonable combination of missing parameters; these simply call the corresponding "make" method in the appropriate class. The "make" methods in each concrete class are package-private, and there's a version for each reasonable combination of missing parameters; these all call the constructor. The constructor (in most cases) is protected, and there's only one version.
Field Summary |
---|
Fields inherited from interface javalib.worldimages.WorldImage |
---|
LOOKS_SAME |
Constructor Summary | |
---|---|
AImage()
|
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. |
static WorldImage |
build(int width,
int height,
ImageBuilder builder)
Build a rectangular image pixel by pixel, with no "extra" information. |
static WorldImage |
build(int width,
int height,
ImageBuilder builder,
Object extra)
Build a rectangular image pixel by pixel. |
WorldImage |
centerMoved(int x,
int y)
Produce a copy of this image, with its center moved to the specified coordinates. |
WorldImage |
centerMoved(Posn xy)
Produce a copy of this image, with its center moved to the specified coordinates. |
protected String |
cornerString()
For debugging purposes; shows the coordinates of the bounding box of the image. |
WorldImage |
cropped(int left,
int right,
int top,
int bottom)
Get a new WorldImage by cropping this one to a rectangular window. |
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. |
Posn |
getCenter()
Retrieve the coordinates of the center of the image. |
int |
getHeight()
Retrieve the height of the image, in pixels. |
int |
getLeft()
Getter for the left edge of the bounding box. |
Color |
getPixelColor(int x,
int y)
Get the color of a specified pixel of an image. |
int |
getTop()
Getter for the top of the bounding box. |
int |
getWidth()
Retrieve the width of the image, in pixels. |
static void |
isApplet(boolean flag)
Record whether or not we're in an applet. |
static WorldImage |
makeCenteredCircle(Posn center,
int radius)
Produce an outlined black circle centered at a specified location. |
static WorldImage |
makeCenteredCircle(Posn center,
int radius,
Color color)
Produce an outlined circle centered at a specified location. |
static WorldImage |
makeCenteredCircle(Posn center,
int radius,
Color color,
Mode mode)
Produce a circle centered at a specified location. |
static WorldImage |
makeCenteredCircle(Posn center,
int radius,
IColor color)
Produce an outlined circle centered at a specified location. |
static WorldImage |
makeCenteredCircle(Posn center,
int radius,
IColor color,
Mode mode)
Produce a circle centered at a specified location. |
static WorldImage |
makeCenteredCircle(Posn center,
int radius,
Mode mode)
Produce a black circle centered at a specified location. |
static WorldImage |
makeCircle(int radius)
Produce an outlined black circle. |
static WorldImage |
makeCircle(int radius,
Color color)
Produce an outlined circle. |
static WorldImage |
makeCircle(int radius,
Color color,
Mode mode)
Produce a circle. |
static WorldImage |
makeCircle(int radius,
IColor color)
Produce an outlined circle. |
static WorldImage |
makeCircle(int radius,
IColor color,
Mode mode)
Produce a circle. |
static WorldImage |
makeCircle(int radius,
Mode mode)
Produce a black circle. |
static WorldImage |
makeEllipse(int width,
int height)
Produce an outlined black ellipse. |
static WorldImage |
makeEllipse(int width,
int height,
Color color)
Produce an outlined ellipse. |
static WorldImage |
makeEllipse(int width,
int height,
Color color,
Mode mode)
Produce an ellipse. |
static WorldImage |
makeEllipse(int width,
int height,
IColor color)
Produce an outlined ellipse. |
static WorldImage |
makeEllipse(int width,
int height,
IColor color,
Mode mode)
Produce an ellipse. |
static WorldImage |
makeEllipse(int width,
int height,
Mode mode)
Produce a black ellipse. |
static WorldImage |
makeFromFile(String filename)
Produce an image from a disk file (e.g. PNG, GIF, JPG, etc.) |
static WorldImage |
makeFromURL(String urlString)
Produce an image from a URL (e.g. "copy image location" in a Web browser) |
WorldImage |
makeImage()
Produce a WorldImage representation of this object. |
static WorldImage |
makeLine(Posn p1,
Posn p2)
Produce a black line segment with specified endpoints. |
static WorldImage |
makeLine(Posn p1,
Posn p2,
Color color)
Produce a line segment with specified endpoints. |
static WorldImage |
makeLine(Posn p1,
Posn p2,
IColor color)
Produce a line segment with specified endpoints. |
static WorldImage |
makePolygon(Color color,
Mode mode,
Posn... points)
Produce a polygon with specified vertices. |
static WorldImage |
makePolygon(Color color,
Posn... points)
Produce an outlined polygon with specified vertices. |
static WorldImage |
makePolygon(IColor color,
Mode mode,
Posn... points)
Produce a polygon with specified vertices. |
static WorldImage |
makePolygon(IColor color,
Posn... points)
Produce an outlined polygon with specified vertices. |
static WorldImage |
makePolygon(Mode mode,
Posn... points)
Produce a black polygon with specified vertices. |
static WorldImage |
makePolygon(Posn... points)
Produce an outlined black polygon with specified vertices. |
static WorldImage |
makeRectangle(int width,
int height)
Produce an outlined black rectangle. |
static WorldImage |
makeRectangle(int width,
int height,
Color color)
Produce an outlined rectangle. |
static WorldImage |
makeRectangle(int width,
int height,
Color color,
Mode mode)
Produce a rectangle. |
static WorldImage |
makeRectangle(int width,
int height,
IColor color)
Produce an outlined rectangle. |
static WorldImage |
makeRectangle(int width,
int height,
IColor color,
Mode mode)
Produce a rectangle. |
static WorldImage |
makeRectangle(int width,
int height,
Mode mode)
Produce a black rectangle. |
static WorldImage |
makeText(String text)
Produce an image of some text, defaulting to regular, 12-point, black. |
static WorldImage |
makeText(String text,
Color color)
Produce an image of some text, defaulting to regular 12-point. |
static WorldImage |
makeText(String text,
float size)
Produce an image of some text, defaulting to normal style and black. |
static WorldImage |
makeText(String text,
float size,
Color color)
Produce an image of some text, defaulting to normal style. |
static WorldImage |
makeText(String text,
float size,
IColor color)
Produce an image of some text, defaulting to normal style. |
static WorldImage |
makeText(String text,
float size,
TextStyle style)
Produce an image of some text, defaulting to black. |
static WorldImage |
makeText(String text,
float size,
TextStyle style,
Color color)
Produce an image of some text. |
static WorldImage |
makeText(String text,
float size,
TextStyle style,
IColor color)
Produce an image of some text. |
static WorldImage |
makeText(String text,
IColor color)
Produce an image of some text, defaulting to regular 12-point. |
static WorldImage |
makeText(String text,
TextStyle style)
Produce an image of some text, defaulting to 12-point black. |
static WorldImage |
makeText(String text,
TextStyle style,
Color color)
Produce an image of some text, defaulting to 12-point. |
static WorldImage |
makeText(String text,
TextStyle style,
IColor color)
Produce an image of some text, defgaulting to 12-point. |
static WorldImage |
makeTriangle(double side)
Produce an equilateral black outlined triangle with the specified side. |
static WorldImage |
makeTriangle(double side,
Color color)
Produce an equilateral outlined triangle with the specified side and color. |
static WorldImage |
makeTriangle(double side,
Color color,
Mode mode)
Produce an equilateral triangle with the specified side, color, and mode. |
static WorldImage |
makeTriangle(double side,
IColor color)
Produce an equilateral outlined triangle with the specified side and color. |
static WorldImage |
makeTriangle(double side,
IColor color,
Mode mode)
Produce an equilateral triangle with the specified side, color, and mode. |
static WorldImage |
makeTriangle(double side,
Mode mode)
Produce an equilateral black triangle with the specified side and mode. |
static WorldImage |
makeTriangle(Posn p1,
Posn p2,
Posn p3)
Produce an outlined black triangle with specified vertices. |
static WorldImage |
makeTriangle(Posn p1,
Posn p2,
Posn p3,
Color color)
Produce an outlined triangle with specified vertices. |
static WorldImage |
makeTriangle(Posn p1,
Posn p2,
Posn p3,
Color color,
Mode mode)
Produce a triangle with specified vertices. |
static WorldImage |
makeTriangle(Posn p1,
Posn p2,
Posn p3,
IColor color)
Produce an outlined triangle with specified vertices. |
static WorldImage |
makeTriangle(Posn p1,
Posn p2,
Posn p3,
IColor color,
Mode mode)
Produce a triangle with specified vertices. |
static WorldImage |
makeTriangle(Posn p1,
Posn p2,
Posn p3,
Mode mode)
Produce a black triangle with specified vertices. |
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 a translated copy of this image. |
WorldImage |
moved(Posn dxdy)
Produce a translated copy of this image. |
WorldImage |
normalized()
Produce a copy of this image translated to have its 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. |
static WorldImage |
overlayImages(WorldImage... others)
Produce an image by overlaying a bunch of existing images. |
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. |
protected static int |
rotate(int x,
int bits)
A utility function for producing hash codes. |
WorldImage |
rotated(double degrees)
Produce a copy of this image rotated by the specified number of degrees around the origin. |
WorldImage |
rotated(int degrees)
Produce a copy of this image rotated by the specified number of degrees around the origin. |
WorldImage |
rotatedAround(double degrees,
Posn anchor)
Produce a copy of this image rotated by the specified number of degrees around the specified Posn. |
WorldImage |
rotatedAround(int degrees,
Posn anchor)
Produce a copy of this image rotated by the specified number of degrees around the specified Posn. |
WorldImage |
rotatedInPlace(double degrees)
Produce a copy of this image rotated by the specified number of degrees around its center. |
WorldImage |
rotatedInPlace(int degrees)
Produce a copy of this image rotated by the specified number of degrees around its center. |
boolean |
same(WorldImage other)
Do two WorldImages appear the same? If they're equal as expression trees, they certainly appear the same. |
boolean |
sameClass(Object other)
Is this the same class as some other object? |
boolean |
save(String filename)
Save a WorldImage to a .png file. |
WorldImage |
scaled(double factor)
Produce a copy of this image scaled by the specified factor. |
WorldImage |
scaled(double xFactor,
double yFactor)
Produce a copy of this image scaled differently in x and y dimensions. |
void |
show()
Display the image in a new window by itself. |
String |
toString()
Convert the image to String form, for debugging purposes. |
WorldImage |
xReflected()
Produce a copy of this image reflected left to right, in place. |
WorldImage |
yReflected()
get a vertically-reflected copy of the image. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface javalib.worldimages.WorldImage |
---|
draw, getBottom, getRight, hashCode, toIndentedString |
Constructor Detail |
---|
public AImage()
Method Detail |
---|
public WorldImage above(WorldImage... others)
WorldImage
above
in interface WorldImage
others
- the images to concatenate below this, starting from the top
public WorldImage aboveCentered(WorldImage... others)
WorldImage
aboveCentered
in interface WorldImage
others
- the images to concatenate below this, starting from the top
public WorldImage beside(WorldImage... others)
WorldImage
beside
in interface WorldImage
others
- zero or more WorldImages
public WorldImage besideCentered(WorldImage... others)
WorldImage
besideCentered
in interface WorldImage
others
- the images to concatenate to the right of this, starting from the left
public static WorldImage build(int width, int height, ImageBuilder builder)
width
- the width in pixels of the desired imageheight
- the height in pixels of the desired imagebuilder
- an ImageBuilder specifying how to choose colorspublic static WorldImage build(int width, int height, ImageBuilder builder, Object extra)
width
- the width in pixels of the desired imageheight
- the height in pixels of the desired imagebuilder
- an ImageBuilder specifying how to choose colorsextra
- an arbitrary Object to be passed to each call of the builderpublic WorldImage centerMoved(int x, int y)
centerMoved
in interface WorldImage
x
- where the center of the image should be after translationy
- where the center of the image should be after translation
public WorldImage centerMoved(Posn xy)
centerMoved
in interface WorldImage
xy
- where the center of the image should be after translation
protected String cornerString()
public WorldImage cropped(int left, int right, int top, int bottom)
WorldImage
cropped
in interface WorldImage
public boolean equals(Object other)
WorldImage
equals
in interface WorldImage
equals
in class Object
other
- the object to compare with this
public RasterImage frozen()
WorldImage
frozen
in interface WorldImage
public Posn getCenter()
getCenter
in interface WorldImage
public int getHeight()
getHeight
in interface WorldImage
public int getLeft()
getLeft
in interface WorldImage
public Color getPixelColor(int x, int y)
WorldImage
getPixelColor
in interface WorldImage
x
- the x coordinatey
- the y coordinate
public int getTop()
getTop
in interface WorldImage
public int getWidth()
getWidth
in interface WorldImage
public static void isApplet(boolean flag)
flag
- public static WorldImage makeCenteredCircle(Posn center, int radius)
center
- the coordinates of the centerradius
- the radius of the circlepublic static WorldImage makeCenteredCircle(Posn center, int radius, Color color)
center
- the coordinates of the centerradius
- the radius of the circlecolor
- the color of the circlepublic static WorldImage makeCenteredCircle(Posn center, int radius, Color color, Mode mode)
center
- the coordinates of the centerradius
- the radius of the circlecolor
- the color of the circlemode
- either Mode.FILLED or Mode.OUTLINEDpublic static WorldImage makeCenteredCircle(Posn center, int radius, IColor color)
center
- the coordinates of the centerradius
- the radius of the circlecolor
- the color of the circlepublic static WorldImage makeCenteredCircle(Posn center, int radius, IColor color, Mode mode)
center
- the coordinates of the centerradius
- the radius of the circlecolor
- the color of the circlemode
- either Mode.FILLED or Mode.OUTLINEDpublic static WorldImage makeCenteredCircle(Posn center, int radius, Mode mode)
center
- the coordinates of the centerradius
- the radius of the circlemode
- either Mode.FILLED or Mode.OUTLINEDpublic static WorldImage makeCircle(int radius)
radius
- the radius of the circlepublic static WorldImage makeCircle(int radius, Color color)
radius
- the radius of the circlecolor
- the color of the circlepublic static WorldImage makeCircle(int radius, Color color, Mode mode)
radius
- the radius of the circlecolor
- the color of the circlemode
- either Mode.FILLED or Mode.OUTLINEDpublic static WorldImage makeCircle(int radius, IColor color)
radius
- the radius of the circlecolor
- the color of the circlepublic static WorldImage makeCircle(int radius, IColor color, Mode mode)
radius
- the radius of the circlecolor
- the color of the circlemode
- either Mode.FILLED or Mode.OUTLINEDpublic static WorldImage makeCircle(int radius, Mode mode)
radius
- the radius of the circlemode
- either Mode.FILLED or Mode.OUTLINEDpublic static WorldImage makeEllipse(int width, int height)
width
- the width in pixelsheight
- the height in pixelspublic static WorldImage makeEllipse(int width, int height, Color color)
width
- the width in pixelsheight
- the height in pixelscolor
- the colorpublic static WorldImage makeEllipse(int width, int height, Color color, Mode mode)
width
- the width in pixelsheight
- the height in pixelscolor
- the colormode
- either Mode.FILLED or Mode.OUTLINEDpublic static WorldImage makeEllipse(int width, int height, IColor color)
width
- the width in pixelsheight
- the height in pixelscolor
- the colorpublic static WorldImage makeEllipse(int width, int height, IColor color, Mode mode)
width
- the width in pixelsheight
- the height in pixelscolor
- the colormode
- either Mode.FILLED or Mode.OUTLINEDpublic static WorldImage makeEllipse(int width, int height, Mode mode)
width
- the width in pixelsheight
- the height in pixelsmode
- either Mode.FILLED or Mode.OUTLINEDpublic static WorldImage makeFromFile(String filename)
filename
- the name of the disk file, interpreted relative to the project directory.public static WorldImage makeFromURL(String urlString)
urlString
- the URL, written as a stringpublic WorldImage makeImage()
Drawable
makeImage
in interface Drawable
public static WorldImage makeLine(Posn p1, Posn p2)
p1
- the coordinates of one endpointp2
- the coordinates of the other endpointpublic static WorldImage makeLine(Posn p1, Posn p2, Color color)
p1
- the coordinates of one endpointp2
- the coordinates of the other endpointcolor
- the color of the line segmentpublic static WorldImage makeLine(Posn p1, Posn p2, IColor color)
p1
- the coordinates of one endpointp2
- the coordinates of the other endpointcolor
- the color of the line segmentpublic static WorldImage makePolygon(Color color, Mode mode, Posn... points)
color
- the color of the polygonmode
- either Mode.FILLED or Mode.OUTLINEDpoints
- one or more Posns to indicate verticespublic static WorldImage makePolygon(Color color, Posn... points)
color
- the color of the polygonpoints
- one or more Posns to indicate verticespublic static WorldImage makePolygon(IColor color, Mode mode, Posn... points)
color
- the color of the polygonmode
- either Mode.FILLED or Mode.OUTLINEDpoints
- one or more Posns to indicate verticespublic static WorldImage makePolygon(IColor color, Posn... points)
color
- the color of the polygonpoints
- one or more Posns to indicate verticespublic static WorldImage makePolygon(Mode mode, Posn... points)
mode
- either Mode.FILLED or Mode.OUTLINEDpoints
- one or more Posns to indicate verticespublic static WorldImage makePolygon(Posn... points)
points
- one or more Posns to indicate verticespublic static WorldImage makeRectangle(int width, int height)
width
- the width in pixelsheight
- the height in pixelspublic static WorldImage makeRectangle(int width, int height, Color color)
width
- the width in pixelsheight
- the height in pixelscolor
- the colorpublic static WorldImage makeRectangle(int width, int height, Color color, Mode mode)
width
- the width in pixelsheight
- the height in pixelscolor
- the colormode
- either Mode.FILLED or Mode.OUTLINEDpublic static WorldImage makeRectangle(int width, int height, IColor color)
width
- the width in pixelsheight
- the height in pixelscolor
- the colorpublic static WorldImage makeRectangle(int width, int height, IColor color, Mode mode)
width
- the width in pixelsheight
- the height in pixelscolor
- the colormode
- either Mode.FILLED or Mode.OUTLINEDpublic static WorldImage makeRectangle(int width, int height, Mode mode)
width
- the width in pixelsheight
- the height in pixelsmode
- either Mode.FILLED or Mode.OUTLINEDpublic static WorldImage makeText(String text)
text
- the String to convert into an imagepublic static WorldImage makeText(String text, Color color)
text
- the String to convert into an imagecolor
- the color of the text (default black)public static WorldImage makeText(String text, float size)
text
- the String to convert into an imagesize
- the size in points (e.g. 12.0 is 12-point font)color
- the color of the text (default black)public static WorldImage makeText(String text, float size, Color color)
text
- the String to convert into an imagesize
- the size in points (e.g. 12.0 is 12-point font)color
- the color of the text (default black)public static WorldImage makeText(String text, float size, IColor color)
text
- the String to convert into an imagesize
- the size in points (e.g. 12.0 is 12-point font)color
- the color of the text (default black)public static WorldImage makeText(String text, float size, TextStyle style)
text
- the String to convert into an imagesize
- the size in points (e.g. 12.0 is 12-point font)style
- either TextStyle.NORMAL (the default, also known as
TextStyle.REGULAR), TextStyle.BOLD, TextStyle,ITALIC,
or TextStyle.BOLD_ITALIC (also known as TextStyle.ITALIC_BOLD)public static WorldImage makeText(String text, float size, TextStyle style, Color color)
text
- the String to convert into an imagesize
- the size in points (e.g. 12.0 is 12-point font)style
- either TextStyle.NORMAL (the default, also known as
TextStyle.REGULAR), TextStyle.BOLD, TextStyle,ITALIC,
or TextStyle.BOLD_ITALIC (also known as TextStyle.ITALIC_BOLD)color
- the color of the text (default black)public static WorldImage makeText(String text, float size, TextStyle style, IColor color)
text
- the String to convert into an imagesize
- the size in points (e.g. 12.0 is 12-point font)style
- either TextStyle.NORMAL (the default, also known as
TextStyle.REGULAR), TextStyle.BOLD, TextStyle,ITALIC,
or TextStyle.BOLD_ITALIC (also known as TextStyle.ITALIC_BOLD)color
- the color of the text (default black)public static WorldImage makeText(String text, IColor color)
text
- the String to convert into an imagecolor
- the color of the text (default black)public static WorldImage makeText(String text, TextStyle style)
text
- the String to convert into an imagestyle
- either TextStyle.NORMAL (the default, also known as
TextStyle.REGULAR), TextStyle.BOLD, TextStyle,ITALIC,
or TextStyle.BOLD_ITALIC (also known as TextStyle.ITALIC_BOLD)public static WorldImage makeText(String text, TextStyle style, Color color)
text
- the String to convert into an imagestyle
- either TextStyle.NORMAL (the default, also known as
TextStyle.REGULAR), TextStyle.BOLD, TextStyle,ITALIC,
or TextStyle.BOLD_ITALIC (also known as TextStyle.ITALIC_BOLD)color
- the color of the text (default black)public static WorldImage makeText(String text, TextStyle style, IColor color)
text
- the String to convert into an imagestyle
- either TextStyle.NORMAL (the default, also known as
TextStyle.REGULAR), TextStyle.BOLD, TextStyle,ITALIC,
or TextStyle.BOLD_ITALIC (also known as TextStyle.ITALIC_BOLD)color
- the color of the text (default black)public static WorldImage makeTriangle(double side)
side
- the length of each side of the trianglepublic static WorldImage makeTriangle(double side, Color color)
side
- the length of each side of the trianglecolor
- the color of the trianglepublic static WorldImage makeTriangle(double side, Color color, Mode mode)
side
- the length of each side of the trianglecolor
- the color of the trianglemode
- either Mode.FILLED or Mode.OUTLINEDpublic static WorldImage makeTriangle(double side, IColor color)
side
- the length of each side of the trianglecolor
- the color of the trianglepublic static WorldImage makeTriangle(double side, IColor color, Mode mode)
side
- the length of each side of the trianglecolor
- the color of the trianglemode
- either Mode.FILLED or Mode.OUTLINEDpublic static WorldImage makeTriangle(double side, Mode mode)
side
- the length of each side of the trianglemode
- either Mode.FILLED or Mode.OUTLINEDpublic static WorldImage makeTriangle(Posn p1, Posn p2, Posn p3)
p1
- the coordinates of one vertexp2
- the coordinates of another vertexp3
- the coordinates of the third vertexpublic static WorldImage makeTriangle(Posn p1, Posn p2, Posn p3, Color color)
p1
- the coordinates of one vertexp2
- the coordinates of another vertexp3
- the coordinates of the third vertexcolor
- the color of the trianglepublic static WorldImage makeTriangle(Posn p1, Posn p2, Posn p3, Color color, Mode mode)
p1
- the coordinates of one vertexp2
- the coordinates of another vertexp3
- the coordinates of the third vertexcolor
- the color of the trianglemode
- either Mode.FILLED or Mode.OUTLINEDpublic static WorldImage makeTriangle(Posn p1, Posn p2, Posn p3, IColor color)
p1
- the coordinates of one vertexp2
- the coordinates of another vertexp3
- the coordinates of the third vertexcolor
- the color of the trianglepublic static WorldImage makeTriangle(Posn p1, Posn p2, Posn p3, IColor color, Mode mode)
p1
- the coordinates of one vertexp2
- the coordinates of another vertexp3
- the coordinates of the third vertexcolor
- the color of the trianglemode
- either Mode.FILLED or Mode.OUTLINEDpublic static WorldImage makeTriangle(Posn p1, Posn p2, Posn p3, Mode mode)
p1
- the coordinates of one vertexp2
- the coordinates of another vertexp3
- the coordinates of the third vertexmode
- either Mode.FILLED or Mode.OUTLINEDpublic WorldImage map(ImageMap map)
WorldImage
map
in interface WorldImage
map
- an ImageMap encapsulating a function from Color to
Color
public WorldImage map(ImageMap map, Object extra)
WorldImage
map
in interface WorldImage
map
- an ImageMap encapsulating a function from Color to
Colorextra
- an arbitrary addtional argument to pass to the function
public WorldImage moved(int dx, int dy)
moved
in interface WorldImage
dx
- how far to move to the right (or left, if dx is negative)dy
- how far to move down (or up, if dy is negative)
public WorldImage moved(Posn dxdy)
moved
in interface WorldImage
dxdy
- a Posn indicating how far to move
public WorldImage normalized()
normalized
in interface WorldImage
public WorldImage overlay(WorldImage... others)
WorldImage
overlay
in interface WorldImage
others
- one or more images to overlay on this one.
public WorldImage overlayCentered(WorldImage... others)
WorldImage
overlayCentered
in interface WorldImage
others
- one or more images to overlay on this one.
public static WorldImage overlayImages(WorldImage... others)
others
- two or more images to be overlaid
public WorldImage overlayXY(WorldImage front, int dx, int dy)
WorldImage
overlayXY
in interface WorldImage
front
- the foreground image (to be translated)dx
- how much to move the foreground image horizontallydy
- how much to move the foreground image vertically
public WorldImage place(WorldImage front, int x, int y)
WorldImage
place
in interface WorldImage
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
protected static int rotate(int x, int bits)
x
- a hashCode for some fieldbits
- how many bits to rotate it within a 32-bit int
public WorldImage rotated(double degrees)
rotated
in interface WorldImage
degrees
- how many degrees to rotate, counter-clockwise (I think!)
public WorldImage rotated(int degrees)
rotated
in interface WorldImage
degrees
- how many degrees to rotate, counter-clockwise (I think!)
public WorldImage rotatedAround(double degrees, Posn anchor)
rotatedAround
in interface WorldImage
degrees
- how many degrees to rotate, counter-clockwise (I think!)anchor
- the Posn to rotate around
public WorldImage rotatedAround(int degrees, Posn anchor)
rotatedAround
in interface WorldImage
degrees
- how many degrees to rotate, counter-clockwise (I think!)anchor
- the Posn to rotate around
public WorldImage rotatedInPlace(double degrees)
rotatedInPlace
in interface WorldImage
degrees
- how many degrees to rotate, counter-clockwise (I think!)
public WorldImage rotatedInPlace(int degrees)
rotatedInPlace
in interface WorldImage
degrees
- how many degrees to rotate, counter-clockwise (I think!)
public boolean same(WorldImage other)
same
in interface WorldImage
same
in interface tester.ISame<WorldImage>
other
- the WorldImage to compare with this
public boolean sameClass(Object other)
other
-
public boolean save(String filename)
WorldImage
save
in interface WorldImage
public WorldImage scaled(double factor)
scaled
in interface WorldImage
factor
- the scaling factor (e.g. 2.0 means it doubles in size)
public WorldImage scaled(double xFactor, double yFactor)
scaled
in interface WorldImage
xFactor
- the scaling factor in the x dimensionyFactor
- the scaling factor in the y dimension
public void show()
show
in interface WorldImage
public String toString()
toString
in interface WorldImage
toString
in class Object
String
representation of this imagepublic WorldImage xReflected()
xReflected
in interface WorldImage
public WorldImage yReflected()
WorldImage
yReflected
in interface WorldImage
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |