Draw img with points

Draw img with points

Post by Evan » Thu, 31 Jan 2002 03:42:53



Hi all!
I get points from a DXF file and I'd like to draw the image in a TPaint or
TImage.
(The points will be connected with lines, there aren't shapes).

I looked in the help and in some examples but I can't understand how to do
this.
Can anyone help me or tell me where can I find infos or simple tutorials?

Thx,
Evan

 
 
 

Draw img with points

Post by David Camero » Sat, 02 Feb 2002 03:10:52



> Hi all!
> I get points from a DXF file and I'd like to draw the image in a TPaint or
> TImage.
> (The points will be connected with lines, there aren't shapes).

> I looked in the help and in some examples but I can't understand how to do
> this.
> Can anyone help me or tell me where can I find infos or simple tutorials?

> Thx,
> Evan

If you have an array of TPoints you can use

image->Canvas->Polyline(arrayOfPoints, numberOfPointsInArray);

This draws a series of lines, connecting the first point to the second
point, the second point to the third point, and so on. You can also use

image->Canvas->Polygon(arrayOfPoints, numberOfPointsInArray);

This is the same as polyline except a line is also drawn between the last
point in the array to the first point, forming a closed polygon.

Also check out the help on TCanvas::MoveTo and TCanvas::LineTo.

Hope this helps,
Dave

 
 
 

Draw img with points

Post by Evan » Mon, 04 Feb 2002 20:05:48


Thanks David.
I solved the problem with another solution:

  for (i=2;i<StringGrid->RowCount;i++){
        x=StringGrid->Cells[0][i].ToDouble();
        if( (x-(int)x) > 0.999 )
                x=(int)x+1;
        y=StringGrid->Cells[1][i].ToDouble();
        if( (y-(int)y) > 0.999 )
                y=(int)y+1;
        Yrel=Ymax-StringGrid->Cells[1][i].ToDouble();
        PaintBox1->Canvas->LineTo(x,y+2*Yrel-200);
  }

But I want to try your tip, it seems more rational.

Bye,
Evan




> > Hi all!
> > I get points from a DXF file and I'd like to draw the image in a TPaint
or
> > TImage.
> > (The points will be connected with lines, there aren't shapes).

> > I looked in the help and in some examples but I can't understand how to
do
> > this.
> > Can anyone help me or tell me where can I find infos or simple
tutorials?

> > Thx,
> > Evan

> If you have an array of TPoints you can use

> image->Canvas->Polyline(arrayOfPoints, numberOfPointsInArray);

> This draws a series of lines, connecting the first point to the second
> point, the second point to the third point, and so on. You can also use

> image->Canvas->Polygon(arrayOfPoints, numberOfPointsInArray);

> This is the same as polyline except a line is also drawn between the last
> point in the array to the first point, forming a closed polygon.

> Also check out the help on TCanvas::MoveTo and TCanvas::LineTo.

> Hope this helps,
> Dave