gpt4 book ai didi

c# - 画线时 Pen.Alignment 不起作用

转载 作者:太空宇宙 更新时间:2023-11-03 15:46:18 24 4
gpt4 key购买 nike

我想画粗线和细线。粗线应位于理论线内。所以我将笔对齐设置如下。

Pen blackPen = new Pen(Color.FromArgb(255, 0, 0, 0), 1);
Pen greenPen = new Pen(Color.FromArgb(255, 0, 255, 0), 10);

greenPen.Alignment = PenAlignment.Inset;

e.Graphics.DrawLine(greenPen, 10, 100, 100, 50);
e.Graphics.DrawLine(blackPen, 10, 100, 100, 50);

但是这个想法并没有实现。做同样的事情还有更好的主意吗???

最佳答案

Pen.Alignment部分实现:

This property determines how the Pen draws closed curves and polygons. The PenAlignment enumeration specifies five values; however, only two values—Center and Inset—will change the appearance of a drawn line. Center is the default value for this property and specifies that the width of the pen is centered on the outline of the curve or polygon. A value of Inset for this property specifies that the width of the pen is inside the outline of the curve or polygon. The other three values, Right, Left, and Outset, will result in a pen that is centered.

因此,Inset 仅适用于多边形或曲线(例如 Graphics.DrawRectangle)。

关于c# - 画线时 Pen.Alignment 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27964001/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com