文字阴影

<head>
    <meta charset="UTF-8" />
    <title>Document</title>
    <style type="text/css">
        p{
            font-size: 80px;
            font-family: "微软雅黑";
            font-weight: bold;
            text-shadow:5px 5px 10px green,10px 10px 10px red,20px 20px 10px yellow;
        }
    </style>
</head>
<body>
    <p>文字阴影</p>
</body>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要在Delphi中实现GDI文字阴影,可以使用Windows API中的阴影效果函数来实现。以下是一个示例代码,演示如何在Delphi中使用GDI函数来实现文字阴影效果: ```delphi unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs; type TForm1 = class(TForm) procedure FormPaint(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.FormPaint(Sender: TObject); var hFont, hOldFont: HFONT; dc: HDC; lf: TLogFont; text: string; rect: TRect; begin // 设置字体样式和文本内容 lf.lfHeight := 24; lf.lfWidth := 0; lf.lfEscapement := 0; lf.lfOrientation := 0; lf.lfWeight := FW_BOLD; lf.lfItalic := 0; lf.lfUnderline := 0; lf.lfStrikeOut := 0; lf.lfCharSet := DEFAULT_CHARSET; lf.lfOutPrecision := OUT_DEFAULT_PRECIS; lf.lfClipPrecision := CLIP_DEFAULT_PRECIS; lf.lfQuality := DEFAULT_QUALITY; lf.lfPitchAndFamily := DEFAULT_PITCH or FF_DONTCARE; StrCopy(lf.lfFaceName, 'Arial'); hFont := CreateFontIndirect(lf); text := 'Hello, World!'; // 获取设备上下文和文本矩形 dc := GetDC(Handle); GetClientRect(Handle, rect); // 设置文字阴影效果 SetTextColor(dc, clGray); hOldFont := SelectObject(dc, hFont); SetBkMode(dc, TRANSPARENT); SetTextAlign(dc, TA_CENTER); // 绘制文字阴影 TextOut(dc, rect.Right div 2 + 2, rect.Bottom div 2 + 2, PChar(text), Length(text)); // 设置文字颜色和绘制文字 SetTextColor(dc, clBlack); TextOut(dc, rect.Right div 2, rect.Bottom div 2, PChar(text), Length(text)); // 恢复设备上下文状态 SelectObject(dc, hOldFont); ReleaseDC(Handle, dc); DeleteObject(hFont); end; end. ``` 在上面的示例代码中,我们使用CreateFontIndirect函数创建一个指定字体样式的字体句柄,然后使用TextOut函数在设备上下文中绘制文字。在绘制文字前,我们设置文字的颜色为灰色,并在绘制文字前先绘制一次阴影效果,然后再使用黑色绘制一次文字。 需要注意的是,为了保证文字阴影效果效果,我们在绘制文字前,需要先将背景模式设置为TRANSPARENT,这样才能使文字阴影文字本身不会重叠。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值