2012-05-07 11 views
7

tengo tres posiciones conocidas, y actualmente estoy conduciendo dos líneas de este modo:¿Cómo dibujar una línea curva suave en WPF?

Line line = new Line 
{ 
    StrokeThickness = 3, 
    Stroke = lineColor, 
    X1 = MyX, 
    Y1 = MyY, 
    X2 = MyX, 
    Y2 = MiddleY 
}; 

Graph.Children.Add(line); 

line = new Line 
{ 
    StrokeThickness = 3, 
    Stroke = lineColor, 
    X1 = MyX, 
    Y1 = MiddleY, 
    X2 = TargetX, 
    Y2 = TargetY 
}; 

Graph.Children.Add(line); 

Aquí está el resultado:

enter image description here

Por lo tanto, como se puede ver, esto es casi lo que yo quiero, excepto que quiero que se suavice, solo un poco.

Ahora estoy buscando cualquier forma en que pueda establecer tres puntos, establecer un nivel suave/curvilíneo en el punto medio y luego dibujar una línea con un color sólido en él. Al igual que cómo puedo hacer esto en Photoshop:

enter image description here

o al menos obtener un tipo similar de suavidad.

+2

Comience aquí: https://www.google.cz/search?q=spline+wpf – Euphoric

+0

http://stackoverflow.com/questions/9801524/how-to-make-the-brush-smooth-without- lines-in-the-middle –

+2

@HBMAAM: Su enlace es a una pregunta completamente independiente. Esta pregunta se trata de dibujar curvas y su pregunta vinculada es sobre gradientes. – Gabe

Respuesta

9

creo que busca estrías

http://msdn.microsoft.com/en-us/library/554h284b.aspx

Gabe es correcto que es de las formas

Bajo WPF usted podría intentar un PolyBezierSegment pero requieren 4 puntos. Posible que puedas poner tres puntos y 1 más para darle forma.

<Canvas> 
    <Path Stroke="Black" StrokeThickness="10"> 
     <Path.Data> 
      <PathGeometry> 
       <PathGeometry.Figures> 
        <PathFigureCollection>  
         <PathFigure StartPoint="100,80"> 
          <PathFigure.Segments> 
           <PathSegmentCollection> 
            <PolyBezierSegment Points="90,200 140,200 160,200 180,200 430,190 430,280" /> 
           </PathSegmentCollection> 
          </PathFigure.Segments> 
         </PathFigure> 
        </PathFigureCollection> 
       </PathGeometry.Figures> 
      </PathGeometry> 
     </Path.Data> 
    </Path> 
</Canvas> 

Esto se traduce en la siguiente curva

enter image description here

+2

Sí, el OP está buscando splines, pero su enlace es para WinForms. OP está usando WPF, por lo que no ayudará. – Gabe

+0

@Gabe Está en lo cierto buscaré un equivalente de WPF o eliminaré. Gracias – Paparazzi

+0

¿Cómo se determinan esos números mágicos? – Tower

Cuestiones relacionadas