[英]What is the equivalent to Rectangle.Inflate() using a GraphicsPath?
我正在開發WindowsForms應用程序,需要突出顯示一些用圖形路徑定義的圖形。
using Drawing.Drawing2D
除了GraphicsPath
是否與Rectangle.Inflate()
類似?
我只需要在x和y中膨脹相同的值。
提前致謝。
如果您希望由GraphicsPath
表示的GraphicsPath
看起來更大 ,那么我個人將使用圖形轉換:
using (Graphics graphics = /* ... */)
{
var matrix = new Matrix();
matrix.Translate( /* ... */ ); // put the mid-point of the figure here
matrix.Scale(1.5f, 1.5f); // makes it 50% bigger
matrix.Translate( /* ... */ ); // put the same mid-point here, but negative
graphics.Transform = matrix;
graphics.FillPath( /* ... */ ); // or DrawPath
// Use this to reset the transform if you still need the Graphics object
graphics.Transform = new Matrix();
}
好吧,這里有GraphicsPath.Widen
,但是和Rectangle.Inflate
不太一樣。
基本上,它使用指定的筆繪制GraphicsPath
的輪廓 ,然后返回一個代表由此繪制區域的GraphicsPath
。
如果只想在屏幕上繪制加寬的圖形,則可以始終繪制兩者:首先是“加寬”路徑,然后是原始路徑(用於“填充”)。 但是話又說回來,您可能只用同一支筆繪制了原始路徑的輪廓...
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.