Project

General

Profile

lines_shift.patch

Sergey Ivanovskiy, 11/16/2020 08:35 AM

Download (5.03 KB)

View differences:

src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.canvas_renderer_webgl.js 2020-11-16 13:26:49 +0000
2073 2073
      
2074 2074
      renderer.beginStroke();
2075 2075
      this.drawLineSegment(x, y, x + width - 1, y, renderer);
2076
      this.drawLineSegment(x + width - 1, y + 1, x + width - 1, y + height - 1, renderer);
2076
      this.drawLineSegment(x + width - 1, y, x + width - 1, y + height - 1, renderer);
2077 2077
      this.drawLineSegment(x + width - 1, y + height - 1, x, y + height - 1, renderer);
2078 2078
      this.drawLineSegment(x, y + height - 1, x, y, renderer);// close the path      
2079 2079
   }
src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.strokes.webgl.js 2020-11-16 13:11:13 +0000
503 503
            
504 504
            if (dashOn)
505 505
            {
506
               canvasRenderer.drawImage(x - hw - canvasRenderer.origin.x, y - hw - canvasRenderer.origin.y, width, width, pixelData);
506
               canvasRenderer.drawImage(x - hw, y - hw, width, width, pixelData, true, false);
507 507
            }
508 508
            // vertical line: increase Y-coordinate
509 509
            if (dx == 0)
......
562 562
         rest -= 1;
563 563
         if (dashOn)
564 564
         {
565
            canvasRenderer.drawImage(x - hw - canvasRenderer.origin.x, y - hw - canvasRenderer.origin.y, width, width, pixelData);
565
            canvasRenderer.drawImage(x - hw, y - hw, width, width, pixelData, true, false);
566 566
         }
567 567
         // save the dash pattern state in order to continue this dash pattern for next drawings 
568 568
         state.dashOn = dashOn;
......
811 811
         
812 812
         var cap = basicStroke.getCapEnum();
813 813
         var join = basicStroke.getJoinEnum();
814
         
815 814
         var a = x2-x1;
816 815
         var b = y2-y1;
817 816
         
......
831 830
         if (b == 0)
832 831
         {
833 832
            l = Math.abs(a);
834
            bx1 = x1;
835
            by1 = y1 + w;
836
            cx1 = x1;
837
            cy1 = y1 - w;
838
            bx2 = x2;
839
            by2 = y2 + w;
840
            cx2 = x2;
841
            cy2 = y2 - w;
842
            ax1 = x1;
843
            ay1 = y1;
844
            ax2 = x2;
845
            ay2 = y2;
833
            if (width == 1)
834
            {
835
               bx1 = x1;
836
               by1 = y1 + 1;
837
               cx1 = x1;
838
               cy1 = y1;
839
               bx2 = x2;
840
               by2 = y2 + 1;
841
               cx2 = x2;
842
               cy2 = y2;
843
               ax1 = x1;
844
               ay1 = y1 + 0.5;
845
               ax2 = x2;
846
               ay2 = y2 + 0.5;
847
            }
848
            else
849
            {
850
               bx1 = x1;
851
               by1 = y1 + w;
852
               cx1 = x1;
853
               cy1 = y1 - w;
854
               bx2 = x2;
855
               by2 = y2 + w;
856
               cx2 = x2;
857
               cy2 = y2 - w;
858
               ax1 = x1;
859
               ay1 = y1;
860
               ax2 = x2;
861
               ay2 = y2;
862
            }
846 863
         }
847 864
         else if (a == 0)
848 865
         {
849 866
            l = Math.abs(b);
850
            bx1 = x1 - w;
851
            by1 = y1;
852
            cx1 = x1 + w;
853
            cy1 = y1;
854
            bx2 = x2 - w;
855
            by2 = y2;
856
            cx2 = x2 + w;
857
            cy2 = y2;
858
            ax1 = x1;
859
            ay1 = y1;
860
            ax2 = x2;
861
            ay2 = y2;
867
            if (width == 1)
868
            {
869
               bx1 = x1;
870
               by1 = y1;
871
               cx1 = x1 + 1;
872
               cy1 = y1;
873
               bx2 = x2;
874
               by2 = y2;
875
               cx2 = x2 + 1;
876
               cy2 = y2;
877
               ax1 = x1 + 0.5;
878
               ay1 = y1;
879
               ax2 = x2 + 0.5;
880
               ay2 = y2;
881
            }
882
            else
883
            {
884
               bx1 = x1 - w;
885
               by1 = y1;
886
               cx1 = x1 + w;
887
               cy1 = y1;
888
               bx2 = x2 - w;
889
               by2 = y2;
890
               cx2 = x2 + w;
891
               cy2 = y2;
892
               ax1 = x1;
893
               ay1 = y1;
894
               ax2 = x2;
895
               ay2 = y2;
896
            }
862 897
         }
863 898
         else
864 899
         {
......
878 913
            ay2 = y2;
879 914
         }
880 915
         
881
         curr.push([x1, y1, l, bx1, by1, cx1, cy1]);
882
         curr.push([x2, y2, l, bx2, by2, cx2, cy2]);
916
         curr.push([ax1, ay1, l, bx1, by1, cx1, cy1]);
917
         curr.push([ax2, ay2, l, bx2, by2, cx2, cy2]);
883 918
         
884 919
         if (prev.length == 2 && join == JOIN_MITER)
885 920
         {
......
1048 1083
       */
1049 1084
      this.strokePoint = function(x, y)
1050 1085
      {
1051
         canvasRenderer.drawImage(x - w - canvasRenderer.origin.x, y - w - canvasRenderer.origin.y, width, width, pixelData);
1086
         canvasRenderer.drawImage(x - w, y - w, width, width, pixelData, true, false);
1052 1087
      }
1053 1088
   }
1054 1089