GraphicsPathIterator.HasCurve Método
Definição
Importante
Algumas informações dizem respeito a um produto pré-lançado que pode ser substancialmente modificado antes de ser lançado. A Microsoft não faz garantias, de forma expressa ou implícita, em relação à informação aqui apresentada.
Indica se o caminho associado a isto GraphicsPathIterator contém uma curva.
public:
bool HasCurve();
public bool HasCurve();
member this.HasCurve : unit -> bool
Public Function HasCurve () As Boolean
Devoluções
Este método retorna true se o subcaminho atual contiver uma curva; caso contrário, false.
Exemplos
O exemplo seguinte foi concebido para uso com Windows Forms e requer PaintEventArgse, um objeto de evento OnPaint. O código executa as seguintes ações:
Cria um GraphicsPath objeto,
myPath.Adiciona três linhas, um retângulo e uma elipse.
Cria um GraphicsPathIterator objeto para
myPath.Testa para ver se o caminho
myPathatual contém uma curva.Mostra o resultado do teste numa caixa de mensagem.
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
Observações
Todas as curvas num caminho são armazenadas como sequências de splines de Bézier. Por exemplo, quando adicionas uma elipse a um caminho, especificas o canto superior esquerdo, a largura e a altura do retângulo delimitador da elipse. Esses números (canto superior esquerdo, largura e altura) não são armazenados no caminho; em vez disso; a elipse é convertida numa sequência de quatro splines de Bézier. O caminho armazena os pontos finais e de controlo desses splines de Bézier.
Um caminho armazena um array de pontos de dados, cada um pertencente a uma linha ou a uma spline de Bézier. Se alguns dos pontos do array pertencerem a splines de Bézier, então HasCurve retorna true. Se todos os pontos do array pertencerem a linhas, então HasCurve retorna false.
Certos métodos achatam um caminho, o que significa que todas as curvas no caminho são convertidas em sequências de linhas. Depois de um caminho ter sido achatado, HasCurve voltará sempre false. Chamar o Flatten, Widen, ou Warp método da GraphicsPath classe achatará um caminho.