zoukankan      html  css  js  c++  java
  • GdiPlus[7]: IGPSolidBrush、IGPHatchBrush


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

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

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

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



    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.
    
  • 相关阅读:
    备忘录 | ‘神器’在手,新世界大门我有
    1001种玩法 | HotswapAgent:支持无限次重定义运行时类与资源
    面面观 | CentOS install etcd 测试
    控制台、终端、虚拟终端和伪终端
    KMP算法,BoyerMoore算法
    qemu kvm 虚拟化
    web端log4net输出错误日志到mysql
    JQuery调用WCF服务,部署在iis
    首篇
    微信支付接口
  • 原文地址:https://www.cnblogs.com/del/p/1623166.html
Copyright © 2011-2022 走看看