PDA

View Full Version : New OSD!



Promixis
April 20th, 2005, 04:21 PM
New OSD object... docs below...

The On Screen Display (OSD)
The OSD table holds the following functions.

osd, error = osd.CreateOSD()
image,error = osd.CreateImage(filename)
pen = osd.CreatePen(width, Brush)
brush = osd.CreateSolidBrush( Color )
brush = osd.CreateLinearGradientBrush( number x1,y1,x2,y2, Color1, Color2 )
brush = osd.CreateTexturedBrush( Image, [WrapMode, x1,y1,x2,y2 ] )
brush = osd.CreateHatchBrush( Hatch, color1, color2 )

color = osd.MakeARGB(alpha, red,green, blue)

The MarkARGB function generates a number that represents the color and alpha intensities that you specified.

the OSD Object
The OSD object has the folling members

Destroy()
Show()
Hide()
SetTranparancy( colorkey, transparancy )
Position( x,y)
Size( w,h)
Topmost( bool )
Line ( x1,y1, x2, y2, Pen)
w,h = MeasureString( Text, FontName, FontSize)
w,h = MeasureStringFull( Text, FontName, FontSize, BoxWidth, BoxHeight, HorizonalAlignment, VerticalAlignment)
DrawString( Text, FontName, FontSize, Brush)
DrawStringFull( Text, FontName, FontSize, BoxWidth, BoxHeight, HorizonalAlignment, VerticalAlignment, Brush)
DrawImage(Image, x,y)
ScaleDrawImage( Image, x, y, Width, Height )
FillRectangle( x,y,width, height, Brush)
DrawRectangle( x,y,width, height, Pen)
FillEllipse( x,y,width, height, Brush)
DrawEllipse( x,y,width, height, Pen)
FillPie( x,y,width, height, StartAngle, SweepAngle, Brush)
DrawPie( x,y,width, height, StartAngle, SweepAngle, Pen)
OnClick( OnClick function )
OnPaint( OnPaint function )
WorkOnBuffer(bool)
CopyBufferToScreen()
SetSmoothingMode(mode)
SetInterpolationMode(mode)
Clear(color)


Destroy destroys the window
Show, shows the window
Hide, hides the window
Size, resizes the window, note: The window is not automatically redrawn!
Topmost, sets the topmost flag on the window, if true, this window will float over any other windows.
Line, draws a line
MeasureString, returns the size of the bounding box of that particular string.
MeasureStringFull, returns the size of the bounding box of that particular string.
DrawString, draws the string on the OSD
DrawStringFull, draws the string on the OSD
DrawImage, draws the Image on the OSD
ScaleDrawImage, scales and draws the image on the OSD
FillRectangle, draws a filled rectangle
DrawRectangle, draws a rectangle
FillEllipse, draws an filled ellipse
DrawEllipse, draws an ellipse
FillPie, draws a filled pie
DrawPie, draws a pie
OnClick, specifies which function should be called when the user clicks on the OSD ( function MyOnClick ( number x, number y), this allows for interactive OSDs! )
OnPaint, Drawing on the OSD is not persistent, thus it can be cleared at any momeny, the OnPaint function will be called to restore the OSD. Note that a good way around this is by drawing on the Buffer instead of the OSD, then in the OnPaint simply call CopyBufferToScreen() since the buffer is persistent. Also using the buffer is a good way to prevent screen flicker. (Double buffering).
WorkOnBuffer( boolean ), set this to true to do all the drawing in the off-screen buffer, when you are done drawing copy all of this to the main screen.
CopyBufferToScreen(), this copies the offscreen buffer to the visible OSD.
SetSmoothingMode, Sets the smoothing mode of the drawing operations.
SetInterpolationMode, set the interpolation mode of the Image scaling routines.
Clear, clears the screen in the color specified.
Image Object
The image object.

number w, number h = Image:Size()
boolean ani = Image:Animated()
Image:Animate()
Image:Pause( boolean pause )
Image:Destroy()

Call Animate if you want the image to be animated.

Pen Object
The pen, Usually used for the Drawing functions.

Pen:Destroy();
Pen:SetDashStyle(DashStyle)
Pen:SetDashCap(DashCap)
Pen:SetStartCap(LineCap)
Pen:SetEndCap(LineCap)

Brush Object
The Brush, Usually used for the Fill functions.

Brush:Destroy();

Alignment Constants
StringAlignmentNear -- Left
StringAlignmentCenter -- Center
StringAlignmentFar -- Right

Smoothing Constants
SmoothingModeDefault -- The default smoothing
SmoothingModeHighSpeed -- Fast
SmoothingModeHighQuality -- High Quality
SmoothingModeNone -- None
SmoothingModeAntiAlias - Anti Aliased

Interpolation Constants
InterpolationModeDefault -- Specifies the default interpolation mode.
InterpolationModeLowQuality -- Specifies a low-quality mode.
InterpolationModeHighQuality -- Specifies a high-quality mode.
InterpolationModeBilinear -- Specifies bilinear interpolation. No prefiltering is done. This mode is not suitable for shrinking an image below 50 percent of its original size.
InterpolationModeBicubic -- Specifies bicubic interpolation. No prefiltering is done. This mode is not suitable for shrinking an image below 25 percent of its original size.
InterpolationModeNearestNeighbor -- Specifies nearest-neighbor interpolation.
InterpolationModeHighQualityBilinear -- Specifies high-quality, bilinear interpolation. Prefiltering is performed to ensure high-quality shrinking.
InterpolationModeHighQualityBicubic -- Specifies high-quality, bicubic interpolation. Prefiltering is performed to ensure high-quality shrinking. This mode produces the highest quality transformed images.

WrapMode Constants
WrapModeTile -- Specifies tiling without flipping.
WrapModeTileFlipX -- Species that tiles are flipped horizontally as you move from one tile to the next in a row.
WrapModeTileFlipY -- Specifies that tiles are flipped vertically as you move from one tile to the next in a column.
WrapModeTileFlipXY -- Specifies that tiles are flipped horizontally as you move along a row and flipped vertically as you move along a column.
WrapModeClamp -- Specifies that no tiling takes place.

HatchStyle Constants
HatchStyleHorizontal
HatchStyleVertical
HatchStyleForwardDiagonal
HatchStyleBackwardDiagonal
HatchStyleCross
HatchStyleDiagonalCross
HatchStyle05Percent
HatchStyle10Percent
HatchStyle20Percent
HatchStyle25Percent
HatchStyle30Percent
HatchStyle40Percent
HatchStyle50Percent
HatchStyle60Percent
HatchStyle70Percent
HatchStyle75Percent
HatchStyle80Percent
HatchStyle90Percent
HatchStyleLightDownwardDiagonal
HatchStyleLightUpwardDiagonal
HatchStyleDarkDownwardDiagonal
HatchStyleDarkUpwardDiagonal
HatchStyleWideDownwardDiagonal
HatchStyleWideUpwardDiagonal
HatchStyleLightVertical
HatchStyleLightHorizontal
HatchStyleNarrowVertical
HatchStyleNarrowHorizontal
HatchStyleDarkVertical
HatchStyleDarkHorizontal
HatchStyleDashedDownwardDiagonal
HatchStyleDashedUpwardDiagonal
HatchStyleDashedHorizontal
HatchStyleDashedVertical
HatchStyleSmallConfetti
HatchStyleLargeConfetti
HatchStyleZigZag
HatchStyleWave
HatchStyleDiagonalBrick
HatchStyleHorizontalBrick
HatchStyleWeave
HatchStylePlaid
HatchStyleDivot
HatchStyleDottedGrid
HatchStyleDottedDiamond
HatchStyleShingle
HatchStyleTrellis
HatchStyleSphere
HatchStyleSmallGrid
HatchStyleSmallCheckerBoard
HatchStyleLargeCheckerBoard
HatchStyleOutlinedDiamond
HatchStyleSolidDiamond
HatchStyleTotal

LineCap Constants
LineCapFlat
LineCapSquare
LineCapRound
LineCapTriangle
LineCapNoAnchor
LineCapSquareAnchor
LineCapRoundAnchor
LineCapDiamondAnchor
LineCapArrowAnchor

DashStyle Constants
DashStyleSolid
DashStyleDash
DashStyleDot
DashStyleDashDot
DashStyleDashDotDot

DashCap Constants
DashCapFlat
DashCapRound
DashCapTriangle

Ron
April 20th, 2005, 05:54 PM
Ehm Mike, I don't think I released this one yet :-)

Ron
April 20th, 2005, 06:01 PM
For people that can't wait for the next release, this OSD is REALLY NEAT!

quixote
April 20th, 2005, 08:13 PM
:-?
I think I'll wait.
So everything needs to be scripted in LUA?

Promixis
April 20th, 2005, 08:37 PM
yes, too many options for the a tree.

quixote
April 20th, 2005, 08:40 PM
It would be great to see some working practical examples, whenever you have the opportunity. I find it easier to learn from examples than from instructions most of the time.

Promixis
April 20th, 2005, 08:48 PM
:D

father of monstermagnet
April 21st, 2005, 11:56 AM
Does


OnClick, specifies which function should be called when the user clicks on the OSD ( function MyOnClick ( number x, number y), this allows for interactive OSDs! )

mean you can create as many buttons you like ?

The end of IEApp and Htmlosd ?

Promixis
April 21st, 2005, 12:04 PM
You can use it this way if you want...

quixote
April 22nd, 2005, 05:54 PM
Wow! I finally had a chance to look at the example, and it is really cool. The possibilities! :D

I particularly like the animated .GIF functionality.

JSMain
April 23rd, 2005, 11:13 AM
Trying to get this running!

It is a plugin right?

What supporting plugins are required to make it work?

I'm obviously missing something!

Ron
April 23rd, 2005, 11:21 AM
It is actually not a plugin, it is one of the main libraries, just drop it into the Girder directory.

JSMain
April 23rd, 2005, 11:45 AM
I considered that as well, but still nothing.
I also shut down and restarted girder to make sure it "linked", But I suspect it's not as nothing is telling it it's there, or required.

Ron
April 23rd, 2005, 12:08 PM
This is not a plugin btw, it only shows up in Lua, how are you checking if it is loaded?

JSMain
April 23rd, 2005, 12:11 PM
Trying to execute the GML examples. Nothing occurs, assuming it isn't loaded because of this.

Ron
April 23rd, 2005, 12:25 PM
Can you check if the 'osd' table exists in the variable explorer?

quixote
April 23rd, 2005, 12:26 PM
All I did to get it to work was decompress the file auxilliary.dll to my main Girder dir and clicked yes when it asked me if I wish to overwrite the other file. I think that the animated GIF example requires that you put a .GIF in the directory refered to in the script with the same name (I forget the name of the file). There were only a couple that didn't work for me, but I didn't investigate further, I was just skimming through the examples to see what is available. Good luck.

JSMain
April 23rd, 2005, 12:32 PM
There wasn't an auxillary previously there....

This is the only OSD reference I found...

JSMain
April 23rd, 2005, 12:33 PM
Hold the phone!

I thought a10 was the latest! I see a11 is out! I'll try that!

Not sure how i missed that update...

Ron
April 23rd, 2005, 12:36 PM
Actually 12 is coming out in a matter of minutes, so hold your horses.

The OSD table should be the at the top level.

birty
April 24th, 2005, 05:46 PM
what are the parameters for measurestring? it always seems to return a width which is far too small for the string i pass in.
edit: it seems to return values up to 85 and any string larger it just returns 85 and a larger height

Ron
April 24th, 2005, 05:55 PM
w,h = MeasureString(Text, Font, FontSize)

Ron
April 24th, 2005, 06:04 PM
Something does seem to be off.

birty
April 24th, 2005, 06:10 PM
the new osd does look good though and im going to use it as an excuse to avaoid doing my boring report for the next few days :)

Ron
April 24th, 2005, 06:13 PM
Don't tell anyone but that is how Girder started back in the day, avoiding homework :-)

Ron
April 24th, 2005, 06:14 PM
I am not sure if I will get time today (it is sunday after all ;-) ) but this is on the list for monday. Hopefully we'll have a new release by the end of the day monday.

JSMain
April 25th, 2005, 06:17 AM
Wow!
I installed 12, but hadn't had a chance to see if this worked yet, and already you're getting prepared to release another new version....

birty
April 26th, 2005, 04:17 AM
i cant seem to get double buffering to work properly, if the osd is destroyed and recreated then the osd is updated correctly, this causes the osd to flash on and off though (rather defats the object of double buffering), if the osd is not recreated then the OSD stays the same as the first time it was painted (i am using the examples from osd.gml by the way)

birty
April 26th, 2005, 07:08 AM
managed to get it to work by moving CopyBufferToScreen() to the end of the script as well as in the onpaint function

Ron
April 26th, 2005, 11:03 AM
That is rigth, first you draw on the buffer and when you are done with it copy it one the screen, and you'll have to do that in the onpaint function because windows will erase the screen.