■99232 / inTopicNo.2) |
Re[1]: 四角形で内側・外側の設定 |
□投稿者/ 魔界の仮面弁士 (3296回)-(2022/02/22(Tue) 20:07:42)
|
■No99231 (パワー さん) に返信 > 座標の内側あるいは外側に接する四角形にしたいのですが、 > そのような設定はありますか?
Pen の Alignment プロパティで、Center (既定値) と Inset (内側に描画)を切り替えられます。
https://docs.microsoft.com/en-us/dotnet/api/system.drawing.pen.alignment?view=netframework-4.8
ただし上記にもあるように、Alignment プロパティの他 3 種の設定(Left, Right, Outset)は Center 指定と同義です。
Public Class Form1 Private ThickPen As Pen Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load ThickPen = New Pen(Brushes.Magenta, 10.0F) ComboBox1.DataSource = System.Enum.GetValues(GetType(System.Drawing.Drawing2D.PenAlignment)) End Sub Private Sub Form1_FormClosed(sender As Object, e As FormClosedEventArgs) Handles MyBase.FormClosed ThickPen.Dispose() End Sub Private Sub ComboBox1_SelectionChangeCommitted(sender As Object, e As EventArgs) Handles ComboBox1.SelectionChangeCommitted ThickPen.Alignment = DirectCast(ComboBox1.SelectedItem, System.Drawing.Drawing2D.PenAlignment) PictureBox1.Invalidate() End Sub
Private Sub PictureBox1_Paint(sender As Object, e As PaintEventArgs) Handles PictureBox1.Paint e.Graphics.DrawRectangle(ThickPen, 20, 20, 180, 180) e.Graphics.DrawRectangle(Pens.Blue, 20, 20, 180, 180) End Sub End Class
|
|