[修复] Firemonkey 使用 DrawPath 断线问题(Android & iOS 平台)

问题:使用 Canvas.DrawPath 绘制时,最后一点无法画到终点位置。(这个问题要在粗线才能察觉)

适用:Delphi 10 Seattle (或更早的版本) for Android & iOS

修复方法:

请将源码 FMX.StrokeBuilder.pas 复制到自己的工程目录里,再进行修改。

procedure TStrokeBuilder.BuildSolidPolygon(const Points: TPolygon; const Opacity: Single; BreakAtEnd: Boolean);

...略...

  while CurIndex < Length(Points) do
  begin
    if (CurIndex >= Length(Points) - 1) and BreakAtEnd and (Points[0] <> Points[Length(Points) - 1]) then
{--->删除这行 Break;}
{+++>新增代码}
    // 修复曲线最后一点断线的问题 by Aone (2016/03/25)
    begin
      PieceDirVec := (DestPos - SrcPos).Normalize;
      ThickPerp := TPointF.Create(-PieceDirVec.Y, PieceDirVec.X) * FHalfThickness;

      InsertVertex(DestPos - ThickPerp, FStrokeColor);
      InsertVertex(DestPos + ThickPerp, FStrokeColor);

      if PrevVerticesPlaced then
      begin
        InsertIndex(FCurrentVertex - 3);
        InsertIndex(FCurrentVertex - 1);
        InsertIndex(FCurrentVertex - 2);

        InsertIndex(FCurrentVertex - 2);
        InsertIndex(FCurrentVertex - 4);
        InsertIndex(FCurrentVertex - 3);
      end;

      Break;
    end;
{<+++}

...略...

end;

效果:

 

官方有人提交 QC 了: 

RSP-14309: [iOS & Android] Delphi 10.1 Berlin - drawing problems
https://quality.embarcadero.com/browse/RSP-14309

 

posted @ 2016-03-25 15:20  龟山Aone  阅读(1013)  评论(0编辑  收藏  举报