Packagede.popforge.imageprocessing.utils
Classpublic final class Drawing

The Drawing class is a utility to draw very fast and simple on an Image object.

The most speed can be achieved drawing lines without anti-aliasing and 100% alpha.

Line with anti-aliasing:

Line without anti-aliasing:



Public Methods
 MethodDefined by
  
drawAALineG(image:Image, color:int, x0:int, y0:int, x1:int, y1:int):void
[static] Draws an anti-aliased line on grayscale images using Xiaolin Wu's algorithm.
Drawing
  
drawAALineRGB(image:Image, color:int, x0:int, y0:int, x1:int, y1:int):void
[static] Draws an anti-aliased line on RGB images using Xiaolin Wu's algorithm.
Drawing
  
drawLine(image:Image, color:int, x0:int, y0:int, x1:int, y1:int, antiAliasing:Boolean = false):void
[static] Draws a line on an Image object choosing automatically the correct format.
Drawing
  
drawLineG(image:Image, color:int, x0:int, y0:int, x1:int, y1:int):void
[static] Draws a line on grayscale images using Bresenham's algorithm (without anti-aliasing).
Drawing
  
drawLineRGB(image:Image, color:int, x0:int, y0:int, x1:int, y1:int):void
[static] Draws a line on RGB images using Bresenham's algorithm (without anti-aliasing).
Drawing
  
drawRect(image:Image, color:int, x:int, y:int, width:int, height:int):void
[static] Draws a rectangle on an Image object.
Drawing
  
drawText(image:Image, color:int, x:int, y:int, text:String, fontName:String = "arial", fontSize:int = 12, bold:Boolean = false):void
[static] Draws a text on an Image object.
Drawing
  
fillRect(image:Image, color:int, x:int, y:int, width:int, height:int):void
[static] Draws and fills a rectangle on an Image object.
Drawing
Method detail
drawAALineG()method
public static function drawAALineG(image:Image, color:int, x0:int, y0:int, x1:int, y1:int):void

Draws an anti-aliased line on grayscale images using Xiaolin Wu's algorithm.

Supported formats:

Parameters
image:Image — The Image on which you want to draw.
 
color:int — A color in the format 0xAAYY.
 
x0:int — The x start position in pixel.
 
y0:int — The y start position in pixel.
 
x1:int — The x end position in pixel.
 
y1:int — The y end position in pixel.
drawAALineRGB()method 
public static function drawAALineRGB(image:Image, color:int, x0:int, y0:int, x1:int, y1:int):void

Draws an anti-aliased line on RGB images using Xiaolin Wu's algorithm.

Supported formats:

Parameters
image:Image — The Image on which you want to draw.
 
color:int — A color in the format 0xAARRGGBB.
 
x0:int — The x start position in pixel.
 
y0:int — The y start position in pixel.
 
x1:int — The x end position in pixel.
 
y1:int — The y end position in pixel.
drawLine()method 
public static function drawLine(image:Image, color:int, x0:int, y0:int, x1:int, y1:int, antiAliasing:Boolean = false):void

Draws a line on an Image object choosing automatically the correct format.

Be careful with the color. The color for a grayscale image is 0xAAYY. This means if you want to draw a white line with full alpha on a grayscale image your color should be 0xffff. For 50% alpha you would use 0x80ff.

The same on an rgb image looks different since you have three channels plus the alpha value. Therefore a white line with 100% alpha needs 0xffffffff. 50% alpha would be 0x80ffffff.

The algorithms for non anti-aliased lines are optimized to work with 100% alpha very quick.

Supported formats:

Parameters
image:Image — The Image on which you want to draw.
 
color:int — The color value either in 0xAARRGGBB for ImageFormat.RGB and ImageFormat.RGBA or 0xAAYY for ImageFormat.GRAYSCALE.
 
x0:int — The x start position in pixel.
 
y0:int — The y start position in pixel.
 
x1:int — The x end position in pixel.
 
y1:int — The y end position in pixel.
 
antiAliasing:Boolean (default = false) — true if you want to use anti-aliased lines.
drawLineG()method 
public static function drawLineG(image:Image, color:int, x0:int, y0:int, x1:int, y1:int):void

Draws a line on grayscale images using Bresenham's algorithm (without anti-aliasing).

Using 100% alpha results in faster execution.

Supported formats:

Parameters
image:Image — The Image on which you want to draw.
 
color:int — A color in the format 0xAAYY.
 
x0:int — The x start position in pixel.
 
y0:int — The y start position in pixel.
 
x1:int — The x end position in pixel.
 
y1:int — The y end position in pixel.
drawLineRGB()method 
public static function drawLineRGB(image:Image, color:int, x0:int, y0:int, x1:int, y1:int):void

Draws a line on RGB images using Bresenham's algorithm (without anti-aliasing).

Using 100% alpha results in faster execution.

Supported formats:

Parameters
image:Image — The Image on which you want to draw.
 
color:int — A color in the format 0xAARRGGBB.
 
x0:int — The x start position in pixel.
 
y0:int — The y start position in pixel.
 
x1:int — The x end position in pixel.
 
y1:int — The y end position in pixel.
drawRect()method 
public static function drawRect(image:Image, color:int, x:int, y:int, width:int, height:int):void

Draws a rectangle on an Image object.

Supported formats:

Parameters
image:Image — The Image on which you want to draw.
 
color:int — The color value either in 0xAARRGGBB for ImageFormat.RGB and ImageFormat.RGBA or 0xAAYY for ImageFormat.GRAYSCALE.
 
x:int — Top-left x position of the rectangle in pixels.
 
y:int — Top-left y position of the rectangle in pixels.
 
width:int — Width of the rectangle in pixels.
 
height:int — Height of the rectangle in pixels.
drawText()method 
public static function drawText(image:Image, color:int, x:int, y:int, text:String, fontName:String = "arial", fontSize:int = 12, bold:Boolean = false):void

Draws a text on an Image object.

Parameters
image:Image — The Image on which you want to draw.
 
color:int — The color value either in 0xAARRGGBB for ImageFormat.RGB and ImageFormat.RGBA or 0xAAYY for ImageFormat.GRAYSCALE.
 
x:int — The x position of the text.
 
y:int — The y position of the text.
 
text:String — The text you want do draw.
 
fontName:String (default = "arial") — The name of the font.
 
fontSize:int (default = 12) — The size of the font.
 
bold:Boolean (default = false)true if font should be bold.
fillRect()method 
public static function fillRect(image:Image, color:int, x:int, y:int, width:int, height:int):void

Draws and fills a rectangle on an Image object.

Supported formats:

Parameters
image:Image — The Image on which you want to draw.
 
color:int — The color value either in 0xAARRGGBB for ImageFormat.RGB and ImageFormat.RGBA or 0xAAYY for ImageFormat.GRAYSCALE.
 
x:int — Top-left x position of the rectangle in pixels.
 
y:int — Top-left y position of the rectangle in pixels.
 
width:int — Width of the rectangle in pixels.
 
height:int — Height of the rectangle in pixels.