funworld
Class TriangleImage

java.lang.Object
  extended by funworld.WorldImage
      extended by funworld.TriangleImage

public class TriangleImage
extends WorldImage

The class to represent filled triangle images drawn by the World when drawing on its Canvas.

The pinhole for the triangle is in the center of the triangle.

Since:
February 4 2012
Author:
Viera K. Proulx

Field Summary
 geometry.Posn p1
           
 geometry.Posn p2
           
 geometry.Posn p3
           
 
Fields inherited from class funworld.WorldImage
color, pinhole
 
Constructor Summary
TriangleImage(geometry.Posn p1, geometry.Posn p2, geometry.Posn p3, java.awt.Color color)
          A full constructor for this triangle image.
TriangleImage(geometry.Posn p1, geometry.Posn p2, geometry.Posn p3, colors.IColor color)
          A convenience constructor to supply the color in the form of IColor.
 
Method Summary
 int getHeight()
          Produce the height of this triangle image
 int getWidth()
          Produce the width of this triangle image
 WorldImage movePinhole(int dx, int dy)
          Produce the triangle with the pinhole moved by the given (dx, dy)
 WorldImage moveTo(geometry.Posn p)
          Produce the triangle with the pinhole moved to the given location
 
Methods inherited from class funworld.WorldImage
overlayImages
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

p1

public geometry.Posn p1

p2

public geometry.Posn p2

p3

public geometry.Posn p3
Constructor Detail

TriangleImage

public TriangleImage(geometry.Posn p1,
                     geometry.Posn p2,
                     geometry.Posn p3,
                     java.awt.Color color)
A full constructor for this triangle image.

Parameters:
p1 - the first point of this triangle
p2 - the second point of this triangle
p3 - the third point of this triangle
color - the color for this image

TriangleImage

public TriangleImage(geometry.Posn p1,
                     geometry.Posn p2,
                     geometry.Posn p3,
                     colors.IColor color)
A convenience constructor to supply the color in the form of IColor.

Parameters:
p1 - the first point of this triangle
p2 - the second point of this triangle
p3 - the third point of this triangle
color - the color for this image
Method Detail

movePinhole

public WorldImage movePinhole(int dx,
                              int dy)
Produce the triangle with the pinhole moved by the given (dx, dy)

Specified by:
movePinhole in class WorldImage
Parameters:
dx - the horizontal offset
dy - the vertical offset

moveTo

public WorldImage moveTo(geometry.Posn p)
Produce the triangle with the pinhole moved to the given location

Specified by:
moveTo in class WorldImage
Parameters:
p - the given location

getWidth

public int getWidth()
Produce the width of this triangle image

Specified by:
getWidth in class WorldImage
Returns:
the width of this image

getHeight

public int getHeight()
Produce the height of this triangle image

Specified by:
getHeight in class WorldImage
Returns:
the height of this image