Xojo Conferences
MBSOct2019CologneDE

Moving a line across a graphic (Real Studio network user group Mailinglist archive)

Back to the thread list
Previous thread: Change ProcID at runtime
Next thread: RBscript help (RB 4.02)


Re: Bellman Path Finding   -   Ben Gotow
  Moving a line across a graphic   -   Robert Livingston & Pam Martin
   Re: Moving a line across a graphic   -   Thomas Reed
   Re: Moving a line across a graphic   -   Ben Gotow

Moving a line across a graphic
Date: 08.05.02 19:44 (Wed, 08 May 2002 11:44:09 -0700)
From: Robert Livingston & Pam Martin
Trying to get a tip from people who have used graphics more than I have

I have a drawing (complex bunch of circles and lines created with graphics
commands in a canvas)

I want to draw a vertical line over the drawing using a slider to control
its position (I want to "slide" the line from side to side under user
control)

Now I just draw the line with the graphics command on the same canvas. Sort
of works but gradually I "accumulate" lines and then give the user an
opportunity to "refresh" the picture to get rid of the spurious lines.

I was thinking of overlaying another canvas which was mostly transparent on
top of the first canvas and moving the line there so it would be easier to
draw and erase (just the line) as it moved on top of the first canvas.

Is this a good approach or are there more sensible ways to achieve the
effect I want (moving a line without disturbing the underlying drawing)
under control of a slider.

---
Subscribe to the digest:
<mailto:<email address removed>>
Unsubscribe:
<mailto:<email address removed>>

Re: Moving a line across a graphic
Date: 08.05.02 20:15 (Wed, 8 May 2002 14:15:45 -0500)
From: Thomas Reed
>I was thinking of overlaying another canvas which was mostly transparent on
>top of the first canvas and moving the line there so it would be easier to
>draw and erase (just the line) as it moved on top of the first canvas.

Sounds like the whole scheme may need changing. You should do all the
drawing in offscreen Picture objects and only draw to the Canvas when
it's ready to show. So you'd keep most of the drawing in one Picture,
prepare the drawing with lines added in a second, and then draw THAT
Picture to the Canvas.

-Thomas

Personal web page: http://home.earthlink.net/~thomasareed/
My shareware: http://home.earthlink.net/~thomasareed/shareware/
REALbasic page: http://home.earthlink.net/~thomasareed/realbasic/
Pixel Pen web pub. guide: http://home.earthlink.net/~thomasareed/pixelpen/

A conclusion is simply the place where you got tired of thinking.

---
Subscribe to the digest:
<mailto:<email address removed>>
Unsubscribe:
<mailto:<email address removed>>

Re: Moving a line across a graphic
Date: 09.05.02 01:35 (Wed, 08 May 2002 20:35:34 -0400)
From: Ben Gotow
on 5/8/02 5:38 Ben, Robert Livingston & Pam Martin (by way of Jon Gotow)
at <email address removed> wrote:

> Trying to get a tip from people who have used graphics more than I have
>
> I have a drawing (complex bunch of circles and lines created with graphics
> commands in a canvas)
>
> I want to draw a vertical line over the drawing using a slider to control
> its position (I want to "slide" the line from side to side under user
> control)
>
> Now I just draw the line with the graphics command on the same canvas. Sort
> of works but gradually I "accumulate" lines and then give the user an
> opportunity to "refresh" the picture to get rid of the spurious lines.
>
> I was thinking of overlaying another canvas which was mostly transparent on
> top of the first canvas and moving the line there so it would be easier to
> draw and erase (just the line) as it moved on top of the first canvas.
>
> Is this a good approach or are there more sensible ways to achieve the
> effect I want (moving a line without disturbing the underlying drawing)
> under control of a slider.
>
This approach might work, but it will result in flashing. The best way to do
this, is to create a buffer for the canvas. A buffer is an offscreen picture
that can be used as a temporary drawing surface. It will alow you to draw a
moving line and will not flash in the process.

Here's what you have to do to implement a buffer:

1. Make a new property 'Buffer as picture'

2. Add 'Buffer = newpicture(me.width,me.height,16)' to the canvases open
handler.

3. Find all the places where you draw onto the screen. An example might be
'me.graphics.drawline(10,10,20,15)'. Replace the word 'me' with the word
'buffer'

4. Find all the places where you draw onto the buffer. If you want what you
drew to appear on the screen, add the line 'me.graphics.drawpicture
buffer,0,0' to the end of the method.

5. To prevent trails, add the line 'buffer.clearrect(0,0,me.width,me.height)
to the top of the method.

Here's an example off a draw method (ie. Paint) before buffering:
me.graphics.drawline 10,5,0,0
me.graphics.drawoval 5,5,10,10
me.graphics.drawrect 9,8,20,10

And after buffering:
buffer.clearrect(0,0,me.width,me.height)
buffer.graphics.drawline 10,5,0,0
buffer.graphics.drawoval 5,5,10,10
buffer.graphics.drawrect 9,8,20,10
me.graphics.drawpicture buffer,0,0

-Ben Gotow

>
> ---
> Subscribe to the digest:
> <mailto:<email address removed>>
> Unsubscribe:
> <mailto:<email address removed>>

---
Subscribe to the digest:
<mailto:<email address removed>>
Unsubscribe:
<mailto:<email address removed>>