G2D Area Object

This subset of the G2D Library provide one object and some methods to handle rectangular graphics areas, it is useful because you can define and manage an undefinite number of rectangular areas that can be skinned using a very flexible and multilayared system.

  • G2D.Area:Box(color, offset)
  • G2D.Area:FillColor(color)
  • G2D.Area:FillPattern(BrushID)
  • G2D.Area:Move(x, y, absolute)
  • G2D.Area:New(x, y, w, h)
  • G2D.Area:Scale(WFactor, HFactor)
  • G2D.Area:SkinBevel(colors, aspect)
  • G2D.Area:SkinColor(color, alpha)
  • G2D.Area:SkinFitMax(brush, offset, alpha, align)
  • G2D.Area:SkinFitMin(brush, offset, alpha, align, border)
  • G2D.Area:SkinGradient(col1, col2, alpha, angle)
  • G2D.Area:SkinHPattern(brush, offset, alpha)
  • G2D.Area:SkinHPattern3S(brush, sectors, alpha, vadapt)
  • G2D.Area:SkinMulti(levels, offset)
  • G2D.Area:SkinPattern(brush, offset, alpha, size)
  • G2D.Area:SkinPattern9S(brush, sectors, alpha, vadapt)
  • G2D.Area:SkinQuick(SkinBrush, Mode)
  • G2D.Area:SkinShades(colList, angle)
  • G2D.Area:SkinStretch(brush, offset, alpha, stretch_fix)
  • G2D.Area:SkinVPattern(brush, offset, alpha)
  • G2D.Area:SkinVPattern3S(brush, sectors, alpha, vadapt)
  • G2D.Area:Snapshot(BGPic)


G2D.Area:Box(color, offset)

G2D.Area:Box(color, offset)

Draw a border around the area, offset will be used to make an inner box or an outer box depending if offset value is negative or positive.

INPUT

  • color : Border color
  • offset : Offset value to make the box smaller or bigger than the actual area size.


G2D.Area:FillColor(color)

G2D.Area:FillColor(Color)

Fill the area object with given 'Color'.

INPUT

  • Color : The fill color


G2D.Area:FillPattern(BrushID)

G2D.Area:FillPattern(brushID)

Fill the area object using the given brush as a pattern.

INPUT

  • BrushID : A valid Hollywood brush id


G2D.Area:Move(x, y, absolute)

G2D.Area:Move(x, y, absolute)

Move the area object to another position or by a given amount, depending on the 'absolute' switch state.

INPUT

  • x : Optional horizontal position or relative horizontal movement
  • y : Optional vertical position or relative vertical movement
  • absolute : Optional True to use the horizontal and vertical values as a new absolute position, or False to use these values as relative position.
    Default = False.


G2D.Area:New(x, y, w, h)

areaObj = G2D.Area:New(x, y, w, h)

Creates and returns a new Area object.

INPUT

  • x : Optional horizontal coordinate, default = 0
  • y : Optional vertical coordinate, default = 0
  • w : Optional width in pixels, default = 50
  • h : Optional height in pixels, default = 50

OUTPUT

  • areaObj : New, initialized Area object


G2D.Area:Scale(WFactor, HFactor)

G2D.Area:Scale(wFactor, hFactor)

Scales the area using the given horizontal and vertical factors.

INPUT

  • wFactor : Horizontal scaling factor
  • hFactor : Vertical scaling factor


G2D.Area:SkinBevel(colors, aspect)

result = G2D.Area:SkinBevel(colors, aspect)

Use this method to skin the specified 'area'. 'colors' is a table describing which colors must be used to render the bevel box.

INPUT

  • colors : A table with the color to use, must have the following fields:
    • light : Light Edges (top and left)
    • dark : Dark Edges (bottom and right)
    • middle : Internal color (set to nil to leave it empty)
  • aspect : It is a table with further parameters with the following fields:
    • fx : Can be one of the following effect : GFX.BevelFx_Raised, GFX.BevelFx_Recessed, GFX.BevelFx_Flat
    • height : Border's height
    • type : Bevel box type : GFX.BevelType_Standard, GFX.BevelType_Sunken

OUTPUT

  • result : Returns True if no error was raised-


G2D.Area:SkinColor(color, alpha)

result = G2D.Area:SkinColor(color, alpha)

Use this function to skin the area object, color can be in RRGGBB format or in AARRGGBB format. 'alpha' is the transparency level, but remember that if you are using a color in AARRGGBB format the alpha channel will be replaced by the 'alpha' value.

INPUT

  • color : The color you want to fill the area with.
  • alpha : With this parameter you can override the color's alpha channel (if defined) with a custom one. Set this parameter with #NONE to leave untouched the color's alpha channel.

OUTPUT

  • result : Returns True if no error was raised-


G2D.Area:SkinFitMax(brush, offset, alpha, align)

result = G2D.Area:SkinFitMax(brush, offset, alpha, align)

Skin the area object with a scaled brush maintaining its aspect ratio. The brush can be shifted using the 'offset' table and you can control transparency with 'alpha' argument ovverriding the existing one if defined.
Using this function the image will be maximized to cover the entire area, it may be possible that the image can be not completely visible because some part go outside the visible area because of the maximization and the aspect ratio.

INPUT

  • brush : The brush to use to skin the area. It can be a brush id or a filename, in the last case the brush will be loaded, used and removed from memory.
  • offset : This table is used to shift horizontally, vertically or in both directions the brush. It must have the following fields:
    • x : Horizontal shift in pixels
    • y : Vertical shift in pixels
  • alpha : With this parameter you can override the brush's alpha channel (if defined) with a custom one. Set this parameter to #NONE to leave untouched the brush's alpha channel.
  • align : Horizontal image alignment, can be #CENTER, #LEFT, #RIGHT, #TOP, or #BOTTOM, default value is #CENTER.

OUTPUT

  • result : Returns True if no error was raised-


G2D.Area:SkinFitMin(brush, offset, alpha, align, border)

result = G2D.Area:SkinFitMin(brush, offset, alpha, align, border)

Skin the area object with a scaled brush maintaining its aspect ratio. The brush can be shifted using the table <offset> and you can control transparency with 'alpha' argument ovverriding the existing one if defined.
Using this function the image will be maximized to cover the entire area but without letting the image go out of the area boundaries so you could have visible borders.

INPUT

  • brush : The brush to use to skin the area. It can be a brush id or a filename, in the last case the brush will be loaded, used and removed from memory.
  • offset : This table is used to shift horizontally, vertically or in both directions the brush. It must have the following fields:
    • x : Horizontal shift in pixels
    • y : Vertical shift in pixels
  • alpha : With this parameter you can override the brush's alpha channel (if defined) with a custom one. Set this parameter to #NONE to leave untouched the brush's alpha channel.
  • align : Horizontal image alignment, can be #CENTER, #LEFT, #RIGHT, #TOP, #BOTTOM, default value is #CENTER.
  • border : Border color.

OUTPUT

  • result : Returns True if no error was raised-


G2D.Area:SkinGradient(col1, col2, alpha, angle)

result = G2D.Area:SkinGradient(col1, col2, alpha, angle)

This method is able to skin area object using a linear color gradient defined by 'col1' and 'col2'. You can control transparency using 'alpha' and you can also rotate the gradient using the parameter 'angle'.

INPUT

  • col1 : Fill color 1 in RRGGBB format, any alpha channel informations will be ignored.
  • col2 : Fill color 2 in RRGGBB format, any alpha channel informations will be ignored.
  • alpha : Use this parameter to control the gradient transparency, set it to #NONE to have the gradient fully opaque.
  • angle : Rotation angle of the gradient.

OUTPUT

  • result : Returns TRUE if the operation has been completed without errors.


G2D.Area:SkinHPattern(brush, offset, alpha)

result = G2D.Area:SkinHPattern(brush, offset, alpha)

This method is used to skin the area object using 'brush'. The brush will be first stretched to the area height and then the area will be filled with the stretched brush.
You can control transparency with 'alpha' overriding the brush alpha channel, if defined.

INPUT

  • brush : The brush to use to skin the area. It can be a brush id or a filename, in the last case the brush will be loaded, used finally removed from memory.
  • offset : This table is used to shift the brush horizontally, vertically or in both directions. It must have the following fields:
    • x : Horizontal shift in pixels
    • y : Vertical shift in pixels
  • alpha : With this parameter you can override the brush's alpha channel, if defined, with a custom one. Set this parameter to #NONE to leave untouched the brush's alpha channel.

OUTPUT

  • result : Returns TRUE if the operation has been completed without errors.


G2D.Area:SkinHPattern3S(brush, sectors, alpha, vadapt)

result = G2D.Area:SkinHPattern3S(brush, sectors, alpha, vadapt)

This method is used to skin the area object using 'brush'. The brush should be an horizontal strip subdivided in three sectors, described by the 'sectors' table).
The left side and right sides are fixed sized while the middle part will be used to fill the area width repeating the middle part, or, if 'vadapt' is set to TRUE, the middle part will be stretched.
You can control transparency with 'alpha' overriding the brush alpha channel, if defined.

INPUT

  • brush : The brush to use to skin the area. It can be a brush id or a filename, in the last case the brush will be loaded, used finally removed from memory.
  • sectors : It's a table describing the three brush's areas as following:
    • left : { start = starting_x_position, size = left_part_width }
    • middle : { start = starting_x_position, size = middle_part_width },
    • right : { start = starting_x_position, size = right_part_width }
  • alpha : With this parameter you can override the brush's alpha channel, if defined, with a custom one. Set this parameter to #NONE to leave untouched the brush's alpha channel.
  • vadapt : If set to TRUE, the middle part will be stretched instead of been used as a fill pattern.

OUTPUT

  • result : Returns TRUE if the operation has been completed without errors.


G2D.Area:SkinMulti(levels, offset)

result = G2D.Area:SkinMulti(levels, offset)

This method is used to skin the area object according to the skin levels listed in 'levels' table.
With this method you can apply multiple skin layers to an area object.

INPUT

  • levels : Table describing each skin level to apply to the area, each entry must have the following fields:
    • area : This table represent a sub-area to adjust the level position and size, values specified here will be added to the correspondenting fields of the area we have to skin.
      This parameter is optional. If specified, the table, must have the fields : x, y, w, h
    • type : This field is used to specify what skin mode must be used for this level, it can be one of the following:
      • GFX.SkinType_Stretch
      • GFX.SkinType_Pattern
      • GFX.SkinType_FitMax
      • GFX.SkinType_FitMin
      • GFX.SkinType_Color
      • GFX.SkinType_Gradient
      • GFX.SkinType_Shades
      • GFX.SkinType_VPattern
      • GFX.SkinType_HPattern
      • GFX.SkinType_VPattern3S
      • GFX.SkinType_HPattern3S
      • GFX.SkinType_Pattern9S
      • GFX.SkinType_Bevel
    • params : This is a table with further values needed by each skin mode, below, for each skin type, will be listed all fields that must be provided in this table:
      • GFX.SkinType_Stretch
        • brush : Brush id or brush filename
        • offset : Skin offset, must have:
          • x : Offset X
          • y : Offset Y
        • alpha : Transparency or #NONE
        • stretch_fix : See notes at the top of this module
      • GFX.SkinType_Pattern
        • brush : Brush id or brush filename
        • offset : Skin offset, must have:
          • x : Offset X
          • y : Offset Y
        • alpha : Transparency or #NONE or any positive value to override brush's alpha channel.
        • size : Optional size of the single tile, is specified, must have:
          • w : Horizontal size
          • h : Vertical size
      • GFX.SkinType_FitMax
        • brush : Brush id or brush filename
        • offset : Skin offset, must have:
          • x : Offset X
          • y : Offset Y
        • alpha : Transparency or #NONE or any positive value to override brush's alpha channel.
        • align : Horizontal skin alignment, can be:
          • #LEFT
          • #CENTER
          • #RIGHT
      • GFX.SkinType_FitMin
        • brush : Brush id or brush filename
        • offset : Skin offset, must have:
          • x : Offset X
          • y : Offset Y
        • alpha : Transparency or #NONE or any positive value to override brush's alpha channel.
        • align : Horizontal skin alignment, can be:
          • #LEFT
          • #CENTER
          • #RIGHT
        • border : Borders color
      • GFX.SkinType_Color
        • color : Solid color to use
        • alpha : Transparency or #NONE or any positive value.
      • GFX.SkinType_Gradient
        • color1 : Gradient's starting color
        • color2 : Gradient's ending color
        • alpha : Transparency or #NONE or any positive value.
        • angle : Gradient's angle
      • GFX.SkinType_Shades *
        • ColorList : Table used to define the shades, each entry must have the following fields:
          • Color : Color in RRGGBB notation
          • Weight : Band ColorN ↔ ColorN+1 weight
          • Alpha : Color transparency level
        • angle : Shades's angle. Actually only 0, 90, 180, 270, …
          are rendered correctly.
      • GFX.SkinType_VPattern
        • brush : Brush id or brush filename
        • offset : Skin offset, must have:
          • x : Offset X
          • y : Offset Y
        • alpha : Transparency or #NONE or any positive value to override brush's alpha channel.
      • GFX.SkinType_HPattern
        • brush : Brush id or brush filename
        • offset : Skin offset, must have:
          • x : Offset X
          • y : Offset Y
        • alpha : Transparency or #NONE or any positive value to override brush's alpha channel.
      • GFX.SkinType_VPattern3S
        • brush : Brush id or brush filename
        • sectors : Table describing skin sectors:
          • top : Top sector
            • start : Starting y coordinate
            • height sector's height
          • middle : Middle sector
            • start : Starting y coordinate
            • height : sector's height
          • bottom : Bottom sector
            • start : Starting y coordinate
            • height : sector's height
        • alpha : Transparency or #NONE or any positive value to override brush's alpha channel.
        • vadapt : Adapt the brush size vertically
      • GFX.SkinType_HPattern3S
        • brush : Brush id or brush filename
        • sectors : Table describing skin sectors:
          • left : Left sector
            • start : Starting x coordinate
            • width sector's width
          • middle : Middle sector
            • start : Starting x coordinate
            • width : sector's width
          • right : Right sector
            • start : Starting x coordinate
            • width : sector's width
        • alpha : Transparency or #NONE or any positive value to override brush's alpha channel.
        • vadapt : Adapt the brush size vertically
      • GFX.SkinType_Pattern9S
        • brush : Brush id or brush filename
        • sectors : Table describing skin sectors:
          • left : Left sector
            • start : Starting x coordinate
            • width sector's width
          • hmiddle : Middle sector
            • start : Starting x coordinate
            • width : sector's width
          • right : Right sector
            • start : Starting x coordinate
            • width : sector's width
          • top : Top sector
            • start : Starting y coordinate
            • height sector's height
          • vmiddle : Middle sector
            • start : Starting y coordinate
            • height : sector's height
          • bottom : Bottom sector
            • start : Starting y coordinate
            • height : sector's height
        • alpha : Transparency or #NONE or any positive value to override brush's alpha channel.
        • vadapt : Adapt the brush size vertically
      • GFX.SkinType_Bevel
        • colors : Colors table
          • Light : Light color
          • Dark : Dark color
          • Middle : Middle color (NIL for empty bevels)
        • aspect : Further aspect options
          • fx : Can be one of the following:
            • GFX.BevelFx_Raised
            • GFX.BevelFx_Recessed
            • GFX.BevelFx_Flat
        • height : Border's height
        • type : Bevel type, one of the following:
          • GFX.BevelType_Standard
          • GFX.BevelType_Sunken
  • offset : Optional table with the global skin offset for all levels that needs it. It must hold the fields 'x' and 'y'.

OUTPUT

  • result : Returns TRUE if the operation has been completed without errors.


G2D.Area:SkinPattern(brush, offset, alpha, size)

result = G2D.Area:FkinPattern(Brush, Offset, Alpha, Size)

Skin the area object with the 'Brush' pattern. The brush can be shifted using the 'Offset' table, you can control transparency with 'Aplha' argument.

INPUT

  • Brush : The brush to use to skin the area. It can be a brush id or a filename, in the last case the brush will be loaded, used and and removed from memory just after the rendering.
  • Offset : This table is used to shift horizontally, vertically or in both directions the brush. It must have the following fields:
    • x : Horizontal shift in pixels
    • y : Vertical shift in pixels
  • Alpha : With this parameter you can override the brush's alpha channel (if defined) with a custom one. Set this parameter to #NONE to leave untouched the brush's alpha channel.
  • Size : Optional tile size, it must have the fields:
    • w : Tile width in pixels
    • h : Tile height in pixels

OUTPUT

  • result : True if all gone fine.


G2D.Area:SkinPattern9S(brush, sectors, alpha, vadapt)

result = G2D.Area:SkinPattern9S(brush, sectors, alpha, vadapt)

This method is used to skin the area object using 'brush'. This method needs a brush subdivided in 9 sectors that will be described using the 'sectors' table.

INPUT

  • brush : The brush to use to skin the area. It can be a brush id or a filename, in the last case the brush will be loaded, used finally removed from memory.
  • sectors : It's a table describing the three brush's areas as following:
    • top : { start = starting_y_position, size = top_part_height }
    • vmiddle : { start = starting_y_position, size = middle_part_height }
    • bottom : { start = starting_y_position, size = bottom_part_height }
    • left : { start = starting_x_position, size = left_part_width }
    • hmiddle : { start = starting_x_position, size = middle_part_width }
    • right : { start = starting_x_position, size = right_part_width }
  • alpha : With this parameter you can override the brush's alpha channel, if defined, with a custom one. Set this parameter to #NONE to leave untouched the brush's alpha channel.
  • vadapt : If set to TRUE, the middle parts will be stretched instead of been used as fill patterns.

OUTPUT

  • result : Returns TRUE if the operation has been completed without errors.


G2D.Area:SkinQuick(SkinBrush, Mode)

G2D.Area:SkinQuick(SkinBrush, Mode)

Method used to fill the area object with a skin without the need to specify too much parameters.

INPUT

  • SkinBrush : A valid Hollywood brush id to use as a fill base.
  • Mode : Ones skinning mode from the following:
    • GFX.SkinMode_Pattern : The brush will be used as a tile
    • GFX.SkinMode_Image : The brush will be stretched to cover the area
    • GFX.SkinMode_Skin9S : The brush will be splitted in nine sectors (3×3) and each one will be used to skin the area this way:
      Brush Sectors:
      +-+-+-+ A: Top-left edge
      |A|B|C| B: Top-middle (horizontal pattern)
      +-+-+-+ C: Top-right edge
      |D|E|F| D: Left-middle (vertical pattern)
      +-+-+-+ E: middle (area pattern)
      |G|H|I| F: Right-middle (vertical pattern)
      +-+-+-+ and so on…

NOTE
To have perfect pixel skins with the 'GFX.SkinMode_Skin9S' mode your brush size should be divisible by 3



G2D.Area:SkinShades(colList, angle)

result = G2D.Area:SkinShades(colList, angle)

This method is able to skin the area object using a parametric gradient you have to provide the table 'colList' where the color shades are defined.
You cal also rotate the color gradient but remember that only multiple of 90 90 degrees will be correctly rendered at this time.

INPUT

  • colList : Color table defining the shades with the following format: collist = { { step_1 }, { step_2 }, { step_2 }, … } Where: step_n = { Color = RRGGBBC, Weight = n, Alpha = n }
    • Color : Is a color in RRGGBB notation.
    • Weight : The last item must have Weight = 0, and the sum of all entries must be 100. This parameter is used to define the color band width, infact the Weight of the first item, for example, defines the width of the shade composed by the first and the second color entries.
    • Alpha : Is a value between 0 and 255 and will be faded along the colors during the gradient creation.
  • angle : Rotation angle of the gradient. Actually only multiple of 90 degrees will be rendered correctly.

OUTPUT

  • result : Returns TRUE if the operation has been completed without errors.


G2D.Area:SkinStretch(brush, offset, alpha, stretch_fix)

result = G2D.Area:SkinStretch(Brush, Offset, Alpha, Stretch_Fix)

Skins the area object stretching the image 'brush'. The 'brush' can be shifted shifted using the table 'offset', you can also adjust the stransparency with the 'alpha' parameter.

INPUT

  • brush : A valid Hollywood brush id or an image filename. In the last case the brush will be loaded, used and removed from memory just after the rendering.
  • offset : This table is used to shift horizontally, vertically or both directions the brush. It must have the following fields:
    • x : Horizontal shift
    • y : Vertical shift
  • alpha : With this parameter you can override the brush's alpha channel (if defined) with a custom one. Set this parameter with #NONE to leaveù untouched the brush's alpha channel.
  • stretch_fix : I've made this fix because when I stretch a brush using smooth I get an image that is bigger then the same image stretched without smooth, the difference seems to be a single pixel.

OUTPUT

  • result : Returns 'True' if there was no errors.


G2D.Area:SkinVPattern(brush, offset, alpha)

result = G2D.Area:SkinVPattern(brush, offset, alpha)

This method is used to skin the area object using 'brush', the brush will be first stretched to the area width and then the area will be filled with the stretched brush vertically.
You can control transparency with 'alpha' overriding the brush alpha channel, if defined.

INPUT

  • brush : The brush to use to skin the area. It can be a brush id or a filename, in the last case the brush will be loaded, used finally removed from memory.
  • offset : This table is used to shift the brush horizontally, vertically or in both directions. It must have the following fields:
    • x : Horizontal shift in pixels
    • y : Vertical shift in pixels
  • alpha : With this parameter you can override the brush's alpha channel, if defined, with a custom one. Set this parameter to #NONE to leave untouched the brush's alpha channel.

OUTPUT

  • result : Returns TRUE if the operation has been completed without errors.


G2D.Area:SkinVPattern3S(brush, sectors, alpha, vadapt)

result = G2D.Area:SkinVPattern3S(brush, sectors, alpha, vadapt)

This method is used to skin the area object using 'brush'. The brush should be a vertical strip subdivided in three sectors, described by the 'sectors' table).
The top side and bottom sides are fixed sized while the middle part will be used to fill the area height repeating the middle part, or, if 'vadapt' is set to TRUE, the middle part will be stretched.
You can control transparency with 'alpha' overriding the brush alpha channel, if defined.

INPUT

  • brush : The brush to use to skin the area. It can be a brush id or a filename, in the last case the brush will be loaded, used finally removed from memory.
  • sectors : It's a table describing the three brush's areas as following:
    • top : { start = starting_y_position, size = top_part_height }
    • middle : { start = starting_y_position, size = middle_part_height },
    • bottom : { start = starting_y_position, size = bottom_part_height }
  • alpha : With this parameter you can override the brush's alpha channel, if defined, with a custom one. Set this parameter to #NONE to leave untouched the brush's alpha channel.
  • vadapt : If set to TRUE, the midlle part will be stretched instead of been used as a fill pattern.

OUTPUT

  • result : Returns TRUE if the operation has been completed without errors.


G2D.Area:Snapshot(BGPic)

brush = G2D.Area:snapshot(BGPic)

This method returns a brush with the content 'seen' by the object area.
'BGPic' is the currently active background picture, if you don't specify it BGPic 1 will be selected.

INPUT

  • BGPic : Optional BGPic, default = 1

OUTPUT

  • brush : Brush id of the captured area


hollywoodlibs/g2d/area.txt · Ultima modifica: 2017/04/24 21:09 da admin
CC Attribution-Noncommercial 4.0 International
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0