找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 302|回复: 3

soui中实现镜像文本

[复制链接]
  • TA的每日心情

    昨天 08:23
  • 签到天数: 227 天

    [LV.7]常住居民III

    2

    主题

    0

    回帖

    3840

    积分

    论坛元老

    积分
    3840
    发表于 2024-8-6 15:51:50 | 显示全部楼层 |阅读模式
    本帖最后由 ceffans 于 2024-8-6 15:56 编辑

    复制代码
    1. void ContainerBox::OnPaint(IRenderTarget* pRT)
    2. {
    3.         CRect rcClient = GetClientRect();
    4.         CPoint ptCenter = rcClient.CenterPoint();

    5.         SStringW sstrFontFormat = L"face:宋体,bold:0,italic:0,underline:0,strike:0,size:30";
    6.         SOUI::IFontPtr pFont = SFontPool::GetFont(sstrFontFormat, GetScale());
    7.         pRT->SelectObject(pFont);

    8.         //测试镜像
    9.         CRect rcTemp;
    10.         rcTemp.left = ptCenter.x - 100;
    11.         rcTemp.right = ptCenter.x + 100;
    12.         rcTemp.top = ptCenter.y - 50;
    13.         rcTemp.bottom = ptCenter.y + 50;

    14.         SStringW sstrTxt = L"1234567890A";
    15.         {//原始数据
    16.                 {//绘制个背景色便于观察
    17.                         COLORREF clrBkgnd = GETCOLOR(L"RGB(0,255,0)");
    18.                         CAutoRefPtr<IBrush> brush, oldbrush;
    19.                         pRT->CreateSolidColorBrush(clrBkgnd, &brush);
    20.                         pRT->SelectObject(brush, (IRenderObj**)&oldbrush);
    21.                         pRT->FillRectangle(&rcTemp);
    22.                         pRT->SelectObject(oldbrush, NULL);
    23.                 }
    24.                 pRT->DrawText(sstrTxt, -1, (LPRECT)rcTemp, DT_CENTER | DT_VCENTER | DT_SINGLELINE | DT_NOPREFIX);
    25.         }

    26.         {//左镜像
    27.                 CRect rcMirror(rcTemp);
    28.                 rcMirror.left = rcTemp.right;
    29.                 rcMirror.right = rcMirror.left + rcTemp.Width();

    30.                 SMatrix matrix;
    31.                 matrix.setScale2(-1, 1, ptCenter.x, ptCenter.y);
    32.                 pRT->SetTransform(matrix.fMat, NULL);
    33.                 pRT->DrawText(sstrTxt, -1, (LPRECT)rcMirror, DT_CENTER | DT_VCENTER | DT_SINGLELINE | DT_NOPREFIX);
    34.                 pRT->SetTransform(SMatrix().fMat, NULL);
    35.         }

    36.         {//右镜像
    37.                 CRect rcMirror(rcTemp);
    38.                 rcMirror.left = rcTemp.left - rcTemp.Width();
    39.                 rcMirror.right = rcTemp.left;

    40.                 SMatrix matrix;
    41.                 matrix.setScale2(-1, 1, ptCenter.x, ptCenter.y);
    42.                 pRT->SetTransform(matrix.fMat, NULL);
    43.                 pRT->DrawText(sstrTxt, -1, (LPRECT)rcMirror, DT_CENTER | DT_VCENTER | DT_SINGLELINE | DT_NOPREFIX);
    44.                 pRT->SetTransform(SMatrix().fMat, NULL);
    45.         }

    46.         {//上镜像
    47.                 CRect rcMirror(rcTemp);
    48.                 rcMirror.top = rcTemp.bottom;
    49.                 rcMirror.bottom = rcMirror.top + rcTemp.Height();

    50.                 SMatrix matrix;
    51.                 matrix.setScale2(1, -1, ptCenter.x, ptCenter.y);
    52.                 pRT->SetTransform(matrix.fMat, NULL);
    53.                 pRT->DrawText(sstrTxt, -1, (LPRECT)rcMirror, DT_CENTER | DT_VCENTER | DT_SINGLELINE | DT_NOPREFIX);
    54.                 pRT->SetTransform(SMatrix().fMat, NULL);
    55.         }

    56.         {//下镜像
    57.                 CRect rcMirror(rcTemp);
    58.                 rcMirror.bottom = rcTemp.top;
    59.                 rcMirror.top = rcTemp.top - rcTemp.Height();

    60.                 SMatrix matrix;
    61.                 matrix.setScale2(1, -1, ptCenter.x, ptCenter.y);
    62.                 pRT->SetTransform(matrix.fMat, NULL);
    63.                 pRT->DrawText(sstrTxt, -1, (LPRECT)rcMirror, DT_CENTER | DT_VCENTER | DT_SINGLELINE | DT_NOPREFIX);
    64.                 pRT->SetTransform(SMatrix().fMat, NULL);
    65.         }
    66. }
    复制代码

    镜像文本.png
  • TA的每日心情
    开心
    2025-6-8 10:03
  • 签到天数: 58 天

    [LV.5]常住居民I

    69

    主题

    12

    回帖

    1605

    积分

    管理员

    积分
    1605
    发表于 2024-8-7 10:50:27 | 显示全部楼层
    QQ图片20240807104935.jpg
  • TA的每日心情
    开心
    2025-6-8 10:03
  • 签到天数: 58 天

    [LV.5]常住居民I

    69

    主题

    12

    回帖

    1605

    积分

    管理员

    积分
    1605
    发表于 2024-8-8 11:34:41 | 显示全部楼层
    微信图片_20240808113356.png
  • TA的每日心情
    开心
    2025-6-8 10:03
  • 签到天数: 58 天

    [LV.5]常住居民I

    69

    主题

    12

    回帖

    1605

    积分

    管理员

    积分
    1605
    发表于 2024-8-20 20:47:11 | 显示全部楼层
    QQ图片20240820204609.jpg
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    Archiver|手机版|小黑屋|SOUI官方论坛

    GMT+8, 2025-6-24 07:05 , Processed in 0.059953 second(s), 24 queries .

    Powered by Discuz! X3.5

    © 2001-2025 Discuz! Team.

    快速回复 返回顶部 返回列表