Bonjour,

mon problème , que j'arrive pas avoir le même position de l'image comme Drawline ( voir angle à 90 degrés).

voir mon gif :
Nom : Animation.gif
Affichages : 199
Taille : 206,1 Ko

Mon code :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
Imports System.Drawing.Drawing2D
 
Public Class Form1
 
 
    Private _Main As Image = My.Resources.Droite1
    Private Sub Form1_Paint(sender As System.Object, e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
        Dim g As Graphics = e.Graphics
        g.SmoothingMode = SmoothingMode.AntiAlias
        Dim rect As New Rectangle(50, 10, 500, 500)
        g.DrawEllipse(New Pen(Brushes.Black, 1), rect)
        DrawAngleImage(g, rect)
    End Sub
 
    Private Sub DrawAngleImage(g As Graphics, r As Rectangle)
        Dim center As New Point(r.Width / 1.7, r.Height / 2)
        Dim radius As Integer = center.X * 0.65
        Using Pen As New Pen(Brushes.Black, 20)
            Pen.StartCap = LineCap.RoundAnchor
            Pen.EndCap = LineCap.Flat
            g.SmoothingMode = SmoothingMode.AntiAlias
            g.DrawLine(Pen, center.X, center.Y, center.X + CInt(Math.Sin(NumericUpDown1.Value * Math.PI / 180) * radius), center.Y - CInt(Math.Cos(NumericUpDown1.Value * Math.PI / 180) * radius))
            g.DrawImage(_Main, New Rectangle(CInt(center.X - CInt(_Main.Width / 3.6)) + CInt(Math.Sin(NumericUpDown1.Value * Math.PI / 180) * radius), CInt(center.Y - CInt(_Main.Height / 2.4)) - CInt(Math.Cos(NumericUpDown1.Value * Math.PI / 180) * radius), _Main.Width, _Main.Height), 0, 0, _Main.Width, _Main.Height, GraphicsUnit.Pixel)
        End Using
    End Sub
 
    Private Sub NumericUpDown1_ValueChanged(sender As System.Object, e As System.EventArgs) Handles NumericUpDown1.ValueChanged
        Me.Refresh()
    End Sub
End Class
Pouvez-Vous m'aider à avoir la mème position comme drawline(voir angle à 90 degrés). Merci d'avance