Author |
Topic: Scrolling (or sliding) pictures (Read 560 times) |
|
KenDown
Full Member
member is offline


Posts: 181
|
 |
Scrolling (or sliding) pictures
« Thread started on: Apr 30th, 2015, 09:26am » |
|
I have a program which slides long pictures across the screen, so if a picture is 1280 wide it is scaled to fit the screen, but if it is - say - 2000 wide it pans across the screen.
The method is fairly crude: I plot the picture at the extreme right of the window and then decrease the x position by 2 and plot it again until the right-hand edge of the picture lines up with the right hand edge of the window. By then, of course, x is a negative value.
As I say, it works, but it is relatively slow and can be jerky.
I've been looking at the "SplashScreen" program by Michael Hutton, which animates beautifully smoothly, but I can't see how to move a picture off the screen to either left or right. It may be impossible with SYS"AnimateWindow" - does anyone know?
Is there another method?
|
|
Logged
|
|
|
|
rtr2
Guest
|
 |
Re: Scrolling (or sliding) pictures
« Reply #1 on: Apr 30th, 2015, 2:45pm » |
|
on Apr 30th, 2015, 09:26am, KenDown wrote: The supplied example program SCROLL.BBC (in the EXAMPLES\GENERAL folder) is intended to demonstrate doing exactly what you describe. It uses the @ox% and @oy% 'system variables', which are provided specifically to support scrolling graphics.
If you still find that too fiddly, consider switching to Liberty BASIC (or LB Booster, which translates to BBC BASIC) which provides a scrolling graphics window as a native feature.
Richard.
|
|
Logged
|
|
|
|
KenDown
Full Member
member is offline


Posts: 181
|
 |
Re: Scrolling (or sliding) pictures
« Reply #2 on: Apr 30th, 2015, 3:26pm » |
|
Hmmmm. I shall have to study that carefully. Just at first glance it appears to create a larger window but displays just a small portion of it. My program uses the full screen window (no borders or scroll bars visible).
In addition your program is controlled by scroll bars, whereas I need the picture to scroll automatically.
I'm not saying yours won't work, just that I'll need to play around with it - and those are probably the reasons why it didn't occur to me as a possible solution to the problem.
Thanks.
|
|
Logged
|
|
|
|
rtr2
Guest
|
 |
Re: Scrolling (or sliding) pictures
« Reply #3 on: Apr 30th, 2015, 5:47pm » |
|
on Apr 30th, 2015, 3:26pm, KenDown wrote:Just at first glance it appears to create a larger window but displays just a small portion of it. |
|
No, Windows doesn't support that (in any straightforward way); ordinarily the 'window' is by definition the visible region (client area + non-client area such as borders and title bar).
Quote:My program uses the full screen window (no borders or scroll bars visible). |
|
It makes no difference. In fact you can maximise the SCROLL.BBC window anyway (albeit that a maximised window is not quite the same as a full-screen window, but the differences are not important in this case).
Quote:In addition your program is controlled by scroll bars, whereas I need the picture to scroll automatically. |
|
Like all the example programs, SCROLL.BBC is intended to be adapted to your own requirements rather than used as-is. In fact controlling the scrolling from something other than the scrollbars is likely to simplify the program.
The fundamental point is that to scroll the BB4W 'mainwin' you should use the @ox% and @oy% system variables. That's what they are for, and attempting to do it any other way wouldn't be sensible. They are really easy to use:
Code: PRINT "The quick brown fox jumps over the lazy dog."
REPEAT
WAIT 4
@ox% = 200 * COS(TIME/100) + 200
SYS "InvalidateRect", @hwnd%, 0, 0
UNTIL FALSE Richard.
|
|
Logged
|
|
|
|
KenDown
Full Member
member is offline


Posts: 181
|
 |
Re: Scrolling (or sliding) pictures
« Reply #4 on: May 3rd, 2015, 1:30pm » |
|
Wow! That is clever. I would never, in a million years, have thought of using COS to simply turn a positive into a negative (and vice versa). How do you think of these things? (That is an expression of admiration, not a request for information!)
|
|
Logged
|
|
|
|
KenDown
Full Member
member is offline


Posts: 181
|
 |
Re: Scrolling (or sliding) pictures
« Reply #5 on: May 5th, 2015, 06:41am » |
|
Curious. To get the screen contents to move right, you have to *decrease* @ox% from zero to screen width.
However even more curious is the fact that any graphics have to be at least 4 in from the left, otherwise they leave a "smear" as they move to the right - and no matter how far in you put any text (under VDU4) they drag a line across behind it. The graphics I can cope with, but have you any ideas about the text line?
|
|
Logged
|
|
|
|
KenDown
Full Member
member is offline


Posts: 181
|
 |
Re: Scrolling (or sliding) pictures
« Reply #6 on: May 5th, 2015, 06:56am » |
|
Hmmmm. An even more fundamental problem appears to be that altering the @ox% variable moves what is on the screen to left or right - but anything not on the screen does not appear. If I have a picture wider than the screen, the part which is plotted can be scrolled around, but the part which did not appear has gone.
Thus if my screen is 1280 wide and I plot a picture 2000 wide and then fiddle with @ox%, the left-most 1280 moves around beautifully, but the right-most 720 never appears.
|
|
Logged
|
|
|
|
rtr2
Guest
|
 |
Re: Scrolling (or sliding) pictures
« Reply #7 on: May 5th, 2015, 07:12am » |
|
on May 5th, 2015, 06:41am, KenDown wrote:However even more curious is the fact that any graphics have to be at least 4 in from the left, otherwise they leave a "smear" as they move to the right |
|
You can't move anything to the right, because that leaves a 'border' in which there is nothing to be displayed! Try scrolling a text editor like Notepad to the right - starting at its 'home' position - you can't do it.
So you must never store a negative value into @ox% or @oy%. From your description you have misunderstood how they work - refresh your memory by once again running the supplied example program SCROLL.BBC.
Edit: For the avoidance of doubt I have now modified the online BB4W documentation to state explicitly that @ox% and @oy% "must be zero or positive":
http://www.bbcbasic.co.uk/bbcwin/manual/bbcwin2.html#systemvars
Richard.
|
« Last Edit: May 5th, 2015, 08:31am by rtr2 » |
Logged
|
|
|
|
KenDown
Full Member
member is offline


Posts: 181
|
 |
Re: Scrolling (or sliding) pictures
« Reply #8 on: May 5th, 2015, 07:56am » |
|
Hmmm. Scrub my last comment. I was just using graphics (RECTANGLEFILL). However when I tried plotting a picture, the whole picture did appear, so sorry about that.
As for putting a negative value into @ox%, it doesn't appear to cause any problems apart from the "smearing" effect, which can be bodged.
Oh, and the line the followed text is, in fact, the cursor and is solved by incorporating OFF.
|
|
Logged
|
|
|
|
rtr2
Guest
|
 |
Re: Scrolling (or sliding) pictures
« Reply #9 on: May 5th, 2015, 08:45am » |
|
on May 5th, 2015, 07:56am, KenDown wrote:As for putting a negative value into @ox%, it doesn't appear to cause any problems apart from the "smearing" effect, which can be bodged. |
|
It may not "appear" to, but I can assure you it does. I'm sorry, but you must never store a negative value into @ox% or @oy% (I have now amended the BB4W documentation to state this explicitly).
If you really want to see the sort of unwanted effects doing so can cause, try storing a negative value in @ox% and then minimise/restore the window!
No common application, whether text or graphics, allows you to scroll to the right from the 'home' position. Try it in Notepad or Paint (or even the BB4W editor): that's as far right as you can go. The @ox% and @oy% system variables are designed to support only this 'conventional' kind of scrolling.
Richard.
|
|
Logged
|
|
|
|
|