GraphicsPathIterator.HasCurve Méthode
Définition
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
Indique si le tracé associé à ce GraphicsPathIterator contient une courbe.
public:
bool HasCurve();
public bool HasCurve ();
member this.HasCurve : unit -> bool
Public Function HasCurve () As Boolean
Retours
Cette méthode retourne true
si le sous-tracé en cours contient une courbe ; sinon, false
.
Exemples
L’exemple suivant est conçu pour être utilisé avec Windows Forms et nécessite PaintEventArgse
, un objet d’événementOnPaint. Le code effectue les actions suivantes :
Crée un GraphicsPath objet ,
myPath
.Ajoute trois lignes, un rectangle et une ellipse.
Crée un GraphicsPathIterator objet pour
myPath
.Teste pour voir si le chemin
myPath
actuel contient une courbe.Affiche le résultat du test dans une boîte de message.
private:
void HasCurveExample( PaintEventArgs^ /*e*/ )
{
// Create a path and add three lines,
// a rectangle and an ellipse.
GraphicsPath^ myPath = gcnew GraphicsPath;
array<Point>^ myPoints = {Point(20,20),Point(120,120),Point(20,120),Point(20,20)};
Rectangle myRect = Rectangle(120,120,100,100);
myPath->AddLines( myPoints );
myPath->AddRectangle( myRect );
myPath->AddEllipse( 220, 220, 100, 100 );
// Create a GraphicsPathIterator for myPath.
GraphicsPathIterator^ myPathIterator = gcnew GraphicsPathIterator( myPath );
// Test for a curve.
bool myHasCurve = myPathIterator->HasCurve();
// Show the test result.
MessageBox::Show( myHasCurve.ToString() );
}
private void HasCurveExample(PaintEventArgs e)
{
// Create a path and add three lines,
// a rectangle and an ellipse.
GraphicsPath myPath = new GraphicsPath();
Point[] myPoints = {new Point(20, 20), new Point(120, 120),
new Point(20, 120),new Point(20, 20) };
Rectangle myRect = new Rectangle(120, 120, 100, 100);
myPath.AddLines(myPoints);
myPath.AddRectangle(myRect);
myPath.AddEllipse(220, 220, 100, 100);
// Create a GraphicsPathIterator for myPath.
GraphicsPathIterator myPathIterator = new
GraphicsPathIterator(myPath);
// Test for a curve.
bool myHasCurve = myPathIterator.HasCurve();
// Show the test result.
MessageBox.Show(myHasCurve.ToString());
}
Public Sub HasCurveExample(ByVal e As PaintEventArgs)
Dim myPath As New GraphicsPath
Dim myPoints As Point() = {New Point(20, 20), _
New Point(120, 120), New Point(20, 120), New Point(20, 20)}
Dim myRect As New Rectangle(120, 120, 100, 100)
myPath.AddLines(myPoints)
myPath.AddRectangle(myRect)
myPath.AddEllipse(220, 220, 100, 100)
' Create a GraphicsPathIterator for myPath.
Dim myPathIterator As New GraphicsPathIterator(myPath)
Dim myHasCurve As Boolean = myPathIterator.HasCurve()
MessageBox.Show(myHasCurve.ToString())
End Sub
Remarques
Toutes les courbes d’un chemin sont stockées sous forme de séquences de splines de Bézier. Par exemple, lorsque vous ajoutez une ellipse à un chemin, vous spécifiez l’angle supérieur gauche, la largeur et la hauteur du rectangle englobant de l’ellipse. Ces nombres (coin supérieur gauche, largeur et hauteur) ne sont pas stockés dans le chemin d’accès ; Place; l’ellipse est convertie en une séquence de quatre splines de Bézier. Le chemin d’accès stocke les points de terminaison et les points de contrôle de ces splines de Bézier.
Un chemin d’accès stocke un tableau de points de données, chacun appartenant à une ligne ou à une spline de Bézier. Si certains points du tableau appartiennent à des splines de Bézier, HasCurve retourne true
. Si tous les points du tableau appartiennent à des lignes, HasCurve retourne false
.
Certaines méthodes aplatissent un chemin, ce qui signifie que toutes les courbes du chemin sont converties en séquences de lignes. Une fois qu’un chemin a été aplati, HasCurve retourne false
toujours . L’appel de la Flattenméthode , Widenou Warp de la GraphicsPath classe aplatit un chemin.
S’applique à
Commentaires
https://aka.ms/ContentUserFeedback.
Bientôt disponible : Tout au long de 2024, nous allons supprimer progressivement GitHub Issues comme mécanisme de commentaires pour le contenu et le remplacer par un nouveau système de commentaires. Pour plus d’informations, consultezEnvoyer et afficher des commentaires pour