GFX Image Object

The Image object, and all related methods, helps when you have to manage several images, allowing you to track all loaded brushes and providing useful methods for the most common operations.

  • GFX.Image.Get(ImageName)
  • GFX.Image.List()
  • GFX.Image:Add(ImageName, ImageFile, Size)
  • GFX.Image:Clone(ClonedName, TintParams)
  • GFX.Image:Draw(Position)
  • GFX.Image:NewLayer(LayerName, Position, Hidden)
  • GFX.Image:Reload()
  • GFX.Image:Remove()
  • GFX.Image:Resize(width, height, smooth)


GFX.Image.Get(ImageName)

imageObj = GFX.Image.Get(Name)

Returns the image object with the given 'ImageName' or Nil if it does not exists.

INPUT

  • Name : Image name

OUTPUT

  • imageObj : The image object or Nil if no object with th given name was found.


GFX.Image.List()

table = GFX.Image.List()

Returns a list of all existing image objects.

OUTPUT

  • table : A table indexed with the object's names holding the object's structure.


GFX.Image:Add(ImageName, ImageFile, Size)

imageObj = GFX.Image:Add(Name, File, Size)

Load the image 'File' and scale it to the given 'Size'. 'Name' is an optional name you may assign to the image object.

INPUT

  • Name : Unique id to name the image to load (optional)
  • File : Image filename
  • Size : A table with the items 'w' and 'h' to specify the size of the image.
    If you do not specify this argument the image will not be scaled.

OUTPUT

  • imageObj : Returns the image object or Nil if an error occurred.

NOTE
All image objects will be stored in the GFX.Images table indexed with the assigned 'Name'.
If you don't assign the name an unique id will be generated for you.



GFX.Image:Clone(NewName, TintParams)

imageObj = GFX.Image:Clone(NewName, TintParams)

Clone an existing image an optionally apply a tint effect to the new one.
The current object will be cloned to a new one called 'NewName', if the chosen name already exists the function will abort.
If you do not set a name a new one will be chosen for you.

INPUT

  • NewName : Name to assign to the cloned image
  • TintParams : Optional tint parameters, is a table:
    → Color : The tint color
    → Strenght : The tint strenght to apply (0-255)

OUTPUT

  • imageObj : The cloned image object or Nil if an error occurred.


GFX.Image:Draw(Position)

GFX.Image:Draw(position)

Renders the image at the given coordinates

INPUT

  • Position : Must have the following members
    → x : Horizontal position
    → y : Vertical position


GFX.Image:NewLayer(LayerName, Position, Hidden)

GFX.Image:NewLayer(LayerName, Position, Hidden)

Create a layer from this object at the given 'Position', optionally the new layer can be hidden.

INPUT

  • LayerName : The layer name we want to create, if you do not set it the image name will be used, if a layer with the same name exists the creation will fail.
  • Position : A table with the fields 'x' and 'y' to set the layer position, default values are x=0, y=0.
  • Hidden : Set to True if you want to set the new layer invisible.
    Default value is False (visible).

OUTPUT

  • LayerName : The new layer name or Nil if an error occurred.


GFX.Image:Reload()

GFX.Image:Reload()

Reload an image object source.



GFX.Image:Remove()

GFX.Image:Remove()

Remove the object from the system, the attached brush will be removed too.



GFX.Image:Resize(width, height, smooth)

GFX.Image:Resize(width, height)

Permanently resizes an image object.

INPUT

  • width : Desired width
  • height : Desired height
  • smooth : Smooth the scaled image : default = True
hollywoodlibs/gfx/image.txt · Ultima modifica: 2016/11/18 11:14 da admin
CC Attribution-Noncommercial 4.0 International
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0