CLabels:new


The new method constructs a new instance of a CLabels object. The CLabels class includes properties that control calculation of centroid positions. Various constructor overloads are available to create a new CLabels and initialize the properties.

Syntax

Use the default constructor to creates a default CLabels object with properties initialized to default values. You will need to attach this to a CImageView object:

C = CLabels:new()

C = CLabels:new( CLabels2 )

C = CLabels:new( CImageView )

where

     

    CLabels2 is an existing CLabels object whose properties will be copied to the new CLabels object.

    CImageView is an existing CImageView object containing a CImage that will be attached to the new CLabels object.

    If no arguments are passed, the default constructor creates a default CLabels object.

    C is the new CLables object.

 

If you use a constructor that does not pass a CImageView object, then you must later specify one using Attach method before labels can be drawn on an image.

Examples

Suppose a CImageView V exists and displays 1 or more images. The following script illustrates two forms of the new constructor. Both produce the same result:

L = CLabels:new( V )

-- create a new CLabels L attached to V

x = 192 ; y = 390

-- target coordinates

str = "My label text"

-- label coordinates

I = V:GetImage()

-- I is the current displayed image in V

L:Add( I, x, y str )

-- draw the label on the image

  

The following script does the same thing but uses the 2-step attachment to a CImageView:

L = CLabels:new()

-- create a new CLabels L

x = 192 ; y = 390

-- target coordinates

str = "My label text"

-- label coordinates

L:Attach( V )

-- attach to the CImageView V

I = V:GetImage()

-- I is the current displayed image in V

L:Add( I, x, y str )

-- draw the label on the image

Related Topics

delete

CLabels class