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 chemin associé à ceci 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-chemin actuel contient une courbe ; sinon, false.
Exemples
L’exemple suivant est conçu pour une utilisation avec Windows Forms, et nécessite PaintEventArgse, un objet d’événement OnPaint. Le code effectue les actions suivantes :
Crée un GraphicsPath objet.
myPathAjoute trois lignes, un rectangle et un ellipse.
Crée un GraphicsPathIterator objet pour
myPath.Teste pour voir si le chemin
myPathactuel 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 un ellipse à un chemin, vous spécifiez l’angle supérieur gauche, la largeur et la hauteur du rectangle englobant de l’ellipse. Ces nombres (angle supérieur gauche, largeur et hauteur) ne sont pas stockés dans le chemin ; Place; l’ellipse est converti en une séquence de quatre splines de Bézier. Le chemin stocke les points de terminaison et les points de contrôle de ces splines de Bézier.
Un chemin stocke un tableau de points de données, chacun appartenant à une ligne ou à une spline de Bézier. Si certains des points du tableau appartiennent aux splines de Bézier, retourne HasCurvetrue. Si tous les points du tableau appartiennent à des lignes, retourne HasCurvefalse.
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 d’accès a été aplati, HasCurve retourne toujours false. L’appel de la Flattenméthode , Widenou Warp de la méthode de la GraphicsPath classe aplatit un chemin d’accès.