com.WorldLibAndroid
Interface ICanvas

All Known Implementing Classes:
CanvasPanel

public interface ICanvas

Defines the methods to draw the possible objects.

Author:
Christian Herrera

Method Summary
 void cleanCanvas()
          Clears the canvas.
 void drawBitmap(int[] colors, int offset, int stride, float x, float y, int width, int height, boolean hasAlpha)
          Treat the specified array of colors as a bitmap, and draw it.
 void drawCircle(float x, float y, float radius, IColor p)
          Draws a filled circle.
 void drawDrawable(Drawable image)
          Draws the specified drawable image.
 void drawLine(float x1, float y1, float x2, float y2, IColor p)
          Draws a line.
 void drawRect(float x1, float y1, float x2, float y2, IColor p)
          Draws a filled rectangle.
 void drawText(java.lang.String m, float x, float y, IColor p)
          Draws a text.
 Canvas getAndroidCanvas()
          Get the inner Canvas; can be used to draw complicated shapes beyond what this interface offers.
 

Method Detail

drawLine

void drawLine(float x1,
              float y1,
              float x2,
              float y2,
              IColor p)
Draws a line.

Parameters:
x1 - coordinate of the beginning of the line.
y1 - coordinate of the beginning of the line.
x2 - coordinate of the end of the line.
y2 - coordinate of the end of the line.
p - object that holds the color of the line.

drawRect

void drawRect(float x1,
              float y1,
              float x2,
              float y2,
              IColor p)
Draws a filled rectangle.

Parameters:
x1 - The left side of the rectangle to be drawn.
y1 - The top side of the rectangle to be drawn.
x2 - The right side of the rectangle to be drawn.
y2 - The bottom side of the rectangle to be drawn.
p - object that holds the color of the rectangle.

drawCircle

void drawCircle(float x,
                float y,
                float radius,
                IColor p)
Draws a filled circle.

Parameters:
x - coordinate of the canvas panel.
y - coordinate of the canvas panel.
radius - of the circle.
p - object that holds the color of the circle.

drawText

void drawText(java.lang.String m,
              float x,
              float y,
              IColor p)
Draws a text.

Parameters:
m - The text to be drawn.
x - The x-coordinate of the origin of the text being drawn.
y - The y-coordinate of the origin of the text being drawn.
p - object that holds the color of the text.

drawBitmap

void drawBitmap(int[] colors,
                int offset,
                int stride,
                float x,
                float y,
                int width,
                int height,
                boolean hasAlpha)
Treat the specified array of colors as a bitmap, and draw it. This gives the same result as first creating a bitmap from the array, and then drawing it, but this method avoids explicitly creating a bitmap object which can be more efficient if the colors are changing often.

Parameters:
colors - Array of colors representing the pixels of the bitmap.
offset - into the array of colors for the first pixel.
stride - The number of colors in the array between rows (must be >= width or <= -width).
x - The X coordinate for where to draw the bitmap.
y - The Y coordinate for where to draw the bitmap.
width - The width of the bitmap.
height - The height of the bitmap.
hasAlpha - True if the alpha channel of the colors contains valid values. If false, the alpha byte is ignored (assumed to be 0xFF for every pixel).

drawDrawable

void drawDrawable(Drawable image)
Draws the specified drawable image.

Parameters:
image - the Drawable to be drawn

cleanCanvas

void cleanCanvas()
Clears the canvas.


getAndroidCanvas

Canvas getAndroidCanvas()
Get the inner Canvas; can be used to draw complicated shapes beyond what this interface offers.

Returns:
the inner Canvas object