GFX Misc Functions

Here are all the other functions included in the GFX Library:

  • GFX.Brush.HShift(brush, x)
  • GFX.Brush.VShift(brush, y)
  • GFX.DisplayExists(dispID)
  • GFX.GetHostSize()
  • GFX.ImageFX.AddFrame(image_brush, border, shadow, infos, size, rounding)
  • GFX.ImageFX.Reflex(image, direction, scale, color, color_strenght, alpha, kill_source)
  • GFX.ImageFX.Scale(image, destx, desty, IsSprite, Maximize, ExactSize, NewWithAlpha)
  • GFX.SafeClipRegion(ClipID, Shape, xStart, yStart, Width, Height)
  • GFX.Text.GetWidth(txt)
  • GFX.Text.WordWrap(txt, length)


GFX.Brush.HShift(brush, x)

result = GFX.Brush.HShift(brush, x)

Shift horizontally the given 'brush' by 'x' pixels.

INPUT

  • brush : Brush to shift
  • x : Shift amount in pixels

OUTPUT

  • result : True if the brush was successfully shifted


GFX.Brush.VShift(brush, y)

result = GFX.Brush.VShift(brush, x)

Shift vertically the given <brush> by <y> pixels.

INPUT

  • brush : Brush to shift
  • y : Shift amount in pixels

OUTPUT

  • result : True if the brush was successfully shifted


GFX.DisplayExists(dispID)

result = GFX.DisplayExists(dispID)

Returns TRUE if the given display exists otherwise returns FALSE.

OUTPUT

  • result : True if the display id exists, otherwise False will be returned,


GFX.GetHostSize()

width, height = GFX.GetHostSize()

In a single call returns the current host width & host height.

OUTPUT

  • width : Host screen width
  • height : Host screen height


GFX.ImageFX.AddFrame(image_brush, border, shadow, infos, size, rounding)

brush = GFX.ImageFX.AddFrame(image_brush, border, shadow, infos, size)

This func will build a photo-frame-like around the source image, it returns a new brush or separated brushes, one for each effect applied.

INPUT

  • image_brush : Brush we want to process
  • border : A table describing the frame we want to build
    → width : Left, Right and Top border size
    → bottom : Bottom size
    → color : Frame color
    → alpha : Frame transparency
  • shadow : Frame shadow
    → active : Set to True if you want to render a shadow
    → offset : A table with the shadow's offset x : Horizontal shadow's offset y : Vertical shadow's offset
    → separated : Set to True to obtain the shadow into a separate brush
    → alpha : Shadow's transparency
    → color : Shadow's color
  • infos : A table used to render informations into the frame bottom
    → row1left : Information row nr.1, left aligned
    → row1right : Information row nr.1, right aligned
    → row2left : Information row nr.2, left aligned
    → font : GFX.Font object for informations rendering
    → separated : Set to True to obtain the informations into a separate brush
  • size : A table with the maximum size of the final brush
    → width : Width
    → height : Height
  • rounding : Box rounding value (0:off, 100:Max, default=0)

OUTPUT

  • frame_brush : The processed brush
  • shadow_brush : If requested, the shadow brush
  • infos_brush : If requested, the informations brush


GFX.ImageFX.Reflex(image, direction, scale, color, color_strenght, alpha, kill_source)

brush = GFX.ImageFX.Reflex(image, direction, scale, color, color_strenght, alpha, kill_source)

Apply a reflection fx to the given 'image' brush. The function returns a new processed brush leaving the source image untouched.

INPUT

  • Image : Brush id of the source brush
  • Direction : Direction of the reflection to apply, it can be:
    → #GFX_REFLEXBOTTOM (default)
    → #GFX_REFLEXTOP
    → #GFX_REFLEXRIGHT
    → #GFX_REFLEXLEFT
  • Scale : The scaling factor of the reflected image (default = 0.5)
  • Color : The color to apply to the reflection (default = #BLACK)
  • Color_Strenght : The strenght of the color to apply (0=off, 255=Max, default=125)
  • Alpha : The alpha value to apply to the reflection (0=invisible, 255=opaque, -1=off, default=-1)
  • Kill_Source : If set to True the source brush 'image' will be removed from memory after the reflection has been generated.

OUTPUT

  • rBrush : Image+Reflection brush


GFX.ImageFX.Scale(image, destx, desty, IsSprite, Maximize, ExactSize, NewWithAlpha)

GFX.ImageFX.Scale(image, destx, desty, isSprite, Maximize, ExactSize, NewWithAlpha)

Scale a brush or a sprite keeping image proportions. The source image will be modified directly.

INPUT

  • Image : Brush or sprite id to scale
  • destX : Width target
  • destY : Height target
  • isSprite : Set to <true> if you are scaling a sprite
  • Maximize : Set to <true> to maximize the image
  • ExactSize : Set to <true> to get a new brush of the exact sizes specified.
    Using this flag the source image will be lost.


GFX.SafeClipRegion(ClipID, Shape, xStart, yStart, Width, Height)

clipID = GFX.SafeClipRegion(ClipID, Shape, xStart, yStart, Width, Height)

Create a ClipRegion and adjust coordinates to prevent illegal values, for example to prevent clip areas defined out of the current display region.

INPUT

  • ClipID : Clip region ID or Nil
  • Shape : Clip region shape (see Hollywood docs)
  • xStart : Starting X
  • yStart : Starting y
  • Width : Area width
  • Height : Area height

OUTPUT

  • clipID : Clip region id


GFX.Text.GetWidth(txt)

textWidth = GFX.Text.GetWidth(txt)

Returns the 'txt' width in pixels taking into account Hollywood tags.

INPUT

  • txt : Text to measure

OUTPUT

  • textWidth : Text width in pixels
  • cleanedText : Text cleaned from all Hollywood tags


GFX.Text.WordWrap(txt, length)

tblText = GFX.Text.WordWrap(txt, length)

Returns the 'tblText' a table with all word wrapped strings (splitted text lines).

INPUT

  • txt : Text to handle

OUTPUT

  • tblText : A table with all word-wrapped strings

NOTES
Please note that the wordwrap is calculated using the current font so you need to setup the font you wish to usi to print this 'txt' before calling this function.
This routine will try to find a break point near a punctuaction character or a space, but if it is not possible will break the string where needed.

hollywoodlibs/gfx/misc.txt · Ultima modifica: 2016/11/18 11:32 da admin
CC Attribution-Noncommercial 4.0 International
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0