Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6887995
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:57:14+00:00 2026-05-27T05:57:14+00:00

Required points are red. I draw this using delphi. with Image1.Canvas do begin Image1.Canvas.Pen.Color

  • 0

enter image description here

Required points are red.
I draw this using delphi.

   with Image1.Canvas do
begin
Image1.Canvas.Pen.Color :=RGB(255,0,0);
    MoveTo(30,3); // 1
    LineTo(260,10);// 1-2
    LineTo(100,100);//2-3
    LineTo(30,3);//3-1
Image1.Canvas.Pen.Color :=RGB(0,0,255);
    MoveTo(20,80);//4
    LineTo(300,40);//4-5

end;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T05:57:15+00:00Added an answer on May 27, 2026 at 5:57 am

    Since you’re already using GDI (Canvas), you can also use regions, here is an example:

    procedure TForm1.PaintBox1Paint(Sender: TObject);
    var
      Canvas: TCanvas;
      T1, T2: array[0..2] of TPoint;
      R1, R2: HRGN;
      Buffer: PRgnData;
      BufferSize: Cardinal;
      P: PRect;
      I: Integer;
      Pt1, Pt2: TPoint; // result intersection points
    begin
      Canvas := (Sender as TPaintBox).Canvas;
    
      // first triangle region
      T1[0] := Point(100, 100);
      T1[1] := Point(260, 10);
      T1[2] := Point(30, 3);
      R1 := CreatePolygonRgn(T1[0], 3, ALTERNATE);
      if R1 = 0 then
        RaiseLastOSError;
      try
        // show the first triangle as red (not needed for computation)
        Canvas.Brush.Color := clRed;
        FillRgn(Canvas.Handle, R1, Canvas.Brush.Handle);
    
        // second triangle region    
        T2[0] := Point(20, 80);
        T2[1] := Point(300, 40);
        T2[2] := Point(100, 100);
        R2 := CreatePolygonRgn(T2[0], 3, ALTERNATE);
        if R2 = 0 then
          RaiseLastOSError;
        try
          // show the second triangle as green (not needed for computation)
          Canvas.Brush.Color := clGreen;
          FillRgn(Canvas.Handle, R2, Canvas.Brush.Handle);
    
          // determine the intersecting region    
          if CombineRgn(R1, R1, R2, RGN_AND) = ERROR then
            RaiseLastOSError;
          // show intersection as yellow (not needed for computation)
          Canvas.Brush.Color := clYellow;
          FillRgn(Canvas.Handle, R1, Canvas.Brush.Handle);
    
          // determine the needed buffer size    
          Buffer := nil;
          BufferSize := GetRegionData(R1, 0, Buffer);
          // allocate buffer and get region data (array of rectangles)
          Buffer := AllocMem(BufferSize);
          try
            if GetRegionData(R1, BufferSize, Buffer) = 0 then
              RaiseLastOSError;
    
            // enumerate all rectangles and find points with leftmost and rightmost X    
            P := @Buffer^.Buffer[0];
            Pt1 := P^.TopLeft;
            Pt2 := Point(P^.Right, P^.Top);
            for I := 0 to Buffer^.rdh.nCount - 1 do
            begin
              if P^.Left < Pt1.X then
                Pt1 := P^.TopLeft;
              if P^.Right > Pt2.X then
                Pt2 := Point(P^.Right, P^.Top);
              Inc(P);
            end;
    
            // connect the points with a blue line (not needed for computation)
            Canvas.Pen.Color := clNavy;
            Canvas.MoveTo(Pt1.X, Pt1.Y);
            Canvas.LineTo(Pt2.X, Pt2.Y);
    
            // output result points (not needed for computation)    
            Canvas.Brush.Color := Self.Color;
            Canvas.Font.Color := clWindowText;
            Canvas.TextOut(8, 108, Format('Pt1: %d, %d, Pt2: %d, %d', [Pt1.X, Pt1.Y, Pt2.X, Pt2.Y]));
          finally
            FreeMem(Buffer);
          end;
        finally
          DeleteObject(R2);
        end;
      finally
        DeleteObject(R1);
      end;
    end;
    

    This will produce the following result:

    Screenshot

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using linq given a IEnumerable of two dimensional points, Find the distance required to
I have a project where I am required to fix this program that has
I have an image with two points, aligned something like this: |----------------| | |
currently i creating a java apps and no database required that why i using
I thought Adding Points, Legends and Text to plots using xts objects would have
Easy points for someone willing to help a beginner. Using JQuery Form and Validation
The following code assigns a manual color scale of red and black to my
...what are the essential components(files required) for a Feature.. and can anyone point to
I wrote a nice little program. At some point, it is required to load
Required is the true language version of the OS, not the user interface language

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.