是否可以更改虚线的大小?

发布于 2024-09-07 15:35:33 字数 217 浏览 6 评论 0原文

我在 TImage Canvas 上画一条虚线,发现虚线的大小对于绘图区域来说太大了。有没有办法改变画布上绘制的虚线的大小?
这就是我为了能够绘制虚线所做的事情。

Canvas.Pen.Style := psDash;
Canvas.Polyline(myPoints);

我没有找到任何可以改变破折号大小/长度的笔属性。

谢谢

I am drawing a dashed line on the TImage Canvas and found out that the size of dashes is way too big for the drawing area. Is there a way to change the size of dashes of lines drawn on canvas?
This is what i do to be able to draw dashed lines.

Canvas.Pen.Style := psDash;
Canvas.Polyline(myPoints);

And i didn't find any Pen property which could change the dash size/length.

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

一指流沙 2024-09-14 15:35:33

根据 http://docwiki.embarcadero.com/VCL/e/ index.php/Graphics.TPenStyle 您可以使用 psUserStyle

ExtCreatePen 的文档位于 http://msdn.microsoft.com/en-us/library/dd162705(VS.85).aspx

这是我对 ExtCreatePen 如何与笔:

const
  NumberOfSections = 8;
  LineLengths: array[0..NumberOfSections-1] of DWORD =
    (20, 15, 14, 17, 14, 8, 16, 9);
var
  logBrush: TLogBrush;
begin

  logBrush.lbStyle := BS_SOLID;
  logBrush.lbColor := DIB_RGB_COLORS;
  logBrush.lbHatch := HS_BDIAGONAL; // ignored

  Canvas.Pen.Handle := ExtCreatePen(PS_GEOMETRIC or PS_USERSTYLE or PS_ENDCAP_ROUND or PS_JOIN_BEVEL,
                      4, logBrush, NumberOfSections, @LineLengths[0]);
  // now Canvas.Pen.Style = psUserStyle

  Canvas.Polyline([Point(0,0), Point(100,100), Point(200, 100)]);

end;

According to http://docwiki.embarcadero.com/VCL/e/index.php/Graphics.TPenStyle you can use psUserStyle

The docs for ExtCreatePen are at http://msdn.microsoft.com/en-us/library/dd162705(VS.85).aspx

Here's my interpretation of how ExtCreatePen is meant to be used in combination with TPen:

const
  NumberOfSections = 8;
  LineLengths: array[0..NumberOfSections-1] of DWORD =
    (20, 15, 14, 17, 14, 8, 16, 9);
var
  logBrush: TLogBrush;
begin

  logBrush.lbStyle := BS_SOLID;
  logBrush.lbColor := DIB_RGB_COLORS;
  logBrush.lbHatch := HS_BDIAGONAL; // ignored

  Canvas.Pen.Handle := ExtCreatePen(PS_GEOMETRIC or PS_USERSTYLE or PS_ENDCAP_ROUND or PS_JOIN_BEVEL,
                      4, logBrush, NumberOfSections, @LineLengths[0]);
  // now Canvas.Pen.Style = psUserStyle

  Canvas.Polyline([Point(0,0), Point(100,100), Point(200, 100)]);

end;
偏爱自由 2024-09-14 15:35:33

我不知道,但是,Polyline() 的实现是哪个?当您按住 Control 键并单击它时,您会看到哪个代码?是否可以使用属性公开变量?如果是这样,您可以设置它,否则 - 如果它是硬编码的 - 您将看到它,并且知道您不能。

I don't know, but, which is the implementation of Polyline()? When you control+click it, which code do you see? Is it using an property-exposed variable may be? If so, you can set it, otherwise -if it is hardcoded- you will see it, and know that you can't.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文