JImage
The JImage object handles in-memory creation of GIF images.
Note
The JImage object has two different behaviors :
- Access limited to the current task when used with no name in the constructor,
- Shared between tasks when a name is used in the constructor.
The constructor is defined as follows :
class JImage {
constructor JImage( [string name] );
...
}
Local to current task
var local_image = new JImage();
This image will be deleted when the task ends.
Shared with other tasks
In all tasks needing to update/use the image :
var global_image = new JImage('unique_name');
This image will be deleted when all tasks using the image end.
Class definition
class JImage {
constructor JImage( [string name] );
bool setDimensions( width, height );
bool copyFrom( JImage otherimage );
bool scrollV( number_of_lines, background_color );
bool setPaletteColor( color_index, r, g, b );
bool setTransparentColor( color_index );
bool enableTransparency( bool );
bool drawPixel( x, y, color_index );
bool drawLine( x0, y0, x1, y1, color_index );
bool drawRect( x, y, width, height, color_index );
bool fillRect( x, y, width, height, color_index );
bool drawRoundRect( x, y, width, height, corner_radius, color_index );
bool fillRoundRect( x, y, width, height, corner_radius, color_index );
bool drawCircle( x, y, radius, color_index );
bool fillCircle( x, y, radius, color_index );
bool drawQuarterCircle( x, y, radius, corners_mask_bits, color_index );
bool fillQuarterCircle( x, y, radius, corners_mask_bits, offset_from_center, color_index );
bool drawTriangle( x0, y0, x1, y1, x2, y2, color_index );
bool fillTriangle( x0, y0, x1, y1, x2, y2, color_index );
bool setTextSize( size );
bool setCursor( x, y );
bool setTextColor( text_color_index [, text_background_color_index]);
bool setTextWrap( bool );
bool print( string );
bool saveToFile( string );
Array getData();
}
GIFimage sommand set
.setDimensions
Change the image size. The maximum size is defined so that width*height <= 128 Mpixels
.copyFrom
Set current dimensions and image from another existing JImage.
.scrollV
Scrolls the image vertically (scroll down only) by number_of_lines and fills the added lines with background_color.
.setPaletteColor
Defines one color entry in the 256 color palette. Color is described by the Red, Green, Blue components, each in the [0...255] range.
By default the following palette is set :
- Color 0 : Black
- Color 1...10 : Predefined color tab as follows :
- TBD
- Color 11...255 : Plasma colormap (see jhere)
.setTransparentColor
Defines which palette entry should be used as the transparent color.
.enableTransparency
Defines if the transparent color entry should be used or not.
.drawPixel
Draws a point (pixel) at (x,y) using the palette color given by color_index.
.drawLine
Draw a line from (x0,y0) to (x1,y1) using the palette color given by color_index.
drawLine( x0, y0, x1, y1, color_index );
.drawRect
Draw an empty rectangle from upper left corner (x,y), using the palette color given by color_index.
drawRect( x, y, width, height, color_index );
.fillRect
Fill a rectangular zone from upper left corner (x,y), using the palette color given by color_index as background.
fillRect( x, y, width, height, color_index );
.drawCircle
Draw a circle centered at (x,y), radius in pixels, using the palette color given by color_index.
img.drawCircle( x, y, radius, color_index );
.fillCircle
Fill a circle using the palette color given by color_index as background.
img.fillCircle( x, y, radius, color_index );
.drawTriangle
Draw a triangle.
drawTriangle( x0, y0, x1, y1, x2, y2, color_index );
.fillTriangle
Draw a colorized triangle, using color_index
fillTriangle( x0, y0, x1, y1, x2, y2, color_index );
.drawRoundRect
Draw a rectangle with round corners
img.drawRoundRect( x, y, width, height, corner_radius, color_index );
.fillRoundRect
Fill a rectangle with round corners.
img.fillRoundRect( x, y, width, height, corner_radius, color_index );
.drawQuarterCircle
Draw a portion of circle
drawQuarterCircle( x, y, radius, corners_mask_bits, color_index );
.fillQuarterCircle
Fill and colorize a portion of circle
fillQuarterCircle( x, y, radius, corners_mask_bits, offset_from_center, color_index );
.setTextSize
Define font size for next text to print.
img.setTextSize( size );
.setCursor
Define the cursor position before printing (display) a text.
img.setCursor( x, y );
.setTextColor
Define font color. Backgroud color is optional.
img.setTextColor( text_color_index [, text_background_color_index]);
Print a text on the GIF image.
You have to define the position (.setCursor), color (.setTextColor), and font size first (.setTextSize).
img.print( 'hello world' );
.saveToFile
img.saveToFile('/tmp/test.gif');