Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2011-06

Patch for fpVectorial

9 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Leonardo M. Ramé

Hi, the methods SetPenWidth and SetPenColor of
TvVectorialDocument doesn't seems to be applied when DrawFPVectorialToCanvas is called.

I added a couple of lines to fpvtocanvas.pas to apply those settings. In my project the patch works as I expect.

Here's the diff:

Index: fpvtocanvas.pas
=================================================================== --- fpvtocanvas.pas (revisi?n: 17687)
+++ fpvtocanvas.pas (copia de trabajo)
@@ -174,6 +174,8 @@

       case CurSegment.SegmentType of
       stMoveTo:
       begin

+ ADest.Pen.Width := ASource.Paths[i].Pen.Width;
+ ADest.Pen.Color := VColorToTColor(ASource.Paths[i].Pen.Color); ADest.MoveTo(CoordToCanvasX(Cur2DSegment.X),
CoordToCanvasY(Cur2DSegment.Y));

         {$ifdef FPVECTORIAL_TOCANVAS_DEBUG}
         Write(Format(' M%d,%d', [CoordToCanvasX(Cur2DSegment.X),

CoordToCanvasY(Cur2DSegment.Y)]));

Do you think the patch should be applied?.

Reply by email

Felipe Monteiro de Carvalho
to Leonardo M. Ramé
Leonardo M. Ram? wrote
I added a couple of lines to fpvtocanvas.pas to apply those settings. In my project the patch works as I expect.

Your code applies the path color in stMoveTo, while it should actually apply it only once before entering the segments loop.

I implemented this in rev1666, along with fixes to make sure that all objects have brush and pen initialized properly, please test.

Felipe Monteiro de Carvalho

Reply by email

Leonardo M. Ramé
to Felipe Monteiro de Carvalho
Felipe Monteiro de Carvalho wrote 13 lines
On Wed, Jun 8, 2011 at 2:14 AM, Leonardo M. Ram? wrote: > I added a couple of lines to fpvtocanvas.pas to apply those settings. In > my project the patch works as I expect. Your code applies the path color in stMoveTo, while it should actually apply it only once before entering the segments loop. I implemented this in rev1666, along with fixes to make sure that all objects have brush and pen initialized properly, please test. -- Felipe Monteiro de Carvalho

Sorry, I use the fpvectorial package from fpc trunk, which is now on rev
17692. Where is rev1666? is it from another repository?.

Reply by email

Felipe Monteiro de Carvalho
to Leonardo M. Ramé
Leonardo M. Ram? wrote
Sorry, I use the fpvectorial package from fpc trunk, which is now on rev 17692. Where is rev1666? is it from another repository?.

Yes, it is from the lazarus-ccr where I develop unstable features.

But I merged all changes in rev17693 to fpc trunk

Felipe Monteiro de Carvalho

Reply by email

Leonardo M. Ramé
to Felipe Monteiro de Carvalho
Felipe Monteiro de Carvalho wrote 8 lines
On Wed, Jun 8, 2011 at 2:16 PM, Leonardo M. Ram? wrote: > Sorry, I use the fpvectorial package from fpc trunk, which is now on rev > 17692. Where is rev1666? is it from another repository?. Yes, it is from the lazarus-ccr where I develop unstable features. But I merged all changes in rev17693 to fpc trunk

Felipe, It doesn't work.

I did this simple test:

var
  Vec: TvVectorialDocument;
  lClYellow: TvColor = (Red: $FF; Green: $FF; Blue: $00; Alpha: FPValphaOpaque);
begin
  Vec := TvVectorialDocument.Create;
  try
    Vec.Width := Round(100);
    Vec.Height := Round(100);
    Vec.SetPenColor(lClYellow);
    Vec.SetPenWidth(1);
    Vec.StartPath(0, 0);
    Vec.AddLineToPath(100, 100);
    Vec.EndPath();
    DrawFPVectorialToCanvas(Vec, PaintBox1.Canvas);
  finally
    Vec.Free;
  end;
end;

This should draw a yellow line (with my patch it did), but now it draws a black line.

Reply by email

Felipe Monteiro de Carvalho
to Leonardo M. Ramé

Your code is wrong, because Vec.StartPath creates a new path. Previously it didn't erase the color, but now it does. Try this order of calls:

    Vec.StartPath(0, 0);
    Vec.SetPenColor(lClYellow); // <--- after StartPath
    Vec.SetPenWidth(1);
    Vec.AddLineToPath(100, 100);
    Vec.EndPath();
Felipe Monteiro de Carvalho

Reply by email

Leonardo M. Ramé
to Felipe Monteiro de Carvalho
Felipe Monteiro de Carvalho wrote 10 lines
Your code is wrong, because Vec.StartPath creates a new path. Previously it didn't erase the color, but now it does. Try this order of calls: Vec.StartPath(0, 0); Vec.SetPenColor(lClYellow); // <--- after StartPath Vec.SetPenWidth(1); Vec.AddLineToPath(100, 100); Vec.EndPath();

Great, now the color works. But the PenWidth doesn't seems to be working.

Reply by email