GdiPlus[7]: IGPSolidBrush、IGPHatchBrush


IGPSolidBrush(实心画刷)只是在 IGPBrush 的基础上增加了一个可读写的 IGPSolidBrush.Color 属性.

IGPHatchBrush(阴影画刷)有三个只读属性: 阴影样式、前景色、背景色; 它们也刚好是 Create 方法的参数.

Create 也可只有前两个参数, 此时背景色默认为不透明的黑色.

下面的例子展示了阴影画刷的所有阴影样式, 效果图如下:

26153227_fZTP.png

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs;

type
  TForm1 = class(TForm)
    procedure FormPaint(Sender: TObject);
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

uses GdiPlus;

procedure TForm1.FormPaint(Sender: TObject);
var
  Graphics: IGPGraphics;
  Brush: IGPHatchBrush;
  ForeColor, BackColor: TGPColor;
  Rect: TGPRect;
  i: Integer;
begin
  Graphics := TGPGraphics.Create(Handle);
  Rect.Initialize(10, 10, 100, 60);
  ForeColor := $FFFF0000;
  BackColor := $FFFFFF00;

  Graphics.Clear($FFFFFFFF);
  for i := 0 to 52 do
  begin
    Brush := TGPHatchBrush.Create(TGPHatchStyle(i), ForeColor, BackColor);
    Graphics.FillRectangle(Brush, Rect);
    Graphics.DrawString(IntToStr(i),
                        TGPFont.Create(Canvas.Handle),
                        TGPPointF.Create(0, 0),
                        TGPSolidBrush.Create($FF000000));

    Graphics.TranslateTransform(0, Rect.Height * 1.2);
    if Graphics.Transform.OffsetY > ClientHeight - Rect.Height - Rect.Y then
    begin
      Graphics.TranslateTransform(Rect.X * 1.5 + Rect.Width, -Graphics.Transform.OffsetY);
    end;
  end;
end;

end.

 
 
 
 
 

 

 

  

转载于:https://my.oschina.net/hermer/blog/319559

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值