Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

bend gdi+ rectangle into an arc

Status
Not open for further replies.

reg1965

Programmer
Mar 12, 2005
5
0
0
GB
hi
im building a clock app. i want to draw roman numerals around the clock
face. i know how to rotate a rectangle containing text (ie XII, I etc)
around. But i would like the rectangle containing text to arc inwards so the
longer numerals (ie VIII) curve with the clock face.
I think this may involve the matrix class but im not sure.
any help would be most appreciated.
Steve
 
I am guessing your answer is in the graphicspath.warp method

But havn't really played with it much..

Rob
PS post back if you get it working :)

 
Here's some code used for a Compass. You can adapt as needed.

Code:
Public Enum Direction As Integer
  N = 0
  NE = 1
  E = 2
  SE = 3
  S = 4
  SW = 5
  W = 6
  NW = 7
End Enum

Protected Overrides Sub OnPaint(ByVal e As   System.Windows.Forms.PaintEventArgs)
e.Graphics.Clear(Me.BackColor)
  Dim bounds As Rectangle
  Dim g As Graphics
  Dim rotation As Single = 0
  g = e.Graphics
  bounds = New Rectangle(50, 50, Me.Width - 100, Me.Height - 100)
  Dim rect As System.Drawing.RectangleF
  g.DrawEllipse(Pens.Black, bounds)
  Dim myMatrix As Drawing2D.Matrix
  Dim sf As New StringFormat(StringFormatFlags.NoWrap)
  sf.Alignment = StringAlignment.Center
  myMatrix = g.Transform()
  rect = New System.Drawing.RectangleF(bounds.X, bounds.Y,   bounds.Width, bounds.Height)
For i As Integer = 0 To 7
  If i > 0 Then
    myMatrix.RotateAt(45, New PointF(Me.Width / 2, Me.Height / 2),   Drawing.Drawing2D.MatrixOrder.Append)
  g.Transform = myMatrix
  End If
  Dim directionString As String
  directionString = System.Enum.GetName(GetType(Direction), i)
  g.DrawString(directionString, New Font("Arial", 12, FontStyle.Bold),   Brushes.Black, rect, sf)
Next
End Sub

Dale
 
Oh yeah, when you change your enumerator to have 12 digits, you'll need to change this line:
Code:
myMatrix.RotateAt(45, New PointF(Me.Width / 2, Me.Height / 2),   Drawing.Drawing2D.MatrixOrder.Append)

change the 45 to 30 to decrease the angle of rotation.

Dale
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top