DrawButton

function DrawButton(img: TImage32; const pt: TPointD; size: double; color: TColor32 = clNone32; buttonShape: TButtonShape = bsRound; buttonAttributes: TButtonAttributes = [baShadow, ba3D]): TPathD;


Buttons are very useful things. They can mark points of interest or used as dynamic controls in graphic design. DrawButton simplifies button drawing (shape, sizing, fill, outline, shadow and 3D effect) into a single procedure.

This function returns the path that defines the button outline.


  uses Img32, Img32.Fmt.PNG,
    Img32.Draw, Img32.Extra;
  ...
  var
    i,j: integer;
    img: TImage32;
    path: TPathD;
  begin
    img := TImage32.Create(256, 256);
    
    //draw round uncolored buttons
    j := 15;
    for i := 3 to 12 do
    begin
      DrawButton(img, PointD(j, 100), i*2,
        clNone32, bsRound);
      inc(j, 10 + i*2);
    end;

    //and draw some colored square buttons
    j := 15;
    for i := 3 to 12 do
    begin
      DrawButton(img, PointD(j, 180), i*2,
        AdjustHue(clRed32, (i-3)*10), bsSquare);
      inc(j, 10 + i*2);
    end;

    img.SaveToFile('buttons.png');
    img.Free;
  end;
    

See Also

TButtonAttributes, TButtonShape, TLayeredImage32.GetMergedImage, TPathD