ImageEn, unit iexLayers

TIELineLayer.Curve

TIELineLayer.Curve


Declaration

property Curve: Double;


Description

Specifies the curvature of the line.
The value is a multiplier to increase or decrease the radius of the curve.
1: Creates a curve of an exact half circle.
>1 creates a shallower curve.
<1 creates a bulging curve.

Pass as negative to sweep clockwise.

The allowable range of the curve values is 10 (shallow curve) and 1/40 (huge curve).




Curves should not be used with the following properties:
- RulerMode
- Above and below positions for LabelPosition

Notes:
- The Alt+Up/Down keys can be used to increase/decrease curvature if loKeyboardShortcuts is included in LayerOptions
- If mlEditLayerPoints is included in MouseInteractLayers, then holding down the Alt key and clicking and dragging a line layer will convert it to a curve

Default: 0


Demo

Demo  \Demos\LayerEditing\Layers_Lines\Layers.dpr


Examples

// Make line slightly curved
TIELineLayer( ImageEnView1.CurrentLayer ).Curve := 5;
ImageEnView1.Update();

// Make line have bulging curved
TIELineLayer( ImageEnView1.CurrentLayer ).Curve := 0.5;
ImageEnView1.Update();

// Draw a half circle curving downward (smile)
TIELineLayer( ImageEnView1.CurrentLayer ).Rotate := 0;
TIELineLayer( ImageEnView1.CurrentLayer ).Curve := 1;
ImageEnView1.Update();

// Draw a half circle curving downward (frown)
TIELineLayer( ImageEnView1.CurrentLayer ).Rotate := 0;
TIELineLayer( ImageEnView1.CurrentLayer ).Curve := -1;
ImageEnView1.Update();


// Draw a Smiley Face

// make layer lines thicker
ImageEnView1.LayerDefaults.Values[ IELP_BorderWidth ] := '10';
ImageEnView1.LayerDefaults.Values[ IELP_FillColor ] := 'clWhite';

// LEFT EYE
// Add an ellipse shape layer
ImageEnView1.LayersAdd( iesEllipse, 100, 100, 30, 30 );

// RIGHT EYE
// Add an ellipse shape layer
ImageEnView1.LayersAdd( iesEllipse, 170, 100, 30, 30 );

// SMILE
// Add a line layer
ImageEnView1.LayersAdd( Point( 100, 150 ), Point( 200, 150 ));

// Curve it
TIELineLayer(ImageEnView1.CurrentLayer).Curve := 1;

// Show changes
ImageEnView1.Update();




// Button to decrease curve
procedure Tfmain.btnDecreaseCurveClick(Sender: TObject);
const
  MIN_CURVE = 1/50; // Huge curve
  MAX_CURVE = 8; // Shallow curve
var
  c: Double;
begin
  if ( ImageEnView1.LayersCurrent >= 0 ) and ( ImageEnView1.CurrentLayer.Kind = ielkLine) then
  begin
    c := TIELineLayer(ImageEnView1.CurrentLayer).Curve;
    if c = 0 then
      c := -MAX_CURVE
    else
    if c > 0 then
      c := c * 1.1
    else
      c := c * 0.9;
    if c < -MAX_CURVE then
      c := 0; // Curve to shallow? Disable curve
    TIELineLayer(ImageEnView1.CurrentLayer).Curve := c;
    ImageEnView1.Update();
  end;
end;

// Button to increase curve
procedure Tfmain.btnIncreaseCurveClick(Sender: TObject);
const
  MIN_CURVE = 1/50; // Huge curve
  MAX_CURVE = 8; // Shallow curve
var
  c: Double;
begin
  if ( ImageEnView1.LayersCurrent >= 0 ) and ( ImageEnView1.CurrentLayer.Kind = ielkLine) then
  begin
    c := TIELineLayer(ImageEnView1.CurrentLayer).Curve;
    if c = 0 then
      c := MAX_CURVE
    else
    if c < 0 then
      c := c * 1.1
    else
      c := c * 0.9;
    if c > MAX_CURVE then
      c := 0; // Curve to shallow? Disable curve
    TIELineLayer(ImageEnView1.CurrentLayer).Curve := c;
    ImageEnView1.Update();
  end;
end;

// Add a curved arrow line layer
ImageEnView1.LayersAdd( Point( 100, 100), Point( 300, 100 ));
lineLayer := TIELineLayer( ImageEnView1.CurrentLayer );
lineLayer.StartShape := ieesArrow;
lineLayer.EndShape := ieesDot;
lineLayer.Curve := -1.0;
ImageEnView1.Update();