Basic Drawing Primitives¶

The following example introduces how an image can be created in OEDepict TK to generate a single black line across an image:

1. Create an OEImage object with a specific width and height.

2. Specify the two end points of the line with OE2DPoint objects.

3. Draw the line with the OEImage.DrawLine method using the OEDepict.OEBlackPen to specify the graphical properties of the line.

4. Write the image into a file by calling the OEWriteImage function.

The OEImage class is implemented as a container of drawing commands. When a method such as OEImage.DrawLine is called, rather than immediately drawing the line specified by the parameters, a line drawing operation is created in the OEImage class for later execution.

Listing 1: Example of line drawing

public class DrawLine {
public static void main(String argv[]) {
int width  = 100;
int height = 100;
// Create image
OEImage image = new OEImage(width, height);

// Draw line with default pen
image.DrawLine(new OE2DPoint(10.0, 10.0),
new OE2DPoint(90.0, 90.0),
oedepict.getOEBlackPen());

// Write image to SVG file
oedepict.OEWriteImage("DrawLine.svg", image);
}
}


The image created by Listing 1 is shown in Figure: Example of line drawing.

Example of line drawing

Coordinate System¶

The coordinate system used in OEDepict TK has the origin (x=0.0, y=0.0) at the top left with the x-axis pointing to the right and the y-axis pointing down.

2D coordinate system (X = horizontal, Y = vertical)

Basic Shapes¶

OEDepict TK supports drawing the following basic shapes:

Image File Formats¶

OEDepict TK natively supports a variety of graphical file formats. OEWriteImage automatically detects the desired file format from the file name passed to the function. The following table lists the file formats natively supported in OEDepict TK and their associated file extensions:

Graphics File Format Format Type File Extension
PNG (Portable Network Graphics) raster image .png
SVG (Scalable Vector Graphics) vector image .svg
bare SVG (with no header) vector image .bsvg
Postscript vector image .ps
Encapsulated PostScript vector image .eps
PDF (Portable Document Format) vector image .pdf

The OEIsRegisteredImageFile function can be used to query whether a given file extension is supported by OEDepict TK. All the supported file formats can be queried using the OEGetSupportedImageFileExtensions function.