Board index » delphi » Drawing "sweeping" lines onto 265 color canvas?

Drawing "sweeping" lines onto 265 color canvas?

Okay, I guess I need to copy/paste the pixels in order to "erase" a
moving line.  I guess I can use CopyRect for this, even though its a
line.

But I'm getting a lot of flicker.  My code to copy the line to a
temporary image, draw the line, then copy the image buffer back onto
the canvas to erase the previous line, etc. is in the MouseMove event.

What can I do?

(In essence, all I want is to have, e.g., a swinging pendulum kind of
look on a 256 color image, by painting a line onto the canvas)

 

Re:Drawing "sweeping" lines onto 265 color canvas?


Quote
Mark Lerch wrote:
>Okay, I guess I need to copy/paste the pixels in order to "erase" a
>moving line ... I'm getting a lot of flicker ... What can I do?
>(In essence, all I want is to have, e.g., a swinging pendulum kind of
>look on a 256 color image, by painting a line onto the canvas)

Does the line have to be a solid color ?
If not, set the pen mode to pmXOr, draw the line, wait a short time,
then draw it again to erase it.

Regards,
--
Duncan
LECS Ltd

Re:Drawing "sweeping" lines onto 265 color canvas?


Thanks for the reply.  Yes, solid line (I've done the XOR bit) - and
w/ varying thicknesses, possibly.

You know, if you open up the simple Image Editor in Delphi, and open a
256 color bitmap, you can select the line tool, and click/drag the
line over the bitmap until you "unclick," then the line draws.

This "sweeping" action is absolutely smooth.  And is *precisely* the
behavior I need.  Wish I could see their source code...

On Mon, 22 Dec 1997 09:13:04 GMT,

Quote
DELETETHISduncan.mcni...@lecs.inet.fi (Duncan McNiven) wrote:
>Mark Lerch wrote:

>>Okay, I guess I need to copy/paste the pixels in order to "erase" a
>>moving line ... I'm getting a lot of flicker ... What can I do?
>>(In essence, all I want is to have, e.g., a swinging pendulum kind of
>>look on a 256 color image, by painting a line onto the canvas)

>Does the line have to be a solid color ?
>If not, set the pen mode to pmXOr, draw the line, wait a short time,
>then draw it again to erase it.

>Regards,

Re:Drawing "sweeping" lines onto 265 color canvas?


Quote
Mark Lerch wrote:

> Thanks for the reply.  Yes, solid line (I've done the XOR bit) - and
> w/ varying thicknesses, possibly.

> You know, if you open up the simple Image Editor in Delphi, and open a
> 256 color bitmap, you can select the line tool, and click/drag the
> line over the bitmap until you "unclick," then the line draws.

> This "sweeping" action is absolutely smooth.  And is *precisely* the
> behavior I need.  Wish I could see their source code...

    This flicker might be due to the WM_ERASEBKGND message being sent
for each step of the "swing". Or in other words, each time you repaint
something, you also erase the background. Assuming you are using TImage,
TPaintBox, or some descendent of TGraphicalControl, on a TForm, then by
simply capturing the WM_ERASEBKGND message you can get rid of the
flicker.

So, in the interface section:

type
  TForm1 = class(TForm)
  ...
  private
    Erase : Boolean;
    procedure WMEraseBkgnd(var Message: TWMEraseBkgnd); message
WM_ERASEBKGND;
  ...
end;

and then in the implementation section:

procedure TForm1.WMEraseBkgnd(var Message: TWMEraseBkgnd);
begin
if Erase then inherited;
end;

    When Erase is True, then the background will be erased. When Erase
is False then the background won't be erased. The latter case will
hopefully eliminate your flicker. I didn't catch all of your message, so
this might not be exactly what you are looking for!

Cheers,
--
Marko Peric       lonew...@tig.com.au

Other Threads