The Image class allows you to create bitmaps in Reporter. More...
The REPORTER JavaScript API provides many class constants, properties and methods. For Arup to
be able to extend and enhance the API in the future any constant, property or method names beginning with a lowercase
or uppercase letter are reserved.
If you need to add your own properties or methods to one of the existing classes then to avoid any potential future conflict you
should ensure that the name begins with either an underscore (_) or a dollar sign ($) or the name is prefixed with your
own unique identifier.
For example if company 'ABC' need to add a property called 'example' then to avoid any potential future conflict use one of:
| Name | Description |
| Image.BMP | Save image as BMP |
| Image.JPG | Save image as JPG |
| Image.PNG | Save image as PNG |
| Name | Type | Description |
| antialiasing | bool | Whether or not lines, shapes and text are drawn with antialiasing (true by default). |
| fillColour | string | Colour to use when filling shapes on the Image. Can be "none", a valid colour from the X colour database (For Linux users, see /etc/X11/rgb.txt) e.g. "Blue", or #RRGGBB (each of R, G and B is a single hex digit) e.g. "#0000FF" for blue. |
| font | string | Font to use when drawing text on the Image e.g. "Courier". Can be any font accessible by REPORTER. |
| fontAngle | integer | Angle (degrees) text is drawn at on the Image. Can be between -360 and 360 degrees. |
| fontColour | string | Colour to use when drawing text on the Image. Can be "none", a valid colour from the X colour database (For Linux users, see /etc/X11/rgb.txt) e.g. "Blue", or #RRGGBB (each of R, G and B is a single hex digit) e.g. "#0000FF" for blue. |
| fontJustify | constant | Justification to use when drawing text on the Image. Can be Reporter.JUSTIFY_CENTRE, Reporter.JUSTIFY_LEFT or Reporter.JUSTIFY_RIGHT |
| fontSize | integer | Size of font (in points) to use when drawing text on the Image |
| fontStyle | constant | Style of font to use when drawing text on the Image. Can be any combination of Reporter.TEXT_NORMAL, Reporter.TEXT_BOLD, Reporter.TEXT_ITALIC and Reporter.TEXT_UNDERLINE |
| height | integer | Height of the Image |
| lineCapStyle | constant | Style to use for the end of lines on an Image. Can be Reporter.CAP_FLAT, Reporter.CAP_SQUARE or Reporter.CAP_ROUND |
| lineColour | string | Colour to use when drawing lines on the Image. Can be "none", a valid colour from the X colour database (For Linux users, see /etc/X11/rgb.txt) e.g. "Blue", or #RRGGBB (each of R, G and B is a single hex digit) e.g. "#0000FF" for blue. |
| lineJoinStyle | constant | Style to use for the line join at vertices of polygons and polylines on an Image. Can be Reporter.JOIN_MITRE, Reporter.JOIN_BEVEL or Reporter.JOIN_ROUND |
| lineStyle | constant | Style to use when drawing lines on an Image. Can be Reporter.LINE_NONE, Reporter.LINE_SOLID, Reporter.LINE_DASH, Reporter.LINE_DOT, Reporter.LINE_DASH_DOT or Reporter.LINE_DASH_DOT_DOT |
| lineWidth | integer | Width to use when drawing lines on an Image value |
| width | integer | Width of the Image |
Detailed DescriptionThe Image class allows you to create, load and save bitmaps. There are various functions available that allow to to draw lines, rectangles, ellipses, text etc on a bitmap. |
Constructornew Image(width[integer], height[integer], backgroundColour (optional)[string])DescriptionCreate a new Image object for creating an image. If only 2 arguments are given they are used as the width and height of the image. The third argument can be used to define the initial background colour (the default is white). |
Width of image
Height of image
Initial background colour for the image (default is white). Can be "none", a valid colour from the X colour database (For Linux users, see /etc/X11/rgb.txt) e.g. "Blue", or #RRGGBB (each of R, G and B is a single hex digit) e.g. "#0000FF" for blue.
ReturnsImage object Return typeImage |
ExampleTo create a new image object 100 pixels wide by 50 pixels high var img = new Image(100, 50);
|
Details of functionsEllipse(x1[integer], y1[integer], x2[integer], y2[integer])DescriptionDraw an ellipse on an image |
X coordinate of start position for ellipse
Y coordinate of start position for ellipse
X coordinate of end position for ellipse
Y coordinate of end position for ellipse
Returnsno return value |
Fill(x[integer], y[integer], tol (optional)[integer])DescriptionFill an area in an image with a colour. |
X coordinate of start position for fill
Y coordinate of start position for fill
Tolerance for colour matching (0-255). Default is 0. When filling a shape if the red, green and blue components are within tol of the colour of pixel (x, y) the pixel will be filled with the current fill colour.
Returnsno return value |
ExampleTo fill an area of image 'idata', starting at point 30, 20 with red: idata.fillColour = "red"; idata.Fill(30, 20);
|
Line(x1[integer], y1[integer], x2[integer], y2[integer])DescriptionDraw a line on an image |
X coordinate of start position for line
Y coordinate of start position for line
X coordinate of end position for line
Y coordinate of end position for line
Returnsno return value |
Load(filename[string])DescriptionLoad an image file (gif, png, bmp or jpeg) |
Imagename you want to load.
Returnsno return value |
ExampleTo load the image file "/data/test/image.jpg" into the image object 'idata' idata.Load("/data/test/image.jpg");
|
PixelCount(colour[string], tol (optional)[integer])DescriptionCount the number of pixels in an image that have a specific colour. |
A valid colour from the X colour database (For Linux users, see /etc/X11/rgb.txt) e.g. "Blue", or #RRGGBB (each of R, G and B is a single hex digit) e.g. "#0000FF" for blue
Tolerance for colour matching (0-255). Default is 0. When looking at pixels if the red, green and blue components are within tol of the colour of pixel (x, y) the pixel will be counted.
ReturnsNumber of pixels (integer) with the colour. Return typeNumber |
ExampleTo count the number of red pixels in image 'idata': var nred = idata.PixelCount("red");
|
Polygon(points[array])DescriptionDraw a polygon on an image. The last point is always connected back to the first point. |
Array of point coordinates
Returnsno return value |
X coordinate of point 1
Y coordinate of point 1
X coordinate of point 2
Y coordinate of point 2
X coordinate of point n
Y coordinate of point n
Returnsno return value |
Polyline(points[array])DescriptionDraw a line with multiple straight segments on an image |
Array of point coordinates
Returnsno return value |
X coordinate of point 1
Y coordinate of point 1
X coordinate of point 2
Y coordinate of point 2
X coordinate of point n
Y coordinate of point n
Returnsno return value |
Rectangle(x1[integer], y1[integer], x2[integer], y2[integer])DescriptionDraw a rectangle on an image |
X coordinate of start position for rectangle
Y coordinate of start position for rectangle
X coordinate of end position for rectangle
Y coordinate of end position for rectangle
Returnsno return value |
Save(filename[string], filetype[constant])DescriptionSave an image to file (png, bmp or jpeg) |
Imagename you want to save.
Type you want to save as. Can be: Image.BMP, Image.JPG or Image.PNG
Returnsno return value |
ExampleTo save the image object 'idata' to file "/data/test/image.jpg" as a jpeg idata.Save("/data/test/image.jpg", Image.JPG);
|
Star(x[integer], y[integer], r[integer])DescriptionDraw a star on an image |
X coordinate of centre of star
Y coordinate of centre of star
Radius of star
Returnsno return value |
ExampleTo draw a blue star with yellow fill, on image 'idata', centred at point 30, 20 with radius 10 idata.lineColour = "blue"; idata.fillColour = "yellow"; idata.Star(30, 20, 10);
|
Text(x[integer], y[integer], text[string])DescriptionDraw text on an image |
X position for text
Y position for text
Text to write on image
Returnsno return value |