How to rotate a RectangleShape in VB.net?

孤者浪人 提交于 2019-12-25 02:25:14

问题


Is it possible to rotate a rectangle shape in VB.net? Code to my rectangle shape is this

baseDice.Parent = shapeContainer
baseDice.CornerRadius = 5
baseDice.Height = 50
baseDice.Width = 50
baseDice.BackColor = Color.Blue
baseDice.BackStyle = BackStyle.Opaque
baseDice.Left = 50
baseDice.Top = 50
baseDice.Name = "baseDice"

baseDice is an object of Microsoft.VisualBasic.PowerPacks.RecntangleShape


回答1:


Use the VB Class Matrix, here's an example

Dim myPen As New Pen(Color.Blue, 1)
Dim myPen2 As New Pen(Color.Red, 1)
e.Graphics.DrawRectangle(myPen, 150, 50, 200, 100)
Dim myMatrix As New Matrix()
myMatrix.Rotate(45, MatrixOrder.Append)
e.Graphics.Transform = myMatrix
e.Graphics.DrawRectangle(myPen2, 150, 50, 200, 100)

In the Matrix.Rotate you give it the angle and what the type of transform is (you can use Append to constantly rotate by an angle)

e is of PaintEventArgs type



来源:https://stackoverflow.com/questions/6921585/how-to-rotate-a-rectangleshape-in-vb-net

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!