2

Hi, all: I'd like to add one annotation in the image and use the top right corner as the positioning anchor. Currently, I know how to use the top left corner. But I tried different commands and failed to use top right corner. Does anyone know how to do it?

Regards

Chen ZX

ChenZX
  • 293
  • 4

1 Answers1

2

The best way to arrange annotations is to use the three commands:

  • void ComponentTransformCoordinates( Component comp, Number off_x, Number off_y, Number scale_x, Number scale_y )

  • void ComponentSetControlPoint( Component comp, Number loc, Number x, Number y, Number restrict_style )

  • void ComponentPositionAroundPoint( Component comp, Number new_x, Number new_y, Number rel_x, Number rel_y, Boolean horz, Boolean vert )

For your specific question, you would want to use the 3nd command. You specify the point of the annotation using rel_x and rel_y. (1,0) would be the top-right corner. Then you specify the coordinates to which this point should be moved as new_x and new_y. The two remaining Boolean parameters are used to limit the movement to horizontal or vertical only.

See this example:

image test := RealImage("Test",4,1000,1000) = icol
test.ShowImage()
imageDisplay disp = test.ImageGetImageDisplay(0)
component rectAnno = NewBoxAnnotation(200,200,800,800)
rectAnno.ComponentSetBackgroundColor(1,0,0)
rectAnno.ComponentSetForegroundColor(0,1,0)
rectAnno.ComponentSetDrawingMode(1)
rectAnno.ComponentSetFillMode(1)
disp.ComponentAddChildAtEnd( rectAnno )

// Example of shifting the top-right corner of the annotation
// to the top-right corner of the image and offset -5/-5
OKDialog("Now Shift")
number TRUE = 1
number FALSE = 0
rectAnno.ComponentPositionAroundPoint(995,5,1,0,TRUE, TRUE)

The F1 help documentation has another useful example script here: Help

The meaning of the location control point is found in the F1 documentation here: Control points

BmyGuest
  • 6,331
  • 1
  • 21
  • 35