zoukankan      html  css  js  c++  java
  • [修复] 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

  • 相关阅读:
    最短路径的三种实现方法
    c/c++小知识
    c++ char * const p问题
    C++ typedef 四个用途
    [转]c++面向对象基础
    [转]C++中引用(&)的用法和应用实例
    表情包。
    linux基础学习
    redis缓存在项目中的使用
    关于redis
  • 原文地址:https://www.cnblogs.com/onechen/p/5319631.html
Copyright © 2011-2022 走看看