Slow moving objects

Feature requests for future versions of Hollywood can be voiced here
Post Reply
Flinx
Posts: 188
Joined: Sun Feb 14, 2021 9:54 am
Location: Germany

Slow moving objects

Post by Flinx »

In my current project a text is sometimes scrolled very slowly, moving up one pixel at a time. But because the regular shifting by one pixel is noticeable, I was looking for a better method.
As a test I doubled my text objects, shifted them by one pixel and blended them with transparency depending on their position. This helps a bit, but of course the letters become transparent when blending and there are brightness fluctuations. To hide these, I placed a third non-transparent text object in front of it and blended the other two with two pixels between them. But for this the font must not have a border of a different color.
The program shows these trials: on the left the normal text and next to it the three experiments.
To see how the objects are blended, you can initialize xoffset with a non-zero value.
By the way, the blending is done with gamma correction, because otherwise at least with a black background, a pulsing of the horizontal lines could be seen.

In this way it looks good, but this method is not really practical, because I have to move three times the number of objects, and I can't show a border anymore, which I had used as a makeshift blur. Also, the characters are one pixel too high this way.

Would a similar drawing mode perhaps be a useful enhancement for a future Hollywood version?
I just hope I haven't overlooked a Hollywood feature that can do something like this already.

Ralf

Code: Select all

Function p_Scroll()
	CurrentTimer=GetTimer(1)
	timerdelta=CurrentTimer-LastTimer
	LastTimer=CurrentTimer	
	ydelta=scrollspeed * (timerdelta/1000)
	ypos=ypos-ydelta
	If ypos<0-fsize Then ypos=startpos

	gamma=1.5
	yta=Int(Frac(ypos+2000)^gamma*256)     ; transparency a
	ytb=255-Int(Frac(ypos+2000)^(1/gamma)*256) ; transparency b
	
	BeginRefresh()
	
	SetLayerStyle("T1", {Y=ypos})

	SetLayerStyle("T2a", {X=xpos2-xoffset/2, Y=ypos-1, Transparency=yta})
	SetLayerStyle("T2b", {X=xpos2+xoffset/2, Y=ypos, Transparency=ytb})

	SetLayerStyle("T3a", {X=xpos3-xoffset, Y=ypos-1, Transparency=yta})
	SetLayerStyle("T3b", {X=xpos3+xoffset, Y=ypos+1, Transparency=ytb})
	SetLayerStyle("T3c", {Y=ypos})

	SetLayerStyle("T4a", {X=xpos4-xoffset, Y=ypos-1, Transparency=yta})
	SetLayerStyle("T4b", {X=xpos4+xoffset, Y=ypos+1, Transparency=ytb})
	SetLayerStyle("T4c", {Y=ypos})

	EndRefresh()
	If xoffset>0 Then xoffset=50-CurrentTimer/500
	If xoffset<0 Then xoffset=0
EndFunction


@DISPLAY {Width = 650, Height = 400, Color = $555555, Layers = True}

startpos=GetAttribute(#DISPLAY, 1, #ATTRHEIGHT)
fsize=100
ypos=startpos-fsize
xoffset=0

SetFont(#SERIF, fsize)
SetFontColor("$FFAA22")
SetFontStyle(#BORDER, #WHITE, 1)

scrollspeed=1.5 ; pixel/s

xpos1=50
TextOut(xpos1, ypos, "T", {Name="T1", Transparency=0})

xpos2=200
TextOut(xpos2, ypos, "T", {Name="T2a", Transparency=0})
TextOut(xpos2, ypos, "T", {Name="T2b", Transparency=0})

xpos3=350
TextOut(xpos3, ypos, "T", {Name="T3a", Transparency=0})
TextOut(xpos3, ypos, "T", {Name="T3b", Transparency=0})
TextOut(xpos3, ypos, "T", {Name="T3c", Transparency=0})

xpos4=500
SetFontStyle(#BORDER, "$FFAA22", 1)
TextOut(xpos4, ypos, "T", {Name="T4a", Transparency=0})
TextOut(xpos4, ypos, "T", {Name="T4b", Transparency=0})
TextOut(xpos4, ypos, "T", {Name="T4c", Transparency=0})

StartTimer(1)

Period=1000/27 ; 27 Hz refresh frequency
SetInterval(1, p_Scroll, Period)

Repeat
	WaitEvent
Forever
User avatar
airsoftsoftwair
Posts: 5425
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Slow moving objects

Post by airsoftsoftwair »

Hmm, maybe you're looking for something like this?
Flinx
Posts: 188
Joined: Sun Feb 14, 2021 9:54 am
Location: Germany

Re: Slow moving objects

Post by Flinx »

That's not what I meant. When moving objects, the Easing Library does similar things to my program, except that where I calculate an acceleration from the time available, a function determines the transition. In the examples you can also see that the slow movements are only pixel by pixel.
My suggestion rather aims directly at the internal drawing function of Hollywood. The color values of all pixels of an object would have to be spread to two or four pixels depending on the fractional part of the x and y value (as a floating point number), similar to what is done in an antialiasing function.
This is probably not easy.
Visually you can achieve a similar effect by creating a large display and then scaling it down with the scale engine, but of course that is much too slow.
Bugala
Posts: 1168
Joined: Sun Feb 14, 2010 7:11 pm

Re: Slow moving objects

Post by Bugala »

That's a pretty neat trick you have there. I don't notice the movement of the second and fourth at all. I had to place a mouse pointer below them to verify they actually are moving, especially the fourth one is very smooth movement, makes me think I have 8K display.
User avatar
airsoftsoftwair
Posts: 5425
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Slow moving objects

Post by airsoftsoftwair »

Flinx wrote: Sun Dec 12, 2021 12:15 pm My suggestion rather aims directly at the internal drawing function of Hollywood. The color values of all pixels of an object would have to be spread to two or four pixels depending on the fractional part of the x and y value (as a floating point number), similar to what is done in an antialiasing function.
This is probably not easy.
Yeah, that's clearly beyond the scope of Hollywood's drawing library. It's really only designed to support primitives, not any advanced functions.
Flinx
Posts: 188
Joined: Sun Feb 14, 2021 9:54 am
Location: Germany

Re: Slow moving objects

Post by Flinx »

Ok, thank you. I will try with the trick from the example above.
But if at some point you'll find nothing more to improve at all...

Ralf
User avatar
fingus
Posts: 269
Joined: Fri Sep 16, 2011 9:53 am

Re: Slow moving objects

Post by fingus »

Sounds like Subpixel-Scrolling (transition over two pixels by fading out single RGB-Triplets on first pixel und turn them on on the newpos Subpixel.)

This technique istn´t really new. The Amiga Game Masterblazer use this trick for the Checkerboard-Floor in order to have a more fluent Movement, which Cut down the Resolution but looks great!

https://www.youtube.com/watch?v=-K2ihEZh9Os
Flinx
Posts: 188
Joined: Sun Feb 14, 2021 9:54 am
Location: Germany

Re: Slow moving objects

Post by Flinx »

Of course I didn't think I was the first one with this idea (but I didn't have a name for it), but I still hope the effect could be helpful enough for other users to put some effort into it.
Post Reply