Silverlight 引路蜂二维图形库示例:线段末端形状(LineCap)

jerry Silverligth 2015年11月26日 收藏

LineCap 指定了开放路径端点的形状。有三种不同的类型:CAP_BUTT, CAP_ROUND和CAP_SQUARE。

下面代码显示了三种不同的LineCap类型。

  1. private void LineCap()
  2. {
  3.  Color blackColor = new Color(0x000000);
  4.  Color whiteColor = new Color(0xffffff);
  5.  graphics2D.Reset();
  6.  graphics2D.Clear(Color.White);
  7.  
  8.  Pen pen = new Pen(blackColor, 20, Pen.CapButt, Pen.JoinMiter);
  9.  graphics2D.DrawLine(pen, 40, 60, 140, 60);
  10.  pen = new Pen(whiteColor, 1);
  11.  graphics2D.DrawLine(pen, 40, 60, 140, 60);
  12.  pen = new Pen(blackColor, 20, Pen.CapRound, Pen.JoinMiter);
  13.  graphics2D.DrawLine(pen, 40, 100, 140, 100);
  14.  pen = new Pen(whiteColor, 1);
  15.  graphics2D.DrawLine(pen, 40, 100, 140, 100);
  16.  
  17.  pen = new Pen(blackColor, 20, Pen.CapSquare, Pen.JoinMiter);
  18.  graphics2D.DrawLine(pen, 40, 140, 140, 140);
  19.  pen = new Pen(whiteColor, 1);
  20.  graphics2D.DrawLine(pen, 40, 140, 140, 140);
  21. }