Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Dreieck mit Seitenbezeichnung+VB.net

Empfohlene Antworten

Veröffentlicht

Nabend zusammen,

steh mal wieder vor einem Problem :(

Ich soll ein Dreieck zeichnen, das mit dem Mauszeiger an der Ecke B beliebig bewegt werden kann... so bis dahin kein Problem.

Mein Problem liegt im Darstellen der Seitenbezeichnungen. Bei der Seite "b" ging das recht leicht, Seite "c" sieht auch akzeptabel aus, jedoch etwas zu weit von der Seite entfernt aber die Seite "a" macht mir extrem zu schaffen. Ich kann diese zwar einigermaßen in Positionen bringen doch sie "klebt" nicht direkt an der Seite, wie es die anderen Bezeichnungen machen.

Vielleicht wisst Ihr ja weiter... vielen Dank schon mal im Voraus.

Gute Nacht:old

Hier mal der Code und Screenshots:


Public Class Form1


    Private Sub Form1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Click

        Invalidate()

    End Sub


    Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove


        'Deklarationen der Variablen

        Dim g As Graphics = CreateGraphics()

        Dim p As Pen = New Pen(backcolor, 0.5)

        Dim br As New SolidBrush(Color.Black)

        Dim fn As New Font("Arial", 10)

        Dim ptMitte As New PointF(CSng(ClientSize.Width / 2), CSng(ClientSize.Height / 2))

        Static ptMaus As New PointF


        Dim rectA As New RectangleF(0.5 * (ptMitte.X + ptMaus.Y + ptMaus.X), ptMaus.Y, 60, 60)

        Dim rectB As New RectangleF(0.5 * (ptMitte.X + ptMaus.X), ptMitte.Y, 120, 120)

        Dim rectC As New RectangleF(0.5 * (ptMitte.X + ptMaus.X), ptMaus.Y, 120, 120)



        'Löschendes Zeichnen

        g.DrawLine(p, ptMitte, ptMaus)      'Strecke AB

        g.DrawLine(p, ptMitte, New PointF(ptMaus.X, ptMitte.Y)) 'Strecke AC

        g.DrawLine(p, ptMaus, New PointF(ptMaus.X, ptMitte.X))  'Strecke BC


        g.DrawString("a", fn, br, rectA)

        g.DrawString("b", fn, br, rectB)

        g.DrawString("c", fn, br, rectC)


        'g.DrawRectangle(p, 0, 0, ClientSize.Width, ClientSize.Height)

        g.FillRectangle(New SolidBrush(BackColor), 0, 0, ClientSize.Width, ClientSize.Height)



        'Zeichnen

        g.drawstring("a", fn, br, rectA)

        g.DrawString("b", fn, br, rectB)

        g.DrawString("c", fn, br, rectC)

        p.Color = Color.Black

        ptMaus.X = CSng(e.X)

        ptMaus.Y = CSng(e.Y)


        g.DrawLine(p, ptMitte, ptMaus)      'Strecke AB 

        g.DrawString("c", fn, br, rectC)


        p.Color = Color.Black

        g.DrawLine(p, ptMaus, New PointF(ptMaus.X, ptMitte.Y)) 'Strecke AC

        g.DrawString("b", fn, br, rectB)


        p.Color = Color.Black

        g.DrawLine(p, ptMitte, New PointF(ptMaus.X, ptMitte.Y))  'Srecke BC

        g.drawString("a", fn, br, rectA)


    End Sub

End Class


dreiceck01.th.jpg

dreiceck02.th.jpg

dreiceck03.th.jpg

dreiceck04.th.jpg

  • 3 Wochen später...

Ich würde mit Vektoren arbeiten, den Mittelpunkt der Strecken finden und da dann die Bezeichung hinschreiben.

mittelPunktx = 0.5 * (x1 + x2);

mittelPunkty = 0.5 * (y1 + y2);

oder so ähnlich :)

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.