Board index » delphi » Drawing Sin Cos line

Drawing Sin Cos line

Hoi,

How can i create a Sin And or Cos line?

Danny

 

Re:Drawing Sin Cos line


image1:TImage;
x,ys,yc:integer;

for x:=0 to image1.with-1 do begin
  yc:=(image1.height div 2)+round((image1.height div 2)*sin(x*2*pi/image1.width));
  ys:=(image1.height div 2)+round((image1.height div 2)*cos(x*2*pi/image1.width));
  image1.canvas.pixels[x,yc]:=clred;
  image1.canvas.pixels[x,ys]:=clblue;
 end;

Rene

Quote
Danny wrote:

> Hoi,

> How can i create a Sin And or Cos line?

> Danny

Re:Drawing Sin Cos line


Quote
Rene Tschaggelar wrote:

> image1:TImage;
> x,ys,yc:integer;

> for x:=0 to image1.with-1 do begin
>   yc:=(image1.height div 2)+round((image1.height div 2)*sin(x*2*pi/image1.width));
>   ys:=(image1.height div 2)+round((image1.height div 2)*cos(x*2*pi/image1.width));
>   image1.canvas.pixels[x,yc]:=clred;
>   image1.canvas.pixels[x,ys]:=clblue;
>  end;

   Yep, and this is one of those cases where using the Pixels[] property
isn't too slow because you're typically only drawing around 1000 or so
points. Now if you need to somehow animate this function on the screen
(change the phase and/or amplitude), then it might be too slow, and
you'd be forced to use the scanline property of a bitmap instead.

Cheers,
--
Marko Peric       lonew...@tig.com.au
http://homepages.tig.com.au/~lonewolf

Re:Drawing Sin Cos line


Thanx

It works fine...

Danny

Re:Drawing Sin Cos line


Marko Peric <lonew...@tig.com.au> skrev i
diskussionsgruppsmeddelandet:37316616.E53D4...@tig.com.au...

Quote
>    Yep, and this is one of those cases where using the Pixels[] property
> isn't too slow because you're typically only drawing around 1000 or so
> points. Now if you need to somehow animate this function on the screen
> (change the phase and/or amplitude), then it might be too slow, and
> you'd be forced to use the scanline property of a bitmap instead.

I don't think that would be of much use, since the sin-functions are the CPU
consuming part.
Quote
> Cheers,
> --
> Marko Peric       lonew...@tig.com.au
> http://homepages.tig.com.au/~lonewolf

Other Threads