Tipp 0038 Geometrische Figuren zeichnen
Autor/Einsender:
Datum:
  Michael Werner
17.04.2004
Entwicklungsumgebung:   VB.Net 2002
Framework:   1.0
Dieser Tipp demonstriert die Grafikmethoden der Klasse Graphic, wie Linien, Kreise, Ellipsen, Rechtecke, Dreiecke, Polygone, Kreissegmente usw. gezeichnet werden können.
 
Public Class Form1
  Inherits System.Windows.Forms.Form
Vom Windows Form Designer generierter Code
  Dim g As Graphics

  Private Sub Form1_Load(ByVal sender As System.Object, _
          ByVal e As System.EventArgs) Handles MyBase.Load
    g = CreateGraphics()
  End Sub

  Private Sub Button1_Click(ByVal sender As System.Object, _
          ByVal e As System.EventArgs) Handles Button1.Click
    Dim oBrush As New SolidBrush(Color.PaleGoldenrod)
    g.FillEllipse(oBrush, ClientRectangle)
  End Sub

  Private Sub Button2_Click(ByVal sender As System.Object, _
          ByVal e As System.EventArgs) Handles Button2.Click
    Dim oPoints As Point() = { _
          New Point(220, 20), _
          New Point(290, 150), _
          New Point(370, 130), _
          New Point(400, 50), _
          New Point(250, 10)}
    Dim oPen3 As New Pen(Color.CornflowerBlue, 1)
    g.DrawPolygon(oPen3, oPoints)
  End Sub

  Private Sub Button3_Click(ByVal sender As System.Object, _
          ByVal e As System.EventArgs) Handles Button3.Click
    Dim oRect As New Rectangle(20, 20, 180, 70)
    Dim oPen1 As New Pen(Color.Blue, 1)
    g.DrawRectangle(oPen1, oRect)
  End Sub

  Private Sub Button4_Click(ByVal sender As System.Object, _
          ByVal e As System.EventArgs) Handles Button4.Click
    Dim oPen2 As New Pen(Color.Red, 1)
    g.DrawPie(oPen2, 20, 70, 100, 100, 0, 90)
  End Sub

  Private Sub Button5_Click(ByVal sender As System.Object, _
          ByVal e As System.EventArgs) Handles Button5.Click
    Dim oRect1 As New Rectangle(150, 150, 100, 100)
    Dim oPen4 As New Pen(Color.DarkGoldenrod, 1)
    g.DrawEllipse(oPen4, oRect1)
  End Sub

  Private Sub Button6_Click(ByVal sender As System.Object, _
          ByVal e As System.EventArgs) Handles Button6.Click
    Dim oRect2 As New Rectangle(110, 110, 110, 60)
    Dim oPen5 As New Pen(Color.DarkCyan, 1)
    g.DrawEllipse(oPen5, oRect2)
  End Sub

  Private Sub Button7_Click(ByVal sender As System.Object, _
          ByVal e As System.EventArgs) Handles Button7.Click
    Dim oPen6 As New Pen(Color.CadetBlue, 3)
    g.DrawLine(oPen6, 20, 20, 180, 70)
  End Sub

  Private Sub Button8_Click(ByVal sender As System.Object, _
          ByVal e As System.EventArgs) Handles Button8.Click
    Dim oPen7 As New Pen(Color.Red, 1)
    g.DrawLine(oPen7, 10, 10, 200, 200)
  End Sub

  Private Sub Button9_Click(ByVal sender As System.Object, _
          ByVal e As System.EventArgs) Handles Button9.Click
    Dim oPointsDreieck As Point() = { _
          New Point(120, 20), _
          New Point(200, 150), _
          New Point(370, 130)}
    Dim oPen8 As New Pen(Color.DarkRed, 1)
    g.DrawPolygon(oPen8, oPointsDreieck)
  End Sub

  Private Sub Button10_Click(ByVal sender As System.Object, _
          ByVal e As System.EventArgs) Handles Button10.Click
    Dim oBrush As New SolidBrush(Color.OldLace)
    g.FillRectangle(oBrush, ClientRectangle)
  End Sub

  Private Sub Button11_Click(ByVal sender As System.Object, _
          ByVal e As System.EventArgs) Handles Button11.Click
        Me.Close()
  End Sub
End Class
 
Weitere Links zum Thema
Ampel zeichnen
Figuren zeichnen und rotieren

Windows-Version
98/SE
ME
NT
2000
XP
Vista
Win 7


Download  (6,9 kB) Downloads bisher: [ 1448 ]

Vorheriger Tipp Zum Seitenanfang Nächster Tipp

Startseite | Tipps | Projekte | Tutorials | Bücherecke | VB-/VBA-Tipps | API-Referenz | Komponenten | VB.Net-Forum | VB/VBA-Forum | DirectX-Forum | Foren-Archiv | DirectX | Chat | Spielplatz | Links | Suchen | Stichwortverzeichnis | Feedback | Impressum

Seite empfehlen Bug-Report
Letzte Aktualisierung: Sonntag, 10. Januar 2012